Downloads · 30 days
148
2% of all-time downloads
ybelkada/japanese-roberta-question-answering
japanese-roberta-question-answering is a question answering model from ybelkada. Use it when the input is a question plus a passage. It is set up for transformers. The card lists the license as cc-by-sa-3.0.
A Japanese Question Answering model fine-tuned on JaQuAD. Please refer RoBERTa base Japanese for details about the pre-training model. The codes for the fine-tuning are available on this notebook
Downloads · 30 days
148
2% of all-time downloads
All-time downloads
9.8K
Public
Repo size
1.8 GB
Likes
1
Public
Click a slice to open those files.
.bin440 MB · 99%
From the Hugging Face model README
A Japanese Question Answering model fine-tuned on JaQuAD. Please refer RoBERTa base Japanese for details about the pre-training model. The codes for the fine-tuning are available 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 = 'スコットランド'
The fine-tuned model is licensed under the CC BY-SA 3.0 license.
The Q&A widget does not work on that model. Tried also with Pipeline and I was able to reproduce the error, needs a further investigation