🚀 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
🔧 技术细节
文档未提供具体技术细节,暂不展示。
📄 许可证
文档未提及许可证信息,暂不展示。