英文

MiniLM-L12-H384-uncased for QA

概述

语言模型:microsoft/MiniLM-L12-H384-uncased 语言:英文 Downstream 任务:抽取式问答(Extractive QA) 训练数据:SQuAD 2.0 评估数据:SQuAD 2.0 代码:见 example QA pipeline on Haystack 基础设施:1x Tesla v100

超参数

seed=42
batch_size = 12
n_epochs = 4
base_LM_model = "microsoft/MiniLM-L12-H384-uncased"
max_seq_len = 384
learning_rate = 4e-5
lr_schedule = LinearWarmup
warmup_proportion = 0.2
doc_stride=128
max_query_length=64
grad_acc_steps=4

性能

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

"exact": 76.13071675229513,
"f1": 79.49786500219953,
"total": 11873,
"HasAns_exact": 78.35695006747639,
"HasAns_f1": 85.10090269418276,
"HasAns_total": 5928,
"NoAns_exact": 73.91084945332211,
"NoAns_f1": 73.91084945332211,
"NoAns_total": 5945

使用方法

在 Haystack 中

若要进行大规模的问答(即多个文档而不是单个段落),您也可以在 Haystack 中加载模型:

reader = FARMReader(model_name_or_path="deepset/minilm-uncased-squad2")
# or
reader = TransformersReader(model="deepset/minilm-uncased-squad2",tokenizer="deepset/minilm-uncased-squad2")

在 Transformers 中

from transformers import AutoModelForQuestionAnswering,  AutoTokenizer, pipeline

model_name = "deepset/minilm-uncased-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)

作者

Vaishali Pal: vaishali.pal@deepset.ai Branden Chan: branden.chan@deepset.ai Timo Möller: timo.moeller@deepset.ai Malte Pietsch: malte.pietsch@deepset.ai Tanay Soni: tanay.soni@deepset.ai

关于我们

deepset 是开源的 NLP 框架 Haystack 的背后公司。该框架旨在帮助您构建可用于生产环境的NLP系统,包括问答、摘要、排名等功能。

我们的其他工作:

联系我们并加入 Haystack 社区

有关 Haystack 的更多信息,请访问我们的 GitHub 仓库和 Documentation

我们还有一个 Discord community open to everyone!

Twitter | LinkedIn | Discord | GitHub Discussions | Website

顺便说一句: we're hiring!