By Sagar Shankaran, Founder of CallSphere
Abstractive text summarization: compare extractive and abstractive summarization methods for AI agents, learn to control summary length and quality, and implement key point extraction pipelines in Python.
Key takeaways
AI agents frequently work with documents, conversation histories, and knowledge bases that exceed context window limits. Summarization compresses information while preserving the key points an agent needs to make decisions. A customer support agent summarizing a 50-message conversation thread, a research agent condensing a 20-page report, or a monitoring agent digesting hundreds of log entries — all rely on summarization as a core capability.
The two fundamental approaches are extractive summarization (selecting the most important sentences verbatim) and abstractive summarization (generating new sentences that capture the meaning). Each has distinct strengths for different agent use cases.
Extractive methods score each sentence in the source text and select the top-scoring ones. They never hallucinate because every word in the summary exists in the original. This makes them ideal for agents that need factual reliability.
flowchart TD
Q{"What matters most<br/>for your team?"}
DIM1["Time to first<br/>production deploy"]
DIM2["Total cost of<br/>ownership at scale"]
DIM3["Debuggability and<br/>observability"]
DIM4["Ecosystem and<br/>community support"]
PICK{Score the<br/>four axes}
A(["Pick<br/>Text Summarization<br/>Techniques for AI…"])
B(["Pick<br/>Abstractive Methods"])
Q --> DIM1 --> PICK
Q --> DIM2 --> PICK
Q --> DIM3 --> PICK
Q --> DIM4 --> PICK
PICK -->|Speed and ecosystem| A
PICK -->|Control and TCO| B
style Q fill:#4f46e5,stroke:#4338ca,color:#fff
style PICK fill:#f59e0b,stroke:#d97706,color:#1f2937
style A fill:#0ea5e9,stroke:#0369a1,color:#fff
style B fill:#059669,stroke:#047857,color:#fff
from sklearn.feature_extraction.text import TfidfVectorizer
import numpy as np
def extractive_summary(text: str, num_sentences: int = 3) -> str:
"""Select the most informative sentences using TF-IDF scoring."""
sentences = text.split(". ")
if len(sentences) <= num_sentences:
return text
vectorizer = TfidfVectorizer(stop_words="english")
tfidf_matrix = vectorizer.fit_transform(sentences)
# Score each sentence by sum of its TF-IDF values
scores = np.array(tfidf_matrix.sum(axis=1)).flatten()
# Get indices of top sentences, preserving original order
top_indices = sorted(
np.argsort(scores)[-num_sentences:],
)
summary = ". ".join(sentences[i] for i in top_indices)
return summary + "."
document = """Machine learning models require training data to learn patterns.
The quality of training data directly impacts model performance.
Data preprocessing includes cleaning, normalization, and feature engineering.
Feature selection reduces dimensionality and improves training speed.
Cross-validation helps estimate how well a model generalizes to unseen data.
Hyperparameter tuning optimizes model configuration for best results.
Ensemble methods combine multiple models to reduce variance and bias."""
print(extractive_summary(document, num_sentences=3))
Abstractive models generate entirely new text, producing more natural and concise summaries. They can rephrase, merge concepts, and adjust the level of detail.
Hear it before you finish reading
Talk to a live CallSphere AI voice agent in your browser — 60 seconds, no signup.
from transformers import pipeline
summarizer = pipeline(
"summarization",
model="facebook/bart-large-cnn",
)
def abstractive_summary(
text: str,
max_length: int = 130,
min_length: int = 30,
) -> str:
result = summarizer(
text,
max_length=max_length,
min_length=min_length,
do_sample=False,
)
return result[0]["summary_text"]
article = """The European Union announced new regulations for artificial
intelligence systems on Wednesday. The AI Act categorizes AI applications
by risk level, from minimal risk to unacceptable risk. High-risk systems
used in critical infrastructure, education, and law enforcement will face
strict requirements including human oversight, transparency documentation,
and regular audits. Companies that violate the regulations could face
fines of up to 35 million euros or 7 percent of global revenue."""
print(abstractive_summary(article))
Agents often need summaries of specific lengths — a one-line preview for a notification, a paragraph for a dashboard, or a page for a report. Here is a utility that handles multiple formats.
from enum import Enum
class SummaryLength(Enum):
HEADLINE = "headline" # ~10 words
SHORT = "short" # ~30 words
MEDIUM = "medium" # ~80 words
DETAILED = "detailed" # ~150 words
LENGTH_CONFIG = {
SummaryLength.HEADLINE: {"max_length": 20, "min_length": 5},
SummaryLength.SHORT: {"max_length": 60, "min_length": 20},
SummaryLength.MEDIUM: {"max_length": 150, "min_length": 60},
SummaryLength.DETAILED: {"max_length": 300, "min_length": 100},
}
def summarize(text: str, length: SummaryLength) -> str:
config = LENGTH_CONFIG[length]
result = summarizer(
text,
max_length=config["max_length"],
min_length=config["min_length"],
do_sample=False,
)
return result[0]["summary_text"]
Sometimes an agent does not need a flowing summary but a list of discrete key points. This hybrid approach extracts and then reformulates.
import openai
def extract_key_points(text: str, max_points: int = 5) -> list[str]:
"""Extract key points from text using an LLM."""
response = openai.chat.completions.create(
model="gpt-4o-mini",
messages=[{
"role": "user",
"content": f"""Extract up to {max_points} key points from this text.
Return each point on a new line, prefixed with a dash.
Be concise — each point should be one sentence.
Text: {text}""",
}],
temperature=0,
)
lines = response.choices[0].message.content.strip().split("\n")
return [line.lstrip("- ").strip() for line in lines if line.strip()]
Agents that summarize autonomously need quality guardrails. The ROUGE metric family measures overlap between generated and reference summaries.
from rouge_score import rouge_scorer
def evaluate_summary(generated: str, reference: str) -> dict:
"""Compute ROUGE scores between generated and reference summaries."""
scorer = rouge_scorer.RougeScorer(
["rouge1", "rouge2", "rougeL"],
use_stemmer=True,
)
scores = scorer.score(reference, generated)
return {
metric: {
"precision": round(score.precision, 3),
"recall": round(score.recall, 3),
"f1": round(score.fmeasure, 3),
}
for metric, score in scores.items()
}
reference = "The EU introduced risk-based AI regulations with fines."
generated = "New EU rules classify AI by risk level, with penalties up to 35M euros."
print(evaluate_summary(generated, reference))
ROUGE-1 measures unigram overlap, ROUGE-2 measures bigram overlap, and ROUGE-L measures the longest common subsequence. For agent summarization, ROUGE-L above 0.4 typically indicates adequate quality for downstream decision making.
Use extractive summarization when factual accuracy is paramount and hallucination is unacceptable — legal documents, medical records, or financial reports. Use abstractive summarization when you need concise, natural-sounding text and the source material is long or repetitive. Many production systems use a hybrid approach: extractive selection first to narrow the source text, then abstractive rewriting for the final summary.
Still reading? Stop comparing — try CallSphere live.
CallSphere ships complete AI voice agents per industry — 14 tools for healthcare, 10 agents for real estate, 4 specialists for salons. See how it actually handles a call before you book a demo.
Split the document into chunks that fit within the model's maximum input length, summarize each chunk independently, then summarize the intermediate summaries. This is called hierarchical or recursive summarization. For very long documents, use a sliding window with overlap to avoid losing information at chunk boundaries.
Compare named entities and numerical values in the summary against the source text. If the summary mentions a person, date, or number not present in the original, flag it as a potential hallucination. You can also use NLI (Natural Language Inference) models to check whether each summary sentence is entailed by the source document.
#TextSummarization #NLP #Extractive #Abstractive #AIAgents #Python #AgenticAI #LearnAI #AIEngineering
This guide is written for engineers and operators evaluating abstractive text summarization in real production systems. Abstractive text summarization sits alongside attention mechanisms, encoder decoder model, extractive text summarization, input text, original text in the daily work of teams shipping production AI. The notes below give a plain-language reference for terms used throughout the article.
For teams that want to ship abstractive text summarization in voice and chat agents this quarter, CallSphere runs 37 agents and 90+ function tools across 6 verticals on a single dashboard. Start a 7-day free pilot, see live demo agents, or compare tiers on /pricing.

Written by
Sagar Shankaran· Founder, CallSphere
LinkedInSagar Shankaran is the founder of CallSphere, where he builds production AI voice and chat agents deployed across healthcare, hospitality, real estate, and home services. He writes about agentic AI, LLM engineering, and shipping voice agents that handle real calls in production.
See how AI voice agents work for your industry. Live demo available -- no signup required.
A founder's guide to the personal AI assistant market: best AI assistant apps, business-grade options, and how CallSphere's voice agent fits in.
A founder's guide to free AI agents, low-code AI agent builders, and how to know when you should pay for a real platform like CallSphere.
Graphiti is the open-source temporal knowledge graph for AI agents in 2026. Learn how bi-temporal memory beats vector RAG for voice agents and long-running LLMs.
Chatbot app vs ChatGPT in 2026: a founder's clear take on the difference, when to use which, and how a real AI chatbot app development works.
How we built a fault-tolerant HVAC emergency triage and tech-dispatch platform on Kubernetes — three-tier CQRS, 11 micro-agents on the OpenAI Agents SDK + LangGraph, NATS JetStream, DTMF/SMS/WebSocket acceptance, circuit breakers, and an evaluation pipeline that catches regressions before they wake a tech at 3 AM.
Head-to-head: OpenAI Frontier and Anthropic's managed agent stack — strengths, fit, and what each means for enterprise AI voice and chat deployment.
© 2026 CallSphere Inc. All rights reserved.
Made within San Francisco
Watch how CallSphere handles real customer calls, schedules appointments, and processes payments — live.
Try Live DemoBook a DemoCalculate Your ROI