模型:

consciousAI/question-answering-roberta-base-s

英文

问答模型

该模型用于问答任务,给定问题和上下文,模型将尝试推断出答案文本、答案范围和置信度得分。模型是基于编码器的(roberta-base),带有问答语言模型头,在SQUADx数据集上进行了微调,精确匹配率为86.14%,f1得分为92.33%。

Live Demo: Question Answering Encoders vs Generative

请点击此链接进行 Encoder based Question Answering V2 ,请点击此链接进行 Generative Question Answering

示例代码:

from transformers import pipeline

model_checkpoint = "consciousAI/question-answering-roberta-base-s"

context = """
🤗 Transformers is backed by the three most popular deep learning libraries — Jax, PyTorch and TensorFlow — with a seamless integration
between them. It's straightforward to train your models with one before loading them for inference with the other.
"""
question = "Which deep learning libraries back 🤗 Transformers?"

question_answerer = pipeline("question-answering", model=model_checkpoint)
question_answerer(question=question, context=context)

训练和评估数据

SQUAD分割

训练过程

预处理:

  • SQUAD数据的较长块被分为最大长度为384个令牌的子块,并设置为128个令牌的步幅。
  • 目标答案根据子块进行重新调整,子块中没有答案或部分答案的被设置为目标答案范围(0,0)。
  • 度量标准:

  • 根据子块处理进行相应调整。
  • n best = 20
  • 跳过长度为零或高于最大答案长度(30)的答案。
  • 训练超参数

    自定义训练循环:训练过程中使用了以下超参数:

    • learning_rate:2e-5
    • train_batch_size:32
    • eval_batch_size:32
    • optimizer:Adam,beta=(0.9,0.999),epsilon=1e-08
    • lr_scheduler_type:linear
    • num_epochs:2

    训练结果

    Epoch F1 Exact Match
    1.0 91.3085 84.5412
    2.0 92.3304 86.1400

    框架版本

    • Transformers 4.23.0.dev0
    • Pytorch 1.12.1+cu113
    • Datasets 2.5.2
    • Tokenizers 0.13.0