Contents Applications Code Course home

Chapter 26Summarisation

After this chapter you will be able to

  • separate extractive from abstractive summarisation and say what each can and cannot do;

  • measure how extractive a corpus is and use it to decide what a model must learn;

  • choose between truncation, sparse attention and hierarchical summarisation for a long input;

  • explain teacher forcing, exposure bias and the loss mask;

  • rank sentences with a frequency score, score four candidates with ROUGE, and see where two cheap faithfulness checks fail.

  • say why ROUGE does not measure faithfulness and what does.

This chapter builds on Chapters 19, 23 and 20, which supply the models, the metrics and the controls.

A task with no right answer

Translation has a target, in that two competent translators produce texts that say the same thing, even when the wording differs. Summarisation does not work that way, because two competent people summarising the same article will disagree about what mattered and both can be right. That makes it the hardest generation task to evaluate, and a good one to study. Four problems from Part V meet in it. A decoder must choose its words, and the choice can drift from the source. A summary can read well and still say something the source did not. ROUGE can score it highly anyway. And a long document may not fit in the context window. Each gets a section below.

Two tasks wearing one name

The word covers two different problems, and they should be separated.

extractive abstractive
what it does selects sentences from the source generates new text
can it hallucinate? no, by construction yes
how it reads disjointed fluent
what it is a ranking problem a generation problem

Extractive summarisation cannot state anything the source did not, which is a guarantee no generative system can offer, and it reads badly because sentences lifted out of context do not join up. Abstractive summarisation reads well and can compress genuinely, saying in one clause what the source took a paragraph to say, and it can also state things the source never said. Transformers made abstractive summarisation practical and made faithfulness the central problem, and those two facts are the same fact.

The dataset decides the task

This is the part most often skipped and it changes everything downstream, because two datasets dominate the literature and they are not the same task. CNN/DailyMail pairs news articles with their bullet-point highlights, and those highlights are largely extractive, since most of their content appears near-verbatim in the first few sentences of the article. XSum pairs BBC articles with their one-sentence opening summary, which is written to be genuinely abstractive and often states something no single sentence of the article states.

Three consequences follow. A model tuned on one transfers poorly to the other, because they reward different behaviour. On CNN/DailyMail a lead-sentence baseline, which simply returns the first few sentences, is competitive, so if your model cannot beat it then you have not established that it learned anything. And hallucination rates on XSum are far higher, which is not a defect of the models, because the dataset asks for statements not present in the source and a model that obliges will sometimes oblige incorrectly.

The practical rule is short. Before choosing a model, measure how extractive your target summaries are, because that number tells you what you are actually training.

Measuring how extractive a summary is

The practical rule above needs a number, and the simplest one is the share of summary bigrams that appear in the source. Take a source sentence the council approved the new budget on tuesday after a long debate and two candidate summaries.

summary bigrams in the source share
council approved new budget 2 of 3 0.667
the council approved the new budget 5 of 5 1.000
lawmakers back spending plan 0 of 3 0.000

The first summary has two bigrams from the source, council approved and new budget, and one that joins them, approved new, which the source does not contain. The second is a lead-style extract and scores one. The third says the same thing in new words and scores zero, although a reader would call it correct. A corpus whose summaries score near one is an extractive task, and a lead baseline will be hard to beat. A corpus near zero is abstractive, and it is where faithfulness errors appear.

An extractive summariser

Extractive summarisation is a ranking problem, and the simplest ranker scores each sentence by how often its content words recur in the article. A sentence made of words the article keeps returning to is probably about the article’s topic. Content words are what remains after dropping function words such as the, of and by. Take an article of seven sentences.

sentence
S1 Heavy rain fell across the region on Tuesday.
S2 The city council approved a new budget after a long debate.
S3 The budget raises spending on roads by 12 percent.
S4 Council members from the northern wards argued that the increase was too small.
S5 Residents had asked for repairs to the bridge for three years.
S6 The mayor said the first repairs will begin in March.
S7 A public meeting on the plan will be held next month.

Three content words occur twice in the article, budget, council and repairs, and every other content word occurs once. The score of a sentence is the sum of its words’ counts divided by the number of content words, and the division stops a long sentence from winning on length alone.

sentence content words sum of counts score
S1 6 6 1.000
S2 6 8 1.333
S3 6 7 1.167
S4 8 9 1.125
S5 6 7 1.167
S6 6 7 1.167
S7 5 5 1.000

The best sentence is S2 at 1.3331.333. Three sentences then tie at 1.1671.167, and as with the BPE merges of Chapter 5 a tie needs a rule or the run cannot be reproduced. Here the earlier sentence wins, so the summary is S2 followed by S3. The lead baseline takes S1 and S2, and S1 is about the weather, which is why the lead does badly on this article. Whether the scored summary is actually better is a question for a metric, and the evaluation section below scores both.

Seven sentences scored by word frequency, with the two chosen against the lead baseline
An extractive summariser ranks sentences by how much of the article's vocabulary they carry. It can beat a lead baseline when the opening sentences are background.

Which architecture

Two shapes are available and both are in Chapter 19. An encoder-decoder reads the document with a bidirectional encoder and writes with a causal decoder, so the encoder sees the whole source at once. This is the natural fit and what the architecture was designed for. A decoder-only model puts the document and the summary in one sequence and continues it, which is what a general instruction-tuned model does when you ask it to summarise.

The encoder-decoder shape has the better inductive bias and needs fine-tuning, while the decoder-only shape needs no fine-tuning at all and arrives already competent, which usually wins on engineering grounds. Pretraining objective matters more than shape, though, since models pretrained by reconstructing corrupted spans of text and not by predicting the next token transfer to summarisation better, because span reconstruction is the same operation summarisation performs.

The long-input problem

Chapter 17 established that attention costs O(n2)O(n^2) in the sequence length, and summarisation is where that bill arrives. A news article fits in a few hundred tokens, a scientific paper is five to ten thousand, a transcript or a legal filing is longer still, and many checkpoints cap at 512 or 1024.

There are three responses, each with a cost. Truncation is cheap and silently discards the tail of the document, which on news is nearly free because news is written with the important part first, and on a paper removes the results. Sparse attention, as in Longformer (whose encoder-decoder variant is LED) and BigBird, has each position attend to a local window plus a few global positions. This brings the cost back to roughly linear and buys length at some cost in quality. And hierarchical summarisation summarises chunks and then summarises the summaries, which handles any length and compounds errors, because a mistake in a chunk summary is invisible at the next level.

The arithmetic of a hierarchy

Take a transcript of 30,00030{,}000 tokens, a model that reads 5,0005{,}000 tokens at a time, and a chunk summary of 500500 tokens.

level input tokens chunks output tokens
1 30,000 6 3,000
2 3,000 1 500

Six chunks give six summaries of 500500 tokens, which together are 3,0003{,}000 tokens and fit in one window, so a single further call writes the final summary. That is two levels and seven model calls. Each level shrinks the text by a factor of ten, so the number of levels grows with the logarithm of the length and the cost is rarely the problem. Faithfulness is. If each step keeps 9090 per cent of the claims it was given, then 0.90000.9000 survive one level, 0.81000.8100 survive two and 0.65610.6561 survive four, because the losses multiply. The second level also reads six summaries and cannot tell which of them contains a mistake.

Figure 26.1. Hierarchical summarisation. Each level summarises the one below, so any length can be handled. An error in a first-level summary cannot be seen by the levels above it.
Figure 26.2. Full attention connects every pair of positions, which costs n2n^2. A sparse pattern keeps a local window and a few global positions, here the first token, so the cost is roughly linear in the length.
Six chunks, six summaries and a final summary, with the share of faithful claims falling
Hierarchical summarisation handles any length by summarising chunks and then the summaries, but each level can lose faithful claims that the next level cannot see.

A common bug

Measure the length distribution of your inputs and your targets before you set the truncation limits. Truncating inputs is visible, since you know you did it, whereas truncating targets is silent and it is a common bug.

A target cut at the limit teaches the model to stop early, and the loss looks fine throughout training because the model is correctly predicting a truncated target. The failure only appears at generation time, as summaries that end mid-thought.

Training, and one thing it gets wrong

Training is the cross-entropy of Chapter 11, with two details that matter. Mask the loss, because padding tokens must not contribute, and an unmasked loss over a heavily padded batch is mostly measuring the model’s ability to predict padding, which will look encouragingly low. And teacher forcing feeds the decoder the correct previous token at each step and not its own prediction, which makes training parallel and stable and introduces the problem below.

A batch of four summaries has 6262, 4848, 9090 and 4040 text tokens, each padded to 100100.

summary text tokens padding
1 62 38
2 48 52
3 90 10
4 40 60
total 240 160

That is 240240 text tokens among 400400 positions, so 4040 per cent of the positions are padding. Suppose a text token costs 2.82.8 nats and a padding token costs nothing, because it is trivially predictable. Averaged over every position the unmasked loss is 2.8×240/400=1.6802.8 \times 240 / 400 = 1.680, while the masked loss, averaged over the text tokens only, is 2.8002.800. The unmasked curve reads 4040 per cent lower than the model deserves. It falls further whenever a batch is padded more heavily, and that is a change in the data pipeline that says nothing about the model.

Exposure bias

The mismatch is exact. During training every previous token the model sees is correct. During generation the model consumes its own output. The model has never been trained on the distribution it faces at inference, and one early error shifts the context for everything after it. The model has no experience of recovering from its own mistakes, because in training it never made any.

Three partial remedies exist and none is a cure. Label smoothing stops the model becoming over-confident, which makes it less brittle when the context is unfamiliar, scheduled sampling occasionally feeds the model’s own predictions during training, and sequence-level fine-tuning optimises against the evaluation metric, not per-token likelihood.

Exposure bias is also the cleanest reason decoding matters here, since sampling at high temperature compounds it, because an unlikely token early is a corrupted context for everything that follows. Summarisation wants the low-entropy end of Chapter 20’s table.

Evaluation, and a trap

Chapter 23 covered ROUGE, the standard here, and two things matter about using it. Evaluate with generation, not loss, because validation loss measures next-token prediction under teacher forcing, which is not the task, so generate summaries and score them. This is slower, and it is the number that matters, since watching loss alone means watching a quantity that improves while the thing you care about does not, and Chapter 23 named that failure.

ROUGE rewards overlap, and overlap is not faithfulness, so a summary can score well and state something false while a correct paraphrase can score near zero, as Chapter 23 showed with the feline rests upon the rug. For summarisation the gap is specific and it has a name. Faithfulness is whether every claim in the summary is supported by the source, and ROUGE does not measure it, cannot measure it, and a system tuned on ROUGE alone will drift away from it.

Measuring faithfulness needs a different instrument, whether entailment models asking whether the source entails each summary sentence, question-answering consistency checks, or human annotation. All three are more expensive than ROUGE, so ROUGE is still reported.

Four candidates on one article

Score four summaries of the article above against the reference the council approved a budget that raises road spending by 12 percent, and repairs will begin in March, which has 1818 words. The first two candidates are the lead baseline and the frequency summary. The third is a faithful paraphrase, lawmakers passed a spending plan that puts 12 percent more into roads, and work starts in March. The fourth is a copy of the reference with one number wrong, 2121 in place of 1212. ROUGE-NN counts overlapping NN-grams, clipped as in Chapter 23, and its F-score reduces to a short form. With oo overlapping NN-grams, a candidate with cc of them and a reference with rr, precision is o/co/c, recall is o/ro/r and F1=2o/(c+r)F_1 = 2o/(c + r).

candidate words R-1 overlap R-1 F1F_1 R-2 overlap R-2 F1F_1
lead-2 19 5 0.270 2 0.114
frequency-2 20 10 0.526 4 0.222
faithful paraphrase 17 8 0.457 2 0.121
wrong number 18 17 0.944 15 0.882

The frequency summary beats the lead baseline, 0.5260.526 against 0.2700.270, and that gap is the margin a trained system has to improve on. The faithful paraphrase scores 0.4570.457, below the frequency summary that only copies. The candidate with the wrong number scores 0.9440.944, the highest in the table, because it differs from the reference in one word. ROUGE ranks the summary that states a falsehood first.

ROUGE-1 F1 for four candidate summaries, with the wrong-number summary highest
ROUGE rewards overlap with the reference. A summary with one changed number can outscore a faithful paraphrase, so overlap says little about faithfulness.

Two cheap checks, and the claim they miss

Two checks run without a model. The first flags content words in the summary that never occur in the source, and the second flags numbers that do not. A third summary, residents approved the first repairs on Tuesday, joins the two above.

summary novel content words unsupported numbers
faithful paraphrase lawmakers, passed, puts, work, starts none
wrong number road, 21 21
wrong claim none none

The number check is narrow and exact, and it catches the 2121. The word check raises a false alarm on every paraphrase, and on road, a plural that lost its s. The third summary passes both checks, because every word in it appears in the article and it contains no number, yet the article never says that residents approved anything. Catching it needs a model that reads the source and the claim together, which is the entailment test described above, and a person to audit that model on a sample.

Run it. code/worked_examples/summarization.py produces every table in this chapter. --extract ranks the sentences, --rouge scores the four candidates, --faithful runs the two checks, --long builds the hierarchy and --mask compares the two losses.

Run it

When not to fine-tune

The chapter has assumed you are training a model, and often you should not. A general instruction-tuned model summarises well with no training at all, which is Chapter 20’s point, and fine-tuning pays for itself when you need a specific style, a specific length, a specific domain vocabulary or an on-premises model.

When you do fine-tune, Chapter 25 applies unchanged, where LoRA at rank 8 trains four tenths of one per cent of the weights, which is usually enough for a task this close to what the model already does. The order to work in is Chapter 20’s hierarchy. Prompt first, measure, and fine-tune only when you can say what prompting failed to achieve.

Summary

Summarisation has no single right answer, so it is hard to evaluate, and it brings together four problems from Part V: decoding, faithfulness, evaluation and long inputs. Extractive summaries select sentences, for example by a frequency score, and cannot state anything the source did not. Abstractive summaries read well and can hallucinate. The dataset decides the task, so measure how extractive the targets are before choosing a model, and beat a lead baseline. Long inputs meet the quadratic cost of attention, and truncation, sparse attention and hierarchical summarisation each pay a different price. Training masks the loss on padding and uses teacher forcing, which leaves exposure bias, so decoding should be low-entropy. Evaluate by generation, because loss is not the task, and remember that ROUGE rewards overlap instead of faithfulness: a summary with one number changed scored 0.9440.944, above every honest candidate. Cheap checks catch a wrong number and miss a false claim built from the source’s own words. Prompt first and fine-tune only when you can say what prompting failed to achieve.

Key terms

extractive summarisation. selecting sentences from the source.

abstractive summarisation. generating new text that conveys the source.

lead baseline. a summary made of the first few sentences of the source.

faithfulness. the property that every claim in a summary is supported by the source.

exposure bias. the mismatch between training on gold prefixes and generating from the model’s own.

Further reading.

Lin (2004) is ROUGE, and its limitations are best read alongside Zhang et al. (2020). Lewis et al. (2020) introduced the denoising pretraining that transfers so well here. Jurafsky and Martin (2025) cover both extractive and abstractive summarisation with more task detail.

Practice problems

26.1 Bigram share by hand. For the source the council approved the new budget on tuesday after a long debate, compute the share of source bigrams in the summary the council approved a budget. Say whether it is extractive.

26.2 Hierarchy by hand. A transcript is 24,00024{,}000 tokens and the model reads 4,0004{,}000 at a time, writing 400400 tokens per chunk summary. How many levels of summarisation are needed, and how many model calls?

26.3 Compounding faithfulness. If each summarisation step keeps 9595 per cent of the claims faithful, what share of claims in the final summary is faithful after three levels?

26.4 The ROUGE shortcut. A candidate of 1212 words shares 77 unigrams with a reference of 1515 words. Compute ROUGE-1 precision, recall and F1F_1, and check that F1=2o/(c+r)F_1 = 2o/(c + r).

Build and measure

26.5 Measure your dataset. For a summarisation corpus of your choice, compute what fraction of summary bigrams appear verbatim in the source. Compare it against a lead-sentence baseline’s ROUGE. What does the gap tell you about what a trained model would have to learn?

26.6 Rank by frequency. Implement the frequency score of this chapter and pick the two best sentences, breaking ties by position. Run it and the lead-2 baseline over a hundred articles of a corpus you choose, and report the difference in mean ROUGE-1 F1F_1. State when the lead baseline wins.

26.7 Beat the lead baseline. Implement the baseline that returns the first three sentences and score it. Then argue what a model must do to justify its cost, and state the margin you would require.

26.8 The silent truncation. Explain why truncating targets produces a training loss that looks healthy while generation fails. Describe the check you would add to a training script to make the bug loud.

26.9 Exposure bias, concretely. Trace what happens when a decoder generates one wrong token at position three of a twenty-token summary. Explain why teacher forcing gives the model no experience of this, and say which of the three remedies addresses it most directly.

In practice

26.10 Two metrics disagree. Construct a summary that scores well on ROUGE and is unfaithful to its source, and one that is faithful and scores poorly. Then describe an evaluation that separates them.

26.11 Choose the architecture. You must summarise ten-thousand-token legal filings, on-premises, in a fixed house style. Work through the choices in this chapter: extractive or abstractive, encoder-decoder or decoder-only, truncate or sparse or hierarchical, prompt or fine-tune. Justify each, and name the one you are least sure about.

26.12 The cheap checks at scale. Run the number check and the novel-word check over the twenty summaries of the next problem. Count how many unsupported claims each check finds, how many false alarms it raises, and how many claims neither finds.

26.13 Faithfulness check. Take twenty summaries from a model and check each claim against the source by hand. Report the share of unsupported claims, and say how ROUGE scored those summaries.

26.14 Prompt or fine-tune? A team needs summaries in a fixed house style at low latency. Describe the experiment that decides between prompting and fine-tuning, and what result would make you fine-tune.

26.15 Mask the loss. A batch has summaries of 2020 tokens padded to 100100. Estimate what share of an unmasked loss comes from padding, and say what the training curve would look like.

Code for this chapter

Each one reproduces the tables above. Run it in the page, change an input and watch which numbers move.

From Natural Language Processing: From Corpus Statistics to Grounded LLMs, by Ramaseshan Ramachandran.