Ultralytics YOLO27: Join the waitlist.
License YOLO
Back to Ultralytics Glossary

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.

  • 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.

Explore solutions

Computer vision in sports

Computer vision in sports

Discover how Ultralytics YOLO powers sports vision with player and ball tracking, performance analytics, coaching insights, and athlete rehabilitation.
Learn more
Computer vision for aerial imagery

Computer vision for aerial imagery

Turn drone and aerial imagery into real-time insights for agriculture, aquaculture, conservation, and geospatial analysis with Ultralytics YOLO.
Learn more
Computer vision in aerospace

Computer vision in aerospace

Apply computer vision in aerospace with Ultralytics YOLO for aircraft inspection, runway FOD detection, airport ground operations, and composite defect detection.
Learn more
Computer vision in security

Computer vision in security

Protect every site with Ultralytics YOLO models. Vision AI powers perimeter monitoring, threat detection, license-plate recognition, and workplace safety.
Learn more
Computer vision in robotics

Computer vision in robotics

Power smarter machines with Ultralytics YOLO models. Vision AI in robotics drives autonomous navigation, perception, object tracking, and real-time control.
Learn more
Computer vision in logistics

Computer vision in logistics

Streamline logistics with Ultralytics YOLO models. Vision AI enables package inspection, sorting, vehicle tracking, and real-time warehouse safety monitoring.
Learn more
Computer vision in retail

Computer vision in retail

Reimagine retail with Ultralytics YOLO models. Vision AI powers inventory tracking, shelf monitoring, queue management, and smarter customer insights.
Learn more
Computer vision in healthcare

Computer vision in healthcare

Build healthcare solutions with Ultralytics YOLO models. Vision AI in healthcare powers faster medical imaging, smarter diagnostics, and patient monitoring.
Learn more
Computer vision in manufacturing

Computer vision in manufacturing

Optimize manufacturing with Ultralytics YOLO models. Vision AI drives quality control, defect detection, PPE compliance, and assembly line automation.
Learn more
Computer vision in automotive

Computer vision in automotive

Apply computer vision in automotive with Ultralytics YOLO models. Vision AI elevates road safety, driver assistance, and vehicle automation for smarter roads.
Learn more
Computer vision in agriculture

Computer vision in agriculture

Bring vision AI to smart agriculture with Ultralytics YOLO models. Power crop monitoring, livestock tracking, and precision farming for higher, smarter yields.
Learn more

Let's build the future of AI together!

Begin your journey with the future of machine learning