Sub topic 1
Decide what the summary is for
A summary is a lossy copy of a document. Every summary drops something, so the first design decision is what to keep. This chapter shows how to fix three things before you write any prompt: the purpose, the audience, and the length. Later chapters cover the mechanics of getting long documents through a model. Those mechanics only work well if you know what a good result looks like.
Prerequisites
This chapter assumes you have:
- Basic Python, enough to read short functions and dictionaries.
- Experience sending prompts to an LLM through an API or a chat interface.
- A rough idea of what tokens are, meaning the pieces of text a model reads and writes.
You do not need to know about chunking or context windows yet. Those come in later chapters.
Why "summarise this" is underspecified
Suppose you give a model a 40-page quarterly report and write "Summarise this." The model must guess:
- Which facts matter. Revenue, risks, staffing changes, and legal notes all appear in the report.
- Who will read the result. A board member and a support engineer need different things.
- How long the result should be. One sentence, a paragraph, or a page.
- What form it should take. Prose, bullets, or a table.
The model will make a plausible guess for each. The output will look like a summary, and it may still be useless for your task. If you run the same prompt over a thousand documents, the guesses also vary from one document to the next, which makes the results inconsistent.
You can remove the guesswork by answering three questions in advance.
Purpose: what decision or action follows?
Purpose is the job the summary does for its reader. The most useful way to state it is as the action the reader takes after reading. Compare these:
| Purpose | What the summary must keep | What it can drop |
|---|---|---|
| Decide whether to read the full document | The topic, the main claim, and the document type | Methods, examples, detail |
| Brief someone before a meeting | Decisions needed, deadlines, owners, open questions | Background the audience already knows |
| Replace the document in a search index | Key terms, named entities, and the main subject | Tone, narrative order |
| Audit or compliance review | Exact figures, obligations, dates, exceptions | Anything that is not a verifiable statement |
| Catch up on a long discussion | Outcomes and who committed to what | The back-and-forth that led there |
Notice that the same source can produce very different correct summaries. A summary that is excellent for a meeting brief can fail an audit, because the audit needs exact figures and the brief rounded them.
A useful test is to ask: what mistake would be costly? If a missed deadline is costly, deadlines are mandatory content. If a wrong number is costly, you may want exact quotes of numbers rather than paraphrases. That cost-of-error thinking will come back in the faithfulness and evaluation chapters.
Audience: what does the reader already know?
Audience determines vocabulary, assumed background, and what counts as new information. Consider a contract summary written for two readers:
- A lawyer wants clause numbers, defined terms, and the exact wording of obligations. Plain-language paraphrase loses precision they need.
- A sales manager wants to know what they are committing to and when. Clause numbers and defined terms add noise.
State the audience in the prompt, and say what they already know. "The reader is an engineer who knows our product but has not seen this incident" tells the model to skip product background and spend its words on the incident.
Audience also affects tone and risk. A summary that will be shown to customers needs a more careful register than one for an internal triage queue.
Length: a budget, not a wish
Length is a constraint you set, and it should follow from purpose and audience. Models respond better to concrete limits than to vague ones. Compare:
- Vague: "Keep it short."
- Concrete: "Use at most 5 bullet points, each under 25 words."
Common ways to express length:
- A word or sentence limit: "at most 120 words" or "three sentences".
- A structure limit: "exactly five bullets" or "one line per section".
- A ratio: "about one tenth of the original". This is harder for a model to follow on long inputs, because it must estimate the original's size.
Word limits are approximate. Models often overshoot or undershoot, so check the actual length in code when it matters, and treat the limit as a target the pipeline verifies rather than one it trusts.
Length also interacts with the strategies in later chapters. In map-reduce, each partial summary has its own length budget, and the combined partial summaries must still fit in the model's context window. A generous per-chunk length can make the combine step fail. So you will often set one length for the final result and a smaller one for intermediate steps.
Write the specification down
Capture the three decisions in a small, explicit structure. Doing this in code, even for a simple project, keeps the decisions reviewable and reusable across prompts.
from dataclasses import dataclass, field
@dataclass
class SummarySpec:
purpose: str
audience: str
max_words: int
format: str = "bullets"
must_include: list[str] = field(default_factory=list)
def instructions(self) -> str:
lines = [
f"Purpose: {self.purpose}",
f"Reader: {self.audience}",
f"Format: {self.format}, at most {self.max_words} words in total.",
"Use only information that appears in the text.",
]
if self.must_include:
items = ", ".join(self.must_include)
lines.append(f"Always include, if present: {items}.")
return "\n".join(lines)
meeting_brief = SummarySpec(
purpose="Prepare a manager for a 15-minute budget meeting",
audience="A finance manager who knows the project but missed the last month",
max_words=120,
must_include=["decisions needed", "deadlines", "amounts"],
)
print(meeting_brief.instructions())Running this prints:
Purpose: Prepare a manager for a 15-minute budget meeting
Reader: A finance manager who knows the project but missed the last month
Format: bullets, at most 120 words in total.
Use only information that appears in the text.
Always include, if present: decisions needed, deadlines, amounts.You can place this block at the top of any summarisation prompt. The next chapters build on it: the prompt-design chapter refines the wording, and the evaluation chapter uses the same spec as the standard to judge results against.
Note the phrase "if present" in the must-include line. Without it, a model asked for "deadlines" may invent one when the document has none. Requirements that force content create pressure to fabricate.
Putting the spec to work on one document
Take a short incident report. You can see how the spec changes the output without running a model at all, by comparing what each purpose would require from the source.
- Source facts: a database outage lasted 47 minutes, caused by an expired certificate, affected checkout, cost an estimated 12,000 dollars in lost sales, and led to a decision to automate certificate renewal by 15 March.
- For an executive brief, the required facts are impact, cost, and the decision. The certificate detail is secondary.
- For an engineering post-mortem index, the required facts are the root cause, the affected system, and the fix. The cost is secondary.
- For an audit, the required facts are the exact duration, the exact cost estimate with its basis, and the remediation date.
Three correct summaries, none interchangeable. If you cannot say which of these you are building, the prompt is not ready to write.
Common mistakes
- Writing the prompt first. Teams start with wording and discover the purpose only when users complain.
- Choosing a length by habit. "One paragraph" is often too long for a triage list and too short for an audit.
- Leaving the audience implicit. The model defaults to a generic reader, which serves nobody well.
- Mixing purposes in one summary. A single summary asked to serve an executive and an auditor is usually too long for one and too loose for the other. Produce two summaries from the same source instead.
- Requiring content that may not exist. Mandatory fields without an "if present" escape lead to invented details.
- Treating the length limit as guaranteed. Measure it.
How this connects to the rest of the tutorial
The spec drives choices in later chapters:
- Purpose and length decide whether an extractive or abstractive style fits, which is the next chapter.
- Length and the size of the source decide whether a single pass is enough or whether you need chunking.
- Must-include items and the cost of errors decide how much effort you spend on faithfulness checks.
- The spec is also the yardstick for evaluation. A summary cannot be judged good or bad until you know what it was for.
Summary of key points
- A summary is lossy, so decide what to keep before you write the prompt.
- State purpose as the action the reader takes next.
- State the audience and what they already know.
- Set a concrete length, and verify it in code.
- Write all three into a spec you can reuse in prompts and evaluation.
- Avoid mandatory fields without an "if present" escape.
Exercise
A support team wants summaries of 20-page customer complaint threads. Agents will read the summary to decide which complaints to escalate to a manager. Write the purpose, audience, and length for this summary, and name one must-include item that carries a risk if it is missing.
Show answer
Purpose: let an agent decide whether to escalate the complaint. Audience: a support agent who knows the product and policies but has not read this thread. Length: at most 80 words, as 4 to 5 bullets, so it can be read in under a minute. Must-include examples: any mention of legal action or regulators, the amount of money in dispute, or the number of times the customer has already contacted support. Missing a legal threat is risky because it could prevent an escalation that should happen. Write the must-include list with "if present" so the model does not invent items.
Exercise
Your prompt says "Always include the deadline." Some documents contain no deadline. What failure can this cause, and how do you fix the prompt?
Show answer
The model may invent a deadline to satisfy the instruction, which gives the reader false information. Change it to "Include the deadline if the text states one. If it does not, omit it," or ask for an explicit "No deadline stated" line.