Text Summarization
A summary keeps the facts and drops the filler. Some systems copy the best sentences word for word while others write new ones, and each choice fails in its own way.
Why Does This Exist?
Nobody has time to read everything. A support team faces a 40-message thread, a lawyer faces a 60-page contract, and both need the facts in under a minute. Reading capacity is fixed while text keeps growing, so the only way out is a shorter version that keeps what matters.
Summarization automates that shortening. It takes a long input and returns a short output that preserves the key facts while discarding repetition and filler. The input can be thousands of words; the output is usually a few sentences.
This page covers the two classical strategies and how to score them. The neural machinery that writes fluent summaries is the reader-writer shape in sequence to sequence, and its closest cousin task is machine translation, which converts between languages instead of between lengths.
Think of It Like This
Packing a weekend bag from a full closet
Your closet holds forty items and the airline allows one small bag. Two packing styles both work. The first lifts three outfits straight off their hangers, tags still on, and drops them in the bag unchanged. The second studies the whole closet, then buys one new versatile outfit that covers the same occasions in fewer pieces.
The first is extractive: copied sentences, original wording, zero invention. The second is abstractive: new sentences that compress harder but depend on the packer's judgment.
Where it stops: clothes never invent a fourth outfit that was in neither the closet nor the shop. Abstractive models do exactly that, generating names and numbers with no source. The bag either holds what was there or it lies about what was there, and only one of the two styles can lie.
How It Actually Works
The two strategies differ in one decision: whether the output may contain words the input never had.
Copying the best sentences
Extractive systems score every sentence and keep the top few. A simple scorer counts word frequencies across the document, ignoring filler, then rates each sentence by the sum of its members frequencies divided by its length. Frequent content words vote their sentences up; long rambling sentences get divided back down.
Worked example
Take this four-sentence report:
S1: The rover landed in the dusty crater at dawn. S2: Engineers cheered as the first images arrived. S3: The rover will drill rock samples for two years. S4: Dusty storms may delay dusty driving near the crater.
After removing filler words, dusty appears 3 times, rover and crater 2 each, and every other content word once. Score each sentence as frequency sum over token count, with filler tokens scoring 0:
S4 sums to 13 over 9 tokens, giving 13 / 9 which is about 1.44. S1 sums to 10 over 9 tokens, giving 10 / 9 which is about 1.11. S2 and S3 land at 0.86 and 0.89. The top two are S4 and S1, so the extractive summary is those two sentences copied exactly, in their original order.
How good is that? Score it with ROUGE-1, the overlap of single words against a human reference. Reference: Dusty storms delayed driving near the crater, with 7 single words. The machine shares dusty, storms, driving, near, the and crater, which is 6 of 7, so recall is 6 / 7 which is about 0.86. Note the miss: delayed versus delay. Without reducing both to one base form, an exact-match metric counts a hit as a miss.
Writing new sentences
Abstractive systems read the whole document into an internal representation and then generate fresh text from it, the same reader-writer shape as translation. Our report might become: a dust storm near the crater may delay the driving program. Every word choice is new, the compression is tighter than copying, and nothing stops the writer from adding a fact that was never there. That last property is the whole trade-off of the next section.
Code
The point is the ranking: a few lines of counting reproduce the hand-traced scores and name the same two winners.
import refrom collections import Counter
def score_sentences(doc: str) -> list[tuple[float, str]]: sents = [s.strip() for s in doc.split(".") if s.strip()] freq = Counter(w for w in re.findall(r"[a-z]+", doc.lower()) if w not in {"the", "a", "is", "and", "of", "to", "in", "on", "for"}) out = [] for s in sents: toks = re.findall(r"[a-z]+", s.lower()) out.append((sum(freq[t] for t in toks) / max(len(toks), 1), s)) return sorted(out, reverse=True)
doc = ("The rover landed in the dusty crater at dawn. " "Engineers cheered as the first images arrived. " "The rover will drill rock samples for two years. " "Dusty storms may delay dusty driving near the crater.")
for score, sent in score_sentences(doc)[:2]: print(f"{score:.2f} {sent}")# -> 1.44 Dusty storms may delay dusty driving near the crater# -> 1.11 The rover landed in the dusty crater at dawnThe printed pair matches the hand computation, so the scorer and the arithmetic check each other.
Watch Out For
A fluent summary that invents facts
Symptom: the abstractive summary reads beautifully and states a launch date, a dose or a revenue figure that appears nowhere in the source. Fluency and truth come from different machinery, so a smooth sentence is no evidence for a true one.
Fix: match the strategy to the stakes. Copy sentences for medical, legal and financial text where an invented number is a disaster. If you generate, verify entities and numbers against the source mechanically before anyone reads the result.
A copied sentence that points at nothing
Symptom: the extractive summary reads He agreed to the terms as its opening line, with no earlier sentence naming who he is. Sentence scores ignore context, so a high-scoring sentence can depend on a low-scoring neighbor it left behind.
Fix: resolve references before cutting. Either carry the sentence that introduces each pronoun along with the one that uses it, or run a coreference pass first and skip sentences whose subjects live elsewhere.
The Quick Version
- Summarization compresses long documents into short texts that keep the key facts.
- Extractive methods score sentences and copy the winners exactly, so they never invent wording.
- Abstractive methods generate new sentences from an internal representation, compressing harder at the cost of possible hallucination.
- ROUGE-1 scores a summary by single-word overlap with a human reference, and exact matching punishes unstemmed variants.
- Copying suits high-stakes factual text, while generating suits fluency-first settings with verification after.