模型:

ydshieh/roberta-base-squad2

英文

roberta-base用于问答

注意:这是模型的第二个版本。有关我们为什么进行更新的说明,请参见FARM存储库中的 this github issue 。如果您想使用第一个版本,在Transformers 3.5中加载模型时指定revision="v1.0"。例如:

model_name = "deepset/roberta-base-squad2"
pipeline(model=model_name, tokenizer=model_name, revision="v1.0", task="question-answering")

概述

语言模型:roberta-base 语言:English 下游任务:提取型问答训练数据:SQuAD 2.0 评估数据:SQuAD 2.0 代码:在 FARM 中参见 example 的基础设施 4x Tesla v100

超参数

batch_size = 96
n_epochs = 2
base_LM_model = "roberta-base"
max_seq_len = 386
learning_rate = 3e-5
lr_schedule = LinearWarmup
warmup_proportion = 0.2
doc_stride=128
max_query_length=64

使用蒸馏模型

请注意,我们还发布了该模型的蒸馏版本,称为 deepset/tinyroberta-squad2 。蒸馏模型具有相当的预测质量,并且运行速度是基础模型的两倍。

性能

official eval script 在SQuAD 2.0开发集上进行评估。

"exact": 79.87029394424324,
"f1": 82.91251169582613,

"total": 11873,
"HasAns_exact": 77.93522267206478,
"HasAns_f1": 84.02838248389763,
"HasAns_total": 5928,
"NoAns_exact": 81.79983179142137,
"NoAns_f1": 81.79983179142137,
"NoAns_total": 5945

用法

在Transformers中

from transformers import AutoModelForQuestionAnswering, AutoTokenizer, pipeline

model_name = "deepset/roberta-base-squad2"

# a) Get predictions
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)

# b) Load model & tokenizer
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 Inferencer

model_name = "deepset/roberta-base-squad2"

# a) Get predictions
nlp = Inferencer.load(model_name, task_type="question_answering")
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)

# b) Load model & tokenizer
model = AdaptiveModel.convert_from_transformers(model_name, device="cpu", task_type="question_answering")
tokenizer = Tokenizer.load(model_name)

在haystack中

若要对大规模文档进行问答(而不是单个段落),您还可以在 haystack 中加载模型:

reader = FARMReader(model_name_or_path="deepset/roberta-base-squad2")
# or 
reader = TransformersReader(model_name_or_path="deepset/roberta-base-squad2",tokenizer="deepset/roberta-base-squad2")

作者

Branden Chan:branden.chan [at] deepset.ai Timo Möller:timo.moeller [at] deepset.ai Malte Pietsch:malte.pietsch [at] deepset.ai Tanay Soni:tanay.soni [at] deepset.ai

关于我们

我们通过开源将自然语言处理技术带给行业!我们的重点是行业特定的语言模型和大规模问答系统。

我们的一些工作:

联系我们: Twitter | LinkedIn | Slack | GitHub Discussions | Website

顺便说一句: we're hiring!