Context Engineering / Information Processing

Summarization

Intermediate [3/5]
Text summarization Content condensation Abstract generation

Definition

Summarization is the task of condensing longer text into shorter versions while preserving key information and meaning. LLMs excel at both extractive (selecting key sentences) and abstractive (generating new summary text) summarization.

Effective summarization is crucial for managing context windows, creating digests, and helping users quickly understand large documents.

Key Concepts

  • Extractive: Selecting and combining existing sentences
  • Abstractive: Generating new text that captures meaning
  • Compression ratio: Original length vs summary length
  • Faithfulness: Summary accuracy to source material

Examples

Types
Extractive vs Abstractive Summarization
ORIGINAL TEXT: "The company announced quarterly revenue of $5.2 billion, exceeding analyst expectations of $4.8 billion. The CEO attributed the strong performance to increased cloud services adoption, which grew 45% year-over-year. However, hardware sales declined 12% due to supply chain challenges. The company plans to invest $2 billion in AI research over the next two years. Stock price rose 8% after hours." EXTRACTIVE SUMMARY: (Selects key sentences verbatim) "The company announced quarterly revenue of $5.2 billion, exceeding analyst expectations. Cloud services grew 45% year-over-year. Stock price rose 8% after hours." ABSTRACTIVE SUMMARY: (Generates new condensed text) "Revenue beat expectations at $5.2B, driven by 45% cloud growth despite 12% hardware decline. The company will invest $2B in AI, boosting stock 8%." COMPARISON: ┌─────────────────┬────────────┬─────────────┐ │ Aspect │ Extractive │ Abstractive │ ├─────────────────┼────────────┼─────────────┤ │ Faithfulness │ High │ Medium* │ │ Fluency │ Medium │ High │ │ Compression │ Lower │ Higher │ │ Hallucination │ None │ Possible │ │ Coherence │ Variable │ Good │ └─────────────────┴────────────┴─────────────┘ * Abstractive can introduce errors when rephrasing
Prompts
Summarization Prompt Patterns
SUMMARIZATION PROMPT PATTERNS: 1. BASIC SUMMARY: "Summarize the following text in 2-3 sentences: {text}" 2. LENGTH-CONTROLLED: "Summarize in exactly 50 words: {text}" 3. BULLET POINT SUMMARY: "Summarize the key points as a bulleted list: {text}" 4. AUDIENCE-SPECIFIC: "Summarize for a non-technical executive: {technical_text}" 5. FOCUS-DIRECTED: "Summarize, focusing specifically on financial implications: {text}" 6. HIERARCHICAL SUMMARY: "Provide: - One-sentence summary - Three key points - Detailed 100-word summary {text}" 7. FAITHFUL SUMMARY (reduces hallucination): "Summarize the following text. Only include information explicitly stated in the text. Do not add inferences or external knowledge. {text}" CONTEXT WINDOW MANAGEMENT: For very long documents, use recursive summarization: Document (50k tokens) ↓ Split into chunks [Chunk 1] [Chunk 2] [Chunk 3] [Chunk 4] ↓ Summarize each [Sum 1] [Sum 2] [Sum 3] [Sum 4] ↓ Combine summaries [Combined partial summaries] ↓ Final summarization [Final summary]

Interactive Exercise

Write a Summary Prompt

You need to summarize a 10-page research paper for a busy executive who only has 1 minute to read. Write the prompt you would use.

Consider: length constraints, audience, focus areas, format.

Pro Tips
  • Specify length explicitly (words, sentences, or bullets)
  • Direct focus to what matters for the use case
  • For high-stakes summaries, ask for only explicit information
  • Use Chain of Density for information-rich summaries

Related Terms