Skip to content
AI360XpertBeta

Text Summarization

Shrink a long document to its core claims. Either copy the best sentences word for word or write new ones that compress the same meaning.

Eight source sentences compress to two summaries, two lines copied verbatim and two lines written new, while ROUGE counts the overlapping words.
Eight source sentences compress to two summaries, two lines copied verbatim and two lines written new, while ROUGE counts the overlapping words.

Why Does This Exist?

Reports, papers, tickets and chat logs pile up faster than you can read them. Skim and you miss the one claim that matters. Read everything and the day is gone. You need a shorter version that keeps the facts and drops the filler.

Early systems cheated with position. They returned the first two sentences, which works for news where the lead carries the story and fails for papers where the result sits at the end. Real summarization scores content instead of position, then either copies or rewrites.

This page covers both strategies and how you score them. The generation engine behind rewrites lives in language models, the closest sequence task in machine translation, and the other long document reader in question answering.

The one idea you need first

A summary is judged against a human reference by word overlap. ROUGE-1 counts shared single words: recall asks how much of the reference you covered, precision asks how much of what you wrote was on target. That pair is the whole scoreboard here.

Think of It Like This

The highlighter and the notepad

You face a dense chapter the night before an exam. With a highlighter you mark two sentences that carry the weight and reread only those. Fast, faithful, but choppy out of context.

With a notepad you close the book and rewrite the core in your own two lines. It reads smooth and compresses tighter, but you might misremember a number or flip a name. That is the full trade. Copy cannot invent yet reads rough. Rewrite reads clean yet can invent.

Where it stops: both tools assume you knew what mattered. If you highlighted the wrong lines or misread the chapter, the short version is confidently wrong either way.

How It Actually Works

Extractive scoring and picking

Extractive systems rank every sentence, then lift the top KK. Here KK is the budget of sentences you keep, often 2 or 3. Each sentence becomes a vector, by counts or by embeddings, and centrality decides: a sentence that shares words or meaning with many others scores high. A diversity pass then drops near duplicates, so the second pick adds news instead of echoing the first.

Take eight sentences. Sentences 2 and 5 score top, the rest trail. Keep those two verbatim. Eight in, two out, zero new words. Those are the counts in the diagram above.

Abstractive reading and rewriting

Abstractive systems read the whole document into a rich representation, then generate fresh words one at a time while attending back to the source. Training pairs long documents with human shorts, and the loss penalizes the next word whenever it strays from the human choice. At test time the model compresses several source lines into one new line.

Same eight sentences. The model writes two new lines that fuse the actors, the numbers and the outcome. Same budget as the extractive pair, new wording, tighter fit, and a small chance of a flipped fact.

Worked ROUGE

Reference summary has 10 words. Your system writes 8 words. They share 6 words.

Recall is overlap over reference: 6/10=0.6006 / 10 = 0.600. Precision is overlap over what you wrote: 6/8=0.7506 / 8 = 0.750. Here recall asks how much truth you covered and precision asks how clean your wording stayed.

F1 blends them: 2×0.600×0.750/(0.600+0.750)=0.900/1.350≈0.6672 \times 0.600 \times 0.750 / (0.600 + 0.750) = 0.900 / 1.350 \approx 0.667. That 0.667 is the number the diagram reports beside the two summaries.

The trade is plain. Copying never invents yet stays choppy and long. Rewriting reads tight yet can hallucinate. Score both with ROUGE, then read the abstractive one yourself when facts matter.

Code

ROUGE-1 for the worked case, from word sets so the 0.600, 0.750 and 0.667 can be checked.

def rouge1(reference: list[str], generated: list[str]) -> dict[str, float]:    ref_set: set[str] = set(reference)    gen_set: set[str] = set(generated)    overlap: int = len(ref_set & gen_set)  # shared words    recall: float = overlap / len(ref_set)    precision: float = overlap / len(gen_set)    f1: float = 2 * recall * precision / (recall + precision)    return {"recall": recall, "precision": precision, "f1": f1}

ref: list[str] = ["jwst", "infrared", "telescope", "stars", "galaxies", "space", "large", "sensitive", "first", "light"]gen: list[str] = ["jwst", "telescope", "infrared", "space", "stars", "large", "new", "images"]print(rouge1(ref, gen))  # -> {'recall': 0.6, 'precision': 0.75, 'f1': 0.6666666666666666}

Six shared words from ten reference words and eight written words. Recall 0.6, precision 0.75, F1 about 0.667.

Watch Out For

Fluent rewrites that invent facts

Symptom: the summary reads clean, names the right actors, then flips a number or assigns the drop to the wrong quarter. Grammar never warns you because the model optimizes for likely words, not true ones.

Fix: copy when precision matters, as in medical or legal text. If you must rewrite, force citations to source spans and check numbers as their own slice before you ship.

Long inputs cut off silently

Symptom: a fifty page file returns a summary of page one only. The model read its first 1024 tokens and dropped the rest without an error, so your evaluation never saw the missing pages.

Fix: chunk the document, summarize each chunk, then summarize the chunk summaries. Track coverage per chunk so no section vanishes quietly.

The Quick Version

  • Text summarization compresses long documents by copying key sentences or writing new ones.
  • Extractive ranks sentences and lifts the top K verbatim, as in sentences 2 and 5 from eight.
  • Abstractive reads the document and generates fresh words, tighter yet able to invent facts.
  • ROUGE-1 scores word overlap between your summary and a human reference.
  • Worked case: 6 shared words from 10 reference and 8 written give recall 0.6, precision 0.75 and F1 0.667.
  • Copy for precision critical text, chunk long inputs, and always read abstractive numbers yourself.