Skip to content

抽取式问答

在 Potato 中搭建 SQuAD 风格的问答界面,用于基于片段的答案抽取、阅读理解任务和段落高亮标注。

抽取式问答标注 schema 提供一个问答界面,标注者直接在文本段落中高亮出答案片段。这个 schema 适合构建阅读理解数据集、SQuAD 风格的问答标注、事实核查,以及任何需要从原文中原样抽取答案的任务。

Potato 抽取式问答界面,在段落中高亮答案片段Potato 中的抽取式问答

概览

抽取式问答 schema 会呈现:

  • 一个问题,醒目地显示在段落上方
  • 一段文本,标注者通过高亮选出答案片段
  • 彩色高亮,标记选中的答案文本
  • 无法回答选项,用于无法从段落中得到答案的问题

快速开始

yaml
annotation_schemes:
  - annotation_type: extractive_qa
    name: answer_span
    description: Highlight the answer to the question in the passage below.
    question_field: question
    passage_field: passage
    allow_unanswerable: true

配置选项

字段类型默认值说明
annotation_typestring必填必须为 "extractive_qa"
namestring必填该 schema 的唯一标识符
descriptionstring必填展示给标注者的说明
question_fieldstring"question"数据 JSON 中存放问题文本的字段
passage_fieldstring""数据 JSON 中存放段落文本的字段(空字符串表示使用默认的文本字段)
allow_unanswerablebooleantrue显示一个复选框,用于把问题标记为无法回答
highlight_colorstring"#FFEB3B"答案高亮的 CSS 颜色

示例

SQuAD 风格问答

yaml
annotation_schemes:
  - annotation_type: extractive_qa
    name: squad_answer
    description: >
      Select the shortest span in the passage that answers the question.
      If the question cannot be answered from the passage, mark it as unanswerable.
    question_field: question
    passage_field: context
    allow_unanswerable: true
    highlight_color: "#FFEB3B"

配合样例数据:

json
{
  "id": "q001",
  "question": "When was the university founded?",
  "context": "The University of Michigan was founded in 1817 in Detroit and moved to Ann Arbor in 1837. It is one of the oldest public universities in the United States."
}

事实核查

yaml
annotation_schemes:
  - annotation_type: extractive_qa
    name: evidence_span
    description: >
      Highlight the evidence in the passage that supports or refutes the claim.
      Mark as unanswerable if the passage contains no relevant evidence.
    question_field: claim
    passage_field: document
    allow_unanswerable: true
    highlight_color: "#81C784"

不带无法回答选项的答案抽取

yaml
annotation_schemes:
  - annotation_type: extractive_qa
    name: definition_extraction
    description: >
      Highlight the definition of the term in the passage.
      Every passage contains a definition — select the most precise span.
    question_field: term
    passage_field: text
    allow_unanswerable: false
    highlight_color: "#64B5F6"

输出格式

json
{
  "answer_span": {
    "labels": {
      "answer_start": 45,
      "answer_end": 49,
      "answer_text": "1817",
      "unanswerable": false
    }
  }
}

标注者把问题标记为无法回答时:

json
{
  "answer_span": {
    "labels": {
      "unanswerable": true
    }
  }
}

实践建议

  1. 要求标注者选最小片段 —— 能完整回答问题的最短文本,能得到更干净的训练数据
  2. 在贴近真实的任务中启用 allow_unanswerable —— 现实中的问答常常包含无法回答的问题;关掉这个选项会逼标注者去猜
  3. 选好读的高亮颜色 —— 确保高亮色和文字有足够对比度,看起来不费劲
  4. 段落长度控制在合理范围 —— 每段 100-500 词比较合适;段落太长会让片段选择变得很累
  5. 把问题写清楚 —— 确保问题表述完整、没有歧义,减少标注者的困惑

延伸阅读

有关实现详情,请参阅源文档