🎉 75% of content is free forever — Unlock Premium from $10/mo →
CW
NEWSLIVESearch All Content
đŸ’ŧ Servicesâ„šī¸ Aboutâœ‰ī¸ ContactView Pricing Plansfrom $10

Summarization: Extractive, Abstractive and Faithfulness

đŸŸĸ Free Lesson

Summarization

Prerequisites

  • !Sentence segmentation and tokenization
  • !Precision and recall as applied to n-gram overlap
  • !How abstractive models generate and why they drift

What You'll Learn

  • 1Choose between extractive and abstractive summarization from the cost of a factual error
  • 2Build an inspectable extractive scorer with position, centrality and redundancy control
  • 3Set a compression budget and translate it into a token plan
  • 4Measure overlap and faithfulness as separate axes instead of one score

Two families, two different ways of being wrong

An extractive system selects sentences from the source and emits them unchanged. It cannot invent a fact, and that is its decisive advantage — but it also cannot compress terminology, merge repeated points, or write the connective tissue that makes a summary readable. An abstractive system generates new sentences conditioned on the source, which produces summaries people actually enjoy reading and which can also state with perfect grammar something the document never said.

The choice follows from your tolerance for fabrication. Legal review, medical notes, financial filings: extraction or heavy grounding, because a fluent wrong sentence in those domains costs more than an awkward right one. Internal digests of meeting notes and marketing blurbs: abstraction, where readability dominates. Many production systems end up hybrid — abstractive over an extracted, deduplicated evidence set — and that design constrains generation to a small set of sentences the model must account for.

PropertyExtractiveAbstractiveHybrid
Factual riskLow: copies onlyHigh: can confabulateMedium, bounded by evidence
ReadabilityChoppy, source wordingFluent, well-formedImproving with care
CompressionLimitedFlexibleFlexible
CostLow, mostly CPUGPU or API per documentBoth
EvaluationROUGE works wellROUGE under-measuresNeeds faithfulness check

An extractive scorer you can inspect

Centrality — how close a sentence is to the document's overall meaning — combined with position and a redundancy penalty gives a baseline that explains itself to reviewers.

python
import math
import re
from collections import Counter


SENT_SPLIT = re.compile(r"(?<=[.!?])\s+(?=[A-Z0-9])")


def tokenize(text: str) -> list[str]:
    return re.findall(r"[a-z0-9']+", text.lower())


def extractive_summary(text: str, ratio: float = 0.25, top_k: int | None = None):
    sentences = [s.strip() for s in SENT_SPLIT.split(text) if s.strip()]
    if not sentences:
        return ""

    docs_tf = Counter(tokenize(text))
    total_tokens = sum(docs_tf.values()) or 1

    # Document centroid in tf-idf space, approximated with sublinear tf.
    def vec(tokens: Counter) -> dict:
        return {t: (1 + math.log(c)) * math.log(total_tokens / (1 + c))
                for t, c in tokens.items()}

    centroid = vec(docs_tf)
    ranked = []
    for i, sent in enumerate(sentences):
        toks = Counter(tokenize(sent))
        v = vec(toks)
        if not v:
            continue
        dot = sum(v[t] * centroid.get(t, 0.0) for t in v)
        norm = math.sqrt(sum(x * x for x in v.values())) or 1.0
        cnorm = math.sqrt(sum(x * x for x in centroid.values())) or 1.0
        centrality = dot / (norm * cnorm)
        position = 1.0 / (1.0 + 0.15 * i)      # lead sentences carry the point
        length_fit = min(1.0, len(toks) / 20.0)
        ranked.append((i, sent, 0.7 * centrality + 0.3 * position, length_fit))

    budget = max(1, int(len(sentences) * ratio)) if top_k is None else top_k
    chosen, chosen_vecs = [], []

    for i, sent, score, _ in sorted(ranked, key=lambda r: -r[2]):
        if len(chosen) >= budget:
            break
        toks = set(tokenize(sent))
        redundant = any(
            len(toks & c) / max(1, len(toks | c)) > 0.6 for c in chosen_vecs
        )
        if redundant:
            continue
        chosen.append((i, sent))
        chosen_vecs.append(toks)

    return " ".join(s for _, s in sorted(chosen))

The redundancy filter is what separates a summary from a highlight reel of the same sentence three times. Without it, near-duplicate paragraphs — typical in meeting notes — crowd out the one line that says something new.

Setting a compression budget

Compression is a product decision expressed in numbers. A 4:1 ratio on a 2,000-word report yields roughly 500 words, about a three-minute read; ask a model for "a short summary" with no number and you get whatever its training distribution considered short, which varies by prompt phrasing and model version.

Translate the budget into a token plan. For extraction, cap sentences until the token count hits the target. For abstractive generation, set max_tokens slightly above the target so the model can finish its sentence rather than being clipped mid-clause, and state the constraint twice in the prompt — once as a word budget and once as a structural instruction such as "three bullets, one line each". Structural constraints are more stable than length adjectives: "brief", "concise" and "tight" produce measurably different outputs from the same model.

💡Budget for the source too

Long inputs change behaviour, not just price. Past the model's comfortable context window, instructions at the bottom of the prompt lose influence over the output. Put the constraints at the end, near where generation starts, and keep the document itself above them.

Measuring overlap without fooling yourself

ROUGE measures n-gram overlap between a candidate and a reference. It is easy to compute, correlates weakly with human judgements of usefulness, and is excellent for regression testing: if your new pipeline drops ROUGE-L by four points, something changed. Implementing it once removes the mystery.

python
import re
from collections import Counter


def _ngrams(tokens: list[str], n: int) -> Counter:
    return Counter(tuple(tokens[i:i + n]) for i in range(len(tokens) - n + 1))


def rouge_n(candidate: str, reference: str, n: int) -> dict:
    cand, ref = _tokens(candidate), _tokens(reference)
    cg, rg = _ngrams(cand, n), _ngrams(ref, n)
    overlap = sum((cg & rg).values())
    return {
        "precision": overlap / max(1, sum(cg.values())),
        "recall": overlap / max(1, sum(rg.values())),
        "f1": _f1(overlap / max(1, sum(cg.values())),
                  overlap / max(1, sum(rg.values()))),
    }


def rouge_l(candidate: str, reference: str) -> dict:
    cand, ref = _tokens(candidate), _tokens(reference)
    m = _lcs_length(cand, ref)
    p, r = m / max(1, len(cand)), m / max(1, len(ref))
    return {"precision": p, "recall": r, "f1": _f1(p, r)}


def _tokens(text: str) -> list[str]:
    return re.findall(r"[a-z0-9']+", text.lower())


def _f1(p: float, r: float) -> float:
    return 2 * p * r / (p + r) if p + r else 0.0


def _lcs_length(a: list[str], b: list[str]) -> int:
    prev = [0] * (len(b) + 1)
    for x in a:
        cur = [0]
        for j, y in enumerate(b, start=1):
            cur.append(prev[j - 1] + 1 if x == y else max(prev[j], cur[j - 1]))
        prev = cur
    return prev[-1]


report = rouge_l(
    "the quarterly report highlights revenue growth and rising costs",
    "revenue grew this quarter while costs also increased",
)
print({k: round(v, 3) for k, v in report.items()})

The trap is treating a high ROUGE score as proof of a good summary. A summary can copy the reference's phrasing and misstate the causal claim, and ROUGE will not notice because it counts tokens, not relations. Use ROUGE for regression, then measure faithfulness separately.

Faithfulness is the metric that protects readers

Faithfulness asks a narrower question than quality: is every claim in the summary supported by the source? The cheapest practical checks are span-level. Split the summary into sentences, retrieve the source sentences most similar to each, and flag any summary sentence whose best overlap falls below a threshold — that sentence has no obvious support. A stronger version runs an entailment model with the retrieved source as premise and the summary sentence as hypothesis, labelling each sentence supported, contradicted, or unverifiable.

Contradictions are the failure worth prioritising. Missing information makes a summary thin; reversed information makes it dangerous, and abstractive models produce reversals under compression pressure — when asked for half the length, they drop hedging words first, turning "may increase costs by up to 5%" into "costs will increase 5%". Keep qualifiers in the budget: instruct the model that numbers, negations and hedges must survive compression unchanged, then verify programmatically that every number in the summary appears in the source.

Long documents: map, reduce, and the order that matters

Whole-book inputs break the pipeline long before the context window does. The reliable pattern is hierarchical: chunk the document into overlapping sections, summarize each chunk (map), then summarize the chunk summaries (reduce), keeping an evidence table so each reduced claim can be traced to its section. Overlap matters — facts introduced at the end of one chunk and paid off in the next are exactly what a hard split loses — so 10–15% overlap with a sentence boundary is a reasonable default.

Streaming summarization, where the model updates its digest as text arrives, has a different failure: early commitments harden. A summary written after the first two paragraphs will frame everything that follows, so restart or revise the digest at section boundaries rather than appending forever. Whichever strategy you choose, keep the source-aligned evidence for every sentence; without it, review becomes re-reading the original document, and the summary has saved nothing.

Structure matters as much as sentence choice

A pile of individually good sentences still makes a poor summary if it opens with a caveat and buries the decision. Readers scan for the same three things in the same order: what happened, why it matters, and what happens next. Ordering the summary to answer those questions in sequence changes perceived usefulness far more than squeezing in one more detail.

Several structural habits do most of the work. Lead with the conclusion when the source has one, and reserve the first sentence for it even if that sentence appears late in the original. Group related points instead of preserving source order, because documents are written for a narrative while summaries are read for retrieval. State quantities with their scope attached — "revenue rose 12%" without the period or the comparison base is a number waiting to be misquoted. And cut meta-text: phrases such as "this report discusses" consume the budget without conveying content, and models reproduce them readily because they are common in training data.

For multi-document summaries, explicitly reconcile conflicts rather than averaging them. When two sources disagree, name the disagreement in one line; silently blending them produces a claim neither source supports.

Common Mistakes

Optimizing ROUGE and calling it quality

Fix: Keep ROUGE as a regression signal and add a span-level faithfulness check for claims and numbers

Letting abstractive models compress numbers and hedges

Fix: Require numerals to match the source exactly and verify programmatically before publishing

Summarizing without a stated compression budget

Fix: Fix a target ratio or bullet count and set max_tokens slightly above it so text is not clipped

Splitting long documents at fixed token counts

Fix: Chunk on sentence or section boundaries with 10–15% overlap to preserve cross-chunk facts

Best Practices

  • Start extractive whenever factual risk outweighs readability, and graduate to abstraction with evidence constraints
  • Deduplicate candidate sentences so repeated points do not crowd out novel ones
  • Trace every summary sentence back to a source span and keep that mapping for review
  • Prefer structural length instructions over adjectives like brief or concise
  • Evaluate on your own documents: ROUGE on news articles says little about legal or support text

Key Takeaways

  • Extractive summarization cannot invent facts; abstractive summarization can read better and confabulate — pick by the cost of a wrong sentence
  • Centrality plus position plus a redundancy penalty is a transparent, effective extractive baseline
  • Compression must be a stated budget in tokens or structure, not an adjective
  • ROUGE measures overlap, not truth: use it for regression and pair it with span-level faithfulness checks
  • Long documents need chunk overlap, evidence tracing, and section-boundary revision rather than endless appending
CW

ChatWhole Learn Editorial Team

Written by experienced data scientists, software engineers, and educators. All content is reviewed by industry professionals to ensure accuracy and relevance.

Last reviewed: 2026-10-12

—
☆☆☆☆☆
0 ratings

Rate & Feedback

Need Expert Generative AI Help?

Get personalized tutoring, project support, or professional consulting.

Advertisement