Text Summarization: Abstractive and Extractive Methods
What You'll Learn
- 1Separate extractive summarization, which selects sentences, from abstractive summarization, which rewrites
- 2Compute ROUGE 1, ROUGE 2, and ROUGE L precision, recall, and F1 by hand
- 3Explain how the pointer generator and coverage loss control copying and repetition
- 4Diagnose a summary that scores well on ROUGE but is factually wrong
Summarization produces a shorter text that keeps the source meaning, and the field splits on one question: does the system select sentences or write new ones. That choice determines your error modes, because extractive summaries inherit source sentences and cannot add a word that was never there, while abstractive models can compress across paragraphs and can also invent facts. This lesson builds both variants and the ROUGE arithmetic that scores them.
Extractive Summarization
An extractive system ranks sentences and keeps the best subset under a length budget, which is a budgeted selection problem rather than a language modeling problem:
Sentence importance comes from a scorer: TextRank and LexRank (Mihalcea and Tarau, 2004) run PageRank over a similarity graph of sentences, while learned variants classify each sentence with a BERT representation and a binary head. The simplest strong baseline ranks by position, because news articles state their point early.
On CNN/DailyMail the Lead 3 baseline, which returns the first three sentences, reaches 40.42 ROUGE-1, 17.66 ROUGE-2, and 36.67 ROUGE-L (Nallapati et al., 2016), and many neural systems of that era beat it by less than a point. Oracle extraction, which picks the subset that maximizes ROUGE against the reference, gives a ceiling near 52 ROUGE-1, which tells you the gap between picking and writing is smaller than the gap between any extractor and the oracle.
Abstractive Summarization
Abstractive models condition on the source and generate tokens one at a time, so summarization becomes conditional language modeling with a shorter target:
Attention (Bahdanau et al., 2014; Nallapati et al., 2016) lets the decoder align each generated word to source positions, and beam search with a length penalty keeps summaries from collapsing to a few words. The failure mode is repetition: an unconstrained attention decoder attends to the same salient phrase at consecutive steps and loops on it.
The pointer generator (See et al., 2017) blends copying and generating. A scalar gate decides per step how much of the distribution comes from the vocabulary and how much from the source positions:
Because the attention distribution concentrates mass on a few positions, copying works only while it is repeated. The coverage mechanism accumulates past attention for each source position, and the coverage loss charges the model for attending again:
Evaluation with ROUGE
ROUGE (Lin, 2004) measures n-gram overlap between the system summary and one or more references. It reports recall oriented scores by default, and the same formulas give precision and F1 when you want them:
ROUGE-1 counts unigrams, ROUGE-2 bigrams, and ROUGE-L uses the longest common subsequence so that word order matters without requiring adjacent matches.
| System | ROUGE-1 | ROUGE-2 | ROUGE-L | Style |
|---|---|---|---|---|
| Lead 3 baseline | 40.42 | 17.66 | 36.67 | extractive |
| Oracle extraction | 52.02 | 23.02 | 47.92 | extractive ceiling |
| Pointer generator | 39.53 | 17.28 | 36.38 | abstractive |
| BART-large | 44.16 | 21.28 | 40.90 | abstractive |
Two benchmarks define the task. CNN/DailyMail holds roughly 300,000 news articles with multi sentence summaries, so models learn to select. XSum (Napoles et al., 2017) holds 226,711 articles with a single hand written sentence, which forces genuine abstraction and is far harder to game.
Worked Examples
Worked Code
"""ROUGE 1, 2, and L over a candidate and a reference."""
import re
from collections import Counter
def ngrams(tokens, n):
return Counter(tuple(tokens[i:i + n]) for i in range(len(tokens) - n + 1))
def rouge(system, reference, n=1):
s, r = system.split(), reference.split()
overlap = sum((ngrams(s, n) & ngrams(r, n)).values())
p = overlap / max(sum(ngrams(s, n).values()), 1)
rec = overlap / max(sum(ngrams(r, n).values()), 1)
f = 2 * p * rec / (p + rec) if p + rec else 0.0
return round(p, 3), round(rec, 3), round(f, 3)
print(rouge("the cat sat on a red mat", "the cat sat on the red mat", 1))
"""Abstractive summarization with a released BART checkpoint."""
from transformers import pipeline
summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
out = summarizer(
"Long news article about city council budgets ...",
max_length=60,
min_length=20,
length_penalty=2.0,
num_beams=4,
)
print(out[0]["summary_text"])
Real-World Applications
- News digests - Publishers compress articles to two sentences for mobile feeds, where the first screen decides whether a reader opens the story.
- Legal and contract review - Extractive summaries quote clauses verbatim so lawyers can audit every statement back to the source.
- Meeting notes - Diarized transcripts are summarized into decisions and owners, and a hallucinated action item is worse than none.
- Search previews - Result snippets use position based extraction because latency budgets leave no room for a decoder.
đĄROUGE rewards overlap, not truth
Common Mistakes
Comparing ROUGE across datasets
Fix: XSum and CNN DailyMail summaries have different lengths and styles, so scores are not comparable between them.
Tuning length on the test set
Fix: Length budgets change ROUGE by several points, so fix them on dev and hold them fixed.
Reporting ROUGE recall alone
Fix: Recall rises with verbose output, so publish F1 or precision alongside it.
Best Practices
- Report ROUGE 1, 2, and L together with the summary length in words
- Use a Lead 3 baseline before claiming an abstractive gain
- Add an entity overlap or claims check to catch fluent hallucinations
Key Takeaways
- Extractive systems solve a budgeted selection problem while abstractive systems solve conditional language modeling
- The pointer generator mixes vocabulary generation and copying through a per step gate p_gen
- Coverage accumulates past attention and the coverage loss charges repeated visits to a source position
- ROUGE L uses longest common subsequences, so it rewards word order without requiring adjacency
Frequently Asked Questions
Why is ROUGE recall oriented?
Summaries come from documents, and the metric originally asked how much of the reference content was recovered. Recall rises as the summary grows, which is why modern leaderboards publish F1 and fix the length budget.
What length penalty should beam search use?
Values between 1.0 and 2.0 are common. Below 1.0 the decoder favors short outputs that drop content, above 2.5 it starts to ramble and repeat.
When does extraction beat generation?
When faithfulness dominates, latency is tight, or the domain punishes invented numbers. News and legal text both favor quoted extraction; product marketing favors abstraction.
Interview Questions
Q1: Why does repetition happen in abstractive summarization?
The decoder attends to the same high mass source positions at consecutive steps and the vocabulary head has no incentive to stop, so coverage accumulates attention and a loss term is added to penalize revisiting.
Q2: How do you evaluate a summarization system beyond ROUGE?
Add entity level factuality checks, a length matched human preference study, and a Lead 3 comparison, because ROUGE alone cannot separate overlap from correctness.