NLP & Transformers

Extractive vs Abstractive QA

Comparing span extraction from source text against generative abstractive answer synthesis.

🟡 intermediate5 min readnlp
Question Answering (QA) algorithms extract or generate answers to user queries given context documents. Extractive QA models (BERT on SQuAD) locate the exact start and end character span tokens within a passage to extract text answers directly. Abstractive QA models (Generative LLMs) read source documents and synthesize fluent natural language answers in new words. Modern production systems combine vector search retrieval (RAG) with abstractive LLM generators.

Two Question Answering Paradigms

Question Answering (QA) models answer natural language questions based on a context document.

  CONTEXT DOCUMENT: "The Eiffel Tower was completed in 1889 in Paris, France."
  QUESTION:         "When was the Eiffel Tower built?"

  EXTRACTIVE QA (BERT):    Predicts exact text span -> "1889" (High Precision, Rigid)
  ABSTRACTIVE QA (GPT-4):  Generates new sentence  -> "The Eiffel Tower was constructed in 1889." (Fluent, Generative)

1. Extractive Question Answering (BERT / SQuAD)

Extractive QA treats question answering as a Span Selection Task.

The model receives a concatenated sequence: [CLS] Question [SEP] Context Passage.

It does NOT generate new words. It predicts two token index numbers:

  1. Start Token Index ($i$): Where the answer starts in the passage.
  2. End Token Index ($j$): Where the answer ends in the passage.
  Passage Tokens:   The   Eiffel   Tower   was   completed   in   [1889]   in   Paris
  Start Score:     0.01    0.01    0.01   0.01     0.01     0.01   0.92   0.01   0.01  (Index 7!)
  End Score:       0.01    0.01    0.01   0.01     0.01     0.01   0.94   0.01   0.01  (Index 7!)

2. Abstractive Question Answering (Generative LLMs)

Abstractive QA reads context documents and generates fluent, full sentence answers in its own words using autoregressive decoder LLMs (GPT-4, LLaMA 3).

  Prompt: "Answer the question based ONLY on context: <Context> Question: <Question>"
  LLM Generation: "According to the provided document, construction finished in 1889."

Production Benchmark Datasets

  1. SQuAD (Stanford Question Answering Dataset): Benchmark dataset of 100,000+ Wikipedia passage question pairs for Extractive QA.
  2. MS MARCO (Microsoft): Real Bing search queries and web passages for information retrieval and QA evaluation.
  3. TriviaQA / Natural Questions: Open domain trivia questions testing general knowledge retrieval.

Say this out loud

Extractive QA predicts exact start and end token indices within a source passage to highlight answers directly without hallucination. Abstractive QA uses generative LLMs to synthesize fluent natural language answers in new words. Production systems use RAG to retrieve ground context passages for abstractive LLM generation.

Followups to expect

  1. What is RAG (Retrieval-Augmented Generation)? Combining dense vector retrieval (finding top-K relevant documents from a database) with an abstractive LLM generator to ground answer generation on real business data.
  2. What is Exact Match (EM) vs F1 Score in SQuAD evaluation? Exact Match requires the predicted span string to match human ground truth character for character. F1 measures word level precision and recall overlap between predicted and target spans.

Check yourself

Question 1 of 3

What is the main operational difference between Extractive Question Answering and Abstractive Question Answering?

More in NLP & Transformers

See all →
The Attention Mechanism5 minTransformer Architecture5 minTokenization & BPE5 min