Transmuter.Text.QuestionAnswering (transmuter v2.0.0)

Copy Markdown View Source

The question answering task. See Transmuter.Text.question_answering/2.

The search for the answer follows the question answering pipeline of Python transformers:

  1. A long context becomes windows of the largest sequence length, which is 384 tokens by default. Each window repeats the last 128 tokens of the window before it, or half of the largest length when that is less.
  2. In each window, the start and end logits of the tokens out of the context get -10000. A softmax gives the start and end scores. The first token, the CLS token of most models, gets the score 0.
  3. The score of a span is the start score of its first token times the end score of its last token. A span has at most :max_answer_length tokens.
  4. The 12 spans with the highest scores in each window are candidates. Each candidate grows to the start of its first word and the end of its last word.
  5. Candidates with the same text, without case, become one answer with the sum of their scores. The answer with the highest score is the result.