前面已经熟悉了相关博文,fastTEXT,纠错/MLM/NER/情感分析/摘要,本文将继续介绍基本业务。
6,给定文本,做阅读理解题,也即Extractive Question Answering:extracting an answer from a text given a question 。相关数据集为SQuAD。
- from transformers import pipeline
- question_answerer = pipeline("question-answering")
- context = r"""
- Extractive Question Answering is the task of extracting an answer from a text given a question. An example of a
- question answering dataset is the SQuAD dataset, which is entirely based on that task. If you would like to fine-tune
- a model on a SQuAD task, you may leverage the examples/pytorch/question-answering/run_squad.py script.
- """
- >>> result = question_answere