模型:

consciousAI/question-answering-roberta-base-s-v2

英文

问答

该模型用于问答任务,给定问题和上下文,模型会试图推断答案文本、答案范围和置信度得分。模型是仅编码器(deepset/roberta-base-squad2),带有QuestionAnswering LM Head,在SQUADx数据集上进行了微调,得到了精确匹配:84.83和F1:91.80的性能得分。

Live Demo: Question Answering Encoders vs Generative

请点击此处进行 Encoder based Question Answering V1 ,请点击此处进行 Generative Question Answering

示例代码:

from transformers import pipeline

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

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)的答案。
  • 训练超参数

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

    • 学习率:2e-5
    • 训练批次大小:32
    • 评估批次大小:32
    • 优化器:Adam,beta=(0.9,0.999),epsilon=1e-08
    • lr_scheduler_type:linear
    • num_epochs:2

    训练结果

    {'exact_match': 84.83443708609272, 'f1': 91.79987545811638}

    框架版本

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