Text Summarization
Text summarization condenses a document into a shorter text that keeps its key points. Covers extractive and abstractive methods, ROUGE, and faithfulness.
Text summarization is the natural language processing (NLP) task of condensing a document into a shorter text that keeps its most important information. The two main approaches are extractive summarization, which selects the most important sentences from the source, and abstractive summarization, which writes new sentences the way a person would. A summary can cover one document or many, and it can be generic or focused on a question, such as "What did the contract say about termination?" Email clients, meeting tools, news apps, search engines, and large language model (LLM) assistants all generate summaries.
Extractive Summarization#
Hans Peter Luhn of IBM built one of the first automatic summarizers in 1958: it scored each sentence by the frequent, meaningful words it contained and returned the top sentences as an abstract. H. P. Edmundson added cue words, title words, and sentence position in 1969, and graph methods followed in 2004. TextRank and LexRank build a graph whose nodes are sentences and whose edges are similarities, then select the most central sentences, the ones most similar to the rest of the document. Sentence embeddings make the centrality version a few lines long:
from sentence_transformers import SentenceTransformer
sentences = [
"The James Webb Space Telescope launched on 25 December 2021 on an Ariane 5 rocket from French Guiana.",
"Webb observes the universe in infrared light, which passes through the dust that hides young stars.",
"Its 6.5-meter primary mirror is built from 18 gold-coated hexagonal segments.",
"A five-layer sunshield the size of a tennis court keeps the mirror and instruments cold.",
"The telescope orbits the Sun about 1.5 million kilometers from Earth, near the second Lagrange point.",
"NASA published the first full-color science images from Webb in July 2022.",
]
model = SentenceTransformer("sentence-transformers/all-MiniLM-L6-v2")
# Score each sentence by its average similarity to every sentence (its centrality)
embeddings = model.encode(sentences)
centrality = model.similarity(embeddings, embeddings).mean(dim=1)
# Keep the two most central sentences, in their original order
top = sorted(centrality.argsort(descending=True)[:2].tolist())
print(" ".join(sentences[i] for i in top))The summary keeps the launch sentence and the orbit sentence. Every word of an extractive summary comes from the source, so the summary cannot state anything the document does not, and it keeps whatever the chosen sentences contain, including details a reader may not need and pronouns such as the "Its" that opens the mirror sentence, which would point back to a sentence left out.
Abstractive Summarization#
Abstractive models are sequence-to-sequence models: an encoder reads the document and a decoder writes the summary one token at a time. Alexander Rush and colleagues trained one with an attention mechanism to write news headlines in 2015, and Abigail See and colleagues' pointer-generator network (2017) let the decoder copy words such as names and numbers directly from the source and penalized it for repeating itself. Pretrained transformers then raised quality sharply: Facebook's BART (2019) learned by reconstructing corrupted text, and Google's PEGASUS (2020) learned by regenerating whole sentences removed from a document, a self-supervised pretraining task close to summarization itself.
LLMs summarize from an instruction and can follow requests for length, audience, and format. A document longer than the context window is split into chunks, each chunk is summarized, and the partial summaries are merged in a second pass, a pattern called map-reduce. Summarization also extends beyond text: video understanding models describe the events in a clip, and image captioning condenses a picture into a sentence. In Ultralytics Platform Agents, an LLM block can condense an image and its upstream YOLO26 detections into a short written summary, and a connected Slack block posts that summary to a channel through its {output} placeholder.
Datasets and Evaluation#
Most models learn from training data made of article and summary pairs: CNN/Daily Mail pairs news stories with their bullet-point highlights, and XSum (2018) pairs BBC articles with single-sentence summaries that rarely reuse whole sentences, which rewards abstraction. ROUGE, introduced by Chin-Yew Lin in 2004, scores a summary by its overlapping words and word sequences with human-written reference summaries; ROUGE-1 counts single words, ROUGE-2 word pairs, and ROUGE-L the longest common subsequence. Overlap scores miss errors of fact, and Joshua Maynez and colleagues found in 2020 that human annotators saw substantial amounts of hallucinated content in the summaries of every abstractive model they studied on XSum. They also found that textual entailment measures, which check whether the source implies the summary, track faithfulness better than ROUGE and other standard metrics.
Summarization vs. Related Terms#
- Text generation: Produces any text from a prompt. Summarization is text generation constrained to the content of a source document.
- Machine translation: Uses the same encoder-decoder architecture to carry the full content of a text into another language.
- Sentiment analysis: Classifies the opinion a text expresses, and opinion summarization combines the two tasks by condensing many reviews into their main points of praise and complaint.
- Retrieval-augmented generation (RAG): Retrieves passages relevant to a question and generates an answer from them, which makes it a form of query-focused summarization over many documents.










