模型:
ybelkada/japanese-roberta-question-answering
语言:
ja许可:
cc-by-sa-3.0一个在 JaQuAD 上进行微调的日本问答模型。有关预训练模型的详细信息,请参阅 RoBERTa base Japanese 。微调的代码可在 on this notebook 上找到。
from transformers import AutoModelForQuestionAnswering, AutoTokenizer question = 'アレクサンダー・グラハム・ベルは、どこで生まれたの?' context = 'アレクサンダー・グラハム・ベルは、スコットランド生まれの科学者、発明家、工学者である。世界初の>実用的電話の発明で知られている。' model = AutoModelForQuestionAnswering.from_pretrained( 'ybelkada/japanese-roberta-question-answering') tokenizer = AutoTokenizer.from_pretrained( 'ybelkada/japanese-roberta-question-answering') inputs = tokenizer( question, context, add_special_tokens=True, return_tensors="pt") input_ids = inputs["input_ids"].tolist()[0] outputs = model(**inputs) answer_start_scores = outputs.start_logits answer_end_scores = outputs.end_logits # Get the most likely beginning of answer with the argmax of the score. answer_start = torch.argmax(answer_start_scores) # Get the most likely end of answer with the argmax of the score. # 1 is added to `answer_end` because the index pointed by score is inclusive. answer_end = torch.argmax(answer_end_scores) + 1 answer = tokenizer.convert_tokens_to_string( tokenizer.convert_ids_to_tokens(input_ids[answer_start:answer_end])) # answer = 'スコットランド'
经过微调的模型使用 CC BY-SA 3.0 许可证。
该问答小部件在该模型上不起作用。我尝试使用Pipeline重现了错误,需要进一步调查。