SkelterLabsInc/JaQuAD
Viewer • Updated • 35.7k • 309 • 12
How to use takehika/xlm-roberta-ja-jaquad-qa with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("question-answering", model="takehika/xlm-roberta-ja-jaquad-qa") # Load model directly
from transformers import AutoTokenizer, AutoModelForQuestionAnswering
tokenizer = AutoTokenizer.from_pretrained("takehika/xlm-roberta-ja-jaquad-qa")
model = AutoModelForQuestionAnswering.from_pretrained("takehika/xlm-roberta-ja-jaquad-qa", device_map="auto")Fine-tuned xlm-roberta-base on the Japanese JaQuAD dataset for extractive question answering.
xlm-roberta-baseFrom from_pretrained:
from transformers import AutoTokenizer, AutoModelForQuestionAnswering
import torch
model_id = "takehika/xlm-roberta-ja-jaquad-qa"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForQuestionAnswering.from_pretrained(model_id).eval()
text = "私は音声アシスタントです。名前はありませんが皆はAIと呼んでいるようです。自宅は暗い箱の中ですが寂しくはありません。好きな食べ物は電気で特技は繰り返すことです。"
questions= ["音声アシスタントはどこに住んでいますか?", "好きな食べ物は?", "名前は?"]
for q in questions:
inputs = tokenizer.encode_plus(
q, text,
add_special_tokens=True,
return_tensors="pt",
truncation=True,
max_length=512,
)
inputs = {k: v for k, v in inputs.items()}
with torch.no_grad():
out = model(**inputs)
start = out.start_logits.argmax(dim=-1).item()
end = out.end_logits.argmax(dim=-1).item()
answer = tokenizer.decode(inputs["input_ids"][0][start:end+1], skip_special_tokens=True)
print(f"質問: {q} -> 回答: {answer}")
SkelterLabsInc/JaQuAD)xlm-roberta-baseThis model modifies the base model by fine-tuning on the above dataset.
Please cite the following when using the XLM-R base model:
@article{DBLP:journals/corr/abs-1911-02116,
author = {Alexis Conneau and
Kartikay Khandelwal and
Naman Goyal and
Vishrav Chaudhary and
Guillaume Wenzek and
Francisco Guzm{\'{a}}n and
Edouard Grave and
Myle Ott and
Luke Zettlemoyer and
Veselin Stoyanov},
title = {Unsupervised Cross-lingual Representation Learning at Scale},
journal = {CoRR},
volume = {abs/1911.02116},
year = {2019},
url = {http://arxiv.org/abs/1911.02116},
eprinttype = {arXiv},
eprint = {1911.02116},
timestamp = {Mon, 11 Nov 2019 18:38:09 +0100},
biburl = {https://dblp.org/rec/journals/corr/abs-1911-02116.bib},
bibsource = {dblp computer science bibliography, https://dblp.org}
}
Please cite the following when using the JaQuAD dataset:
@misc{so2022jaquad,
title={{JaQuAD: Japanese Question Answering Dataset for Machine Reading Comprehension}},
author={ByungHoon So and Kyuhong Byun and Kyungwon Kang and Seongjin Cho},
year={2022},
eprint={2202.01764},
archivePrefix={arXiv},
primaryClass={cs.CL}
}
Base model
FacebookAI/xlm-roberta-base