Sub topic 11
Keeping summaries faithful to the source
This chapter assumes you can read basic Python, have sent prompts to an LLM through an API, and know what a token is. It also assumes you have met the single-pass, map-reduce and refine strategies from earlier chapters. Here you learn how summaries drift from their source, how each strategy makes that drift more likely, and how to catch it.
What faithfulness means
A summary is faithful when every claim in it is supported by the source document. A summary can be fluent, well organised and wrong. Fluency is the reason unfaithful summaries are hard to spot: the model writes confident prose whether or not the facts are there.
Faithfulness is a different property from completeness, which asks whether the important points made it in. A summary that says almost nothing is highly faithful and not very useful. You need both, and the next chapter covers how to measure them. This chapter focuses on the first.
Unfaithful content is usually called hallucination. In summarisation it comes in several distinct forms, and each needs a different defence.
| Failure | Example | Typical cause |
|---|---|---|
| Invented detail | The source never mentions a deadline, but the summary gives one | The model fills a gap with a plausible guess |
| Altered fact | "Revenue rose 12%" becomes "rose 15%" | Number copied wrongly or blended with another figure |
| Wrong attribution | A claim made by a critic is credited to the author | Speaker information lost during compression |
| Lost qualifier | "may reduce risk" becomes "reduces risk" | Compression drops hedges |
| Outside knowledge | The summary adds background the document did not contain | The model draws on training data instead of the text |
| Overgeneralisation | One case study becomes "studies show" | Abstraction goes further than the evidence |
Where each strategy introduces errors
Every strategy you have met has its own failure pattern. Knowing it tells you where to place your checks.
- Single pass. The model sees the whole text, so errors are mostly invented details, outside knowledge, and omissions from long-context effects.
- Map-reduce. The reduce step sees only the partial summaries, not the source. Any error in a partial summary is now invisible to the model and gets repeated. The reduce step can also merge facts from different sections that were never connected, such as a figure from one section paired with a name from another.
- Refine. Each rewrite is a chance to distort the running summary. Details introduced early are paraphrased again and again, and qualifiers and numbers wear away. This is sometimes called drift.
- Hierarchical. Every extra level is another copy of a copy. Errors compound with depth, so keep the number of levels small.
The practical rule is that the further a summary is from the original text, the more checking it needs. Summaries of summaries need the most.
Constrain the prompt
The cheapest defence is the prompt. These instructions reduce hallucination without extra calls:
- Restrict the knowledge source. "Use only information in the text. If something is not stated, do not include it." The code examples in this tutorial already do this.
- Give the model an exit. Add "If the text does not say, write 'not stated'." A model with no permitted way to say "unknown" tends to guess.
- Ask for anchors. Request a short verbatim quote for each key point. Quotes can be checked mechanically, as shown below.
- Preserve qualifiers. "Keep hedges such as 'may', 'approximately' and 'according to' and keep who said what."
- Lower the temperature. A temperature of 0 or close to it reduces random variation. It does not remove hallucination.
Here is a prompt that combines these constraints:
FAITHFUL_PROMPT = """Summarise the text below in at most 5 bullet points.
Rules:
- Use only information stated in the text. Do not add background knowledge.
- Keep numbers, names and dates exactly as written.
- Keep qualifiers such as "may", "about" and "according to X".
- End each bullet with a short exact quote from the text in double quotes.
- If the text does not contain enough information, say "not stated".
Text:
"""
def faithful_summary(text, call_llm):
return call_llm(FAITHFUL_PROMPT + text)Prompt constraints lower the error rate but never bring it to zero. Treat them as the first layer and add checks after them.
Check numbers and quotes with code
Some claims can be verified without a model. Numbers and quotations are the easiest cases, and they are also the errors readers care about most.
import re
NUMBER = re.compile(r'\d+(?:,\d{3})*(?:\.\d+)?%?')
def normalise_number(token):
return token.replace(',', '').replace('%', '')
def unsupported_numbers(summary, source):
source_numbers = {normalise_number(m) for m in NUMBER.findall(source)}
return [m for m in NUMBER.findall(summary)
if normalise_number(m) not in source_numbers]
def quotes_not_in_source(summary, source):
def squash(s):
return ' '.join(s.split()).lower()
src = squash(source)
quotes = re.findall(r'"([^"]+)"', summary)
return [q for q in quotes if squash(q) not in src]
source = "Revenue rose 12% to $4.2 million in 2023. The CEO said growth \"may slow next year\"."
summary = '- Revenue rose 15% to $4.2 million in 2023 "may slow next year"\n- Staff grew to 1,200 "will slow sharply"'
print(unsupported_numbers(summary, source))
print(quotes_not_in_source(summary, source))This prints:
['15', '1,200']
['will slow sharply']The checker flags the changed percentage, the invented headcount and the fabricated quote. It has limits you should know about:
- A number that appears in the source but in the wrong place passes. The check proves presence, not correctness.
- Spelled-out numbers ("twelve") and unit conversions ("4,200,000" for "4.2 million") produce false alarms or misses.
- Computed values, such as a total the model added up itself, are flagged even when they are correct. Decide whether your use case allows derived figures. If it does not, flagging them is the right behaviour.
Flagged items are leads for a human or a repair step, not proof of error.
Verify claims with a second model call
Claims that are not numbers or quotes need a semantic check. A common pattern is to split the summary into individual claims and ask a model whether the source supports each one. The verifier works better than the writer because its task is narrower: judge one statement against evidence, rather than compose a whole summary.
def verify_claims(summary, source, call_llm):
results = []
for line in summary.splitlines():
claim = line.strip().lstrip('-* ').strip()
if not claim:
continue
prompt = (
'Decide whether the claim is fully supported by the text.\n'
'Answer with one word: SUPPORTED or UNSUPPORTED.\n'
'Answer UNSUPPORTED if any part of the claim is missing from the text.\n\n'
'Claim: ' + claim + '\n\nText:\n' + source
)
verdict = call_llm(prompt).strip().upper()
results.append((claim, verdict.startswith('SUPPORTED')))
return results
def drop_unsupported(summary, source, call_llm):
checked = verify_claims(summary, source, call_llm)
return '\n'.join('- ' + claim for claim, ok in checked if ok)Three points affect whether this works in practice:
- Verify against the right text. For a long document, the source will not fit in one verifier call. Verify each partial summary against the chunk that produced it, and keep that pairing in your pipeline. Verifying a final map-reduce summary against the whole document usually means retrieving the relevant passages first.
- The verifier can be wrong. It is a model and shares failure modes with the writer. It tends to approve claims that sound reasonable. The instruction "answer UNSUPPORTED if any part is missing" counters this, and it is worth testing on a few known-bad claims before you trust it.
- One claim per line matters. A bullet that bundles three facts can be marked supported when only two are. Ask the writer for short, single-fact bullets.
Repair, not just detect
When checks fail, you have three options.
- Drop the claim. Fast and safe, at the cost of completeness. Good for batch pipelines.
- Regenerate the chunk. Re-run the summary with the failed claims named in the prompt ("Do not state that revenue rose 15%"). Cap retries at two or three to bound cost.
- Escalate to a person. Appropriate when the summary feeds legal, medical or financial decisions.
Placement matters most in map-reduce and hierarchical pipelines. Check the partial summaries against their chunks before the reduce step, because the reducer cannot detect an error it has no source for. A bad claim removed at the map stage never reaches the final summary.
Reduce drift in refine pipelines
Refine summaries carry the most risk of gradual distortion. Several adjustments help:
- Tell the model to keep existing facts unless the new text contradicts them.
- Keep a list of key facts, such as numbers, names and dates, outside the summary, and re-check it against the running summary after each step.
- Run the claim verifier on the final summary against each chunk, and ask only whether any chunk contradicts the claim.
Use extraction to anchor abstraction
Extractive output cannot invent text, because it copies sentences. A useful hybrid is to select the key sentences first, then ask the model to write an abstractive summary from only those sentences. The model has less material to wander from, and each statement can be traced to a sentence. The trade-off is that selection can miss relevant content, and the final text may read less smoothly.
A practical checklist
- Constrain the prompt: source-only, "not stated" allowed, qualifiers preserved.
- Ask for short, single-fact bullets with supporting quotes.
- Run mechanical checks for numbers and quotes.
- Verify remaining claims against the chunk each came from.
- Check at the map stage, not only at the end.
- Drop, regenerate or escalate, with a retry cap.
- Log every flagged claim. The log becomes your test set in the next chapter.
Exercise
A map-reduce pipeline produces a final summary saying "The study of 40 patients showed the drug cures the condition." The source chunk said "In this pilot of 40 patients, the drug may improve symptoms." Name the faithfulness failures, and say which check in this chapter catches each one and at which stage you should run it.
Show answer
There are two failures. "Cures" for "may improve symptoms" is an altered claim, and the lost qualifier "may" is a dropped hedge. The number 40 is correct, so the number check passes. The quote check would only help if the writer had been asked to attach a verbatim quote, which would then not match the claim. The claim verifier catches the distortion, since "cures" is not fully supported by "may improve symptoms". It should run at the map stage, comparing each partial summary with its own chunk, because the reducer never sees the source and would pass the error along. The prompt should also instruct the writer to preserve qualifiers such as "may".