🚀 xlm-roberta-large用於多語言問答
本項目使用xlm-roberta-large
語言模型處理多語言問答任務,在多語言問答數據集上展現出良好性能,為多語言環境下的問答應用提供了有效的解決方案。
🚀 快速開始
本模型可用於多語言問答任務,下面將展示在不同框架中的使用示例。
✨ 主要特性
- 語言模型:採用
xlm-roberta-large
語言模型。
- 下游任務:適用於抽取式問答任務。
- 訓練數據:使用XQuAD數據集進行訓練和測試。
📦 安裝指南
文檔未提及安裝步驟,暫不展示。
💻 使用示例
基礎用法
在Transformers框架中使用
from transformers import AutoModelForQuestionAnswering, AutoTokenizer, pipeline
model_name = "alon-albalak/xlm-roberta-large-xquad"
nlp = pipeline('question-answering', model=model_name, tokenizer=model_name)
QA_input = {
'question': 'Why is model conversion important?',
'context': 'The option to convert models between FARM and transformers gives freedom to the user and let people easily switch between frameworks.'
}
res = nlp(QA_input)
model = AutoModelForQuestionAnswering.from_pretrained(model_name)
tokenizer = AutoTokenizer.from_pretrained(model_name)
在FARM框架中使用
from farm.modeling.adaptive_model import AdaptiveModel
from farm.modeling.tokenization import Tokenizer
from farm.infer import QAInferencer
model_name = "alon-albalak/xlm-roberta-large-xquad"
nlp = QAInferencer.load(model_name)
QA_input = [{"questions": ["Why is model conversion important?"],
"text": "The option to convert models between FARM and transformers gives freedom to the user and let people easily switch between frameworks."}]
res = nlp.inference_from_dicts(dicts=QA_input, rest_api_schema=True)
model = AdaptiveModel.convert_from_transformers(model_name, device="cpu", task_type="question_answering")
tokenizer = Tokenizer.load(model_name)
在Haystack框架中使用
reader = FARMReader(model_name_or_path="alon-albalak/xlm-roberta-large-xquad")
reader = TransformersReader(model="alon-albalak/xlm-roberta-large-xquad",tokenizer="alon-albalak/xlm-roberta-large-xquad")
使用說明參考自:https://huggingface.co/deepset/xlm-roberta-large-squad2
高級用法
文檔未提及高級用法示例,暫不展示。
📚 詳細文檔
超參數設置
batch_size = 48
n_epochs = 13
max_seq_len = 384
doc_stride = 128
learning_rate = 3e-5
性能評估
在XQuAD的保留測試集上進行評估:
"exact_match": 87.12546816479401,
"f1": 94.77703248802527,
"test_samples": 2307
🔧 技術細節
文檔未提供具體技術細節,暫不展示。
📄 許可證
文檔未提及許可證信息,暫不展示。