语言:
- 日语
许可证: mit
标签:
- 问答系统
- 训练生成
- bert
- jaquad
数据集: SkelterLabsInc/JaQuAD
推理参数:
参数:
对齐到单词: false
示例:
- 文本: 在淘汰赛中击败日本的是哪个国家?
上下文: 日本在预选赛中战胜了强队德国和西班牙晋级淘汰赛,但在对阵克罗地亚时败北。
- 文本: 8世纪时日本的首都是哪里?
上下文: 作为8世纪日本首都奈良的代表性寺院,东大寺以"古都奈良的文化财产"之一被列入世界遗产。东大寺内收藏有被称为"奈良大佛"、高约15米的卢舍那佛像等众多代表日本佛教艺术史的著名作品。
- 文本: "奈良大佛"的高度是多少米?
上下文: 作为8世纪日本首都奈良的代表性寺院,东大寺以"古都奈良的文化财产"之一被列入世界遗产。东大寺内收藏有被称为"奈良大佛"、高约15米的卢舍那佛像等众多代表日本佛教艺术史的著名作品。
基础模型: rinna/japanese-roberta-base
模型索引:
- 名称: roberta_qa_japanese
结果: []
roberta_qa_japanese
(日语说明:日语(抽取式)问答模型)
该模型是基于rinna/japanese-roberta-base(由rinna株式会社提供的预训练RoBERTa模型)微调而成的抽取式问答模型。
模型在Skelter Labs提供的JaQuAD数据集上进行了微调,该数据集的数据来自日语维基百科文章并由人工标注。
预期用途
使用专用管道运行时:
from transformers import pipeline
model_name = "tsmatz/roberta_qa_japanese"
qa_pipeline = pipeline(
"question-answering",
model=model_name,
tokenizer=model_name)
result = qa_pipeline(
question = "在淘汰赛中击败日本的是哪个国家?",
context = "日本在预选赛中战胜了强队德国和西班牙晋级淘汰赛,但在对阵克罗地亚时败北。",
align_to_words = False,
)
print(result)
手动通过前向传播运行时:
import torch
import numpy as np
from transformers import AutoModelForQuestionAnswering, AutoTokenizer
model_name = "tsmatz/roberta_qa_japanese"
model = (AutoModelForQuestionAnswering
.from_pretrained(model_name))
tokenizer = AutoTokenizer.from_pretrained(model_name)
def inference_answer(question, context):
question = question
context = context
test_feature = tokenizer(
question,
context,
max_length=318,
)
with torch.no_grad():
outputs = model(torch.tensor([test_feature["input_ids"]]))
start_logits = outputs.start_logits.cpu().numpy()
end_logits = outputs.end_logits.cpu().numpy()
answer_ids = test_feature["input_ids"][np.argmax(start_logits):np.argmax(end_logits)+1]
return "".join(tokenizer.batch_decode(answer_ids))
question = "在淘汰赛中击败日本的是哪个国家?"
context = "日本在预选赛中战胜了强队德国和西班牙晋级淘汰赛,但在对阵克罗地亚时败北。"
answer_pred = inference_answer(question, context)
print(answer_pred)
训练过程
您可以从这里下载微调的源代码。
训练超参数
训练过程中使用了以下超参数:
- 学习率: 7e-05
- 训练批次大小: 2
- 评估批次大小: 1
- 随机种子: 42
- 梯度累积步数: 16
- 总训练批次大小: 32
- 优化器: Adam,参数为betas=(0.9,0.999)和epsilon=1e-08
- 学习率调度器类型: 线性
- 学习率预热步数: 100
- 训练轮数: 3
训练结果
训练损失 |
轮次 |
步数 |
验证损失 |
2.1293 |
0.13 |
150 |
1.0311 |
1.1965 |
0.26 |
300 |
0.6723 |
1.022 |
0.39 |
450 |
0.4838 |
0.9594 |
0.53 |
600 |
0.5174 |
0.9187 |
0.66 |
750 |
0.4671 |
0.8229 |
0.79 |
900 |
0.4650 |
0.71 |
0.92 |
1050 |
0.2648 |
0.5436 |
1.05 |
1200 |
0.2665 |
0.5045 |
1.19 |
1350 |
0.2686 |
0.5025 |
1.32 |
1500 |
0.2082 |
0.5213 |
1.45 |
1650 |
0.1715 |
0.4648 |
1.58 |
1800 |
0.1563 |
0.4698 |
1.71 |
1950 |
0.1488 |
0.4823 |
1.84 |
2100 |
0.1050 |
0.4482 |
1.97 |
2250 |
0.0821 |
0.2755 |
2.11 |
2400 |
0.0898 |
0.2834 |
2.24 |
2550 |
0.0964 |
0.2525 |
2.37 |
2700 |
0.0533 |
0.2606 |
2.5 |
2850 |
0.0561 |
0.2467 |
2.63 |
3000 |
0.0601 |
0.2799 |
2.77 |
3150 |
0.0562 |
0.2497 |
2.9 |
3300 |
0.0516 |
框架版本
- Transformers 4.23.1
- Pytorch 1.12.1+cu102
- Datasets 2.6.1
- Tokenizers 0.13.1