Sub topic 1
Decide what the summary is for
A summary that works for one reader can fail for another. Before you write a prompt or pick a strategy, decide what the summary is for. This chapter gives you three decisions to make first: purpose, audience, and length. It also shows how to record them so that your prompt and your evaluation both use them.
Prerequisites
This chapter assumes you have:
- Basic Python, including functions and string formatting.
- Experience sending prompts to an LLM through an API or a chat interface.
- Familiarity with the idea of tokens, the units of text a model reads and writes.
Why the goal comes first
A model can compress any text, but it cannot know what you need to keep. If you ask for "a summary", it guesses. The guess is usually a generic overview that suits no one in particular.
Consider a 40-page incident report. An engineer on call wants the root cause and the fix. A manager wants the customer impact and the timeline. A compliance officer wants to know whether personal data was exposed. Each needs a different summary of the same document. If you do not choose one, the model picks for you, and you cannot tell whether it picked well.
The three decisions
Purpose
Purpose is the job the summary does for its reader. Common purposes include:
- Triage: help the reader decide whether to read the full document.
- Decision support: give the reader the facts needed to approve, reject, or act.
- Replacement: let the reader skip the source entirely.
- Navigation: point the reader to the right sections of the source.
Replacement is the most demanding. The summary must be complete and accurate on every point that matters, because nobody will check the source.
Audience
The audience determines vocabulary, assumed knowledge, and which details matter. A summary for domain experts can use technical terms and skip background. A summary for newcomers must define terms and add context. Name the audience in the prompt, for example "a product manager with no engineering background".
Length
Length is a constraint you can measure. State it in a unit the model follows well, such as "three bullet points", "under 100 words", or "one paragraph". Models follow word and sentence limits only roughly, so check the output rather than trusting it. Shorter is not always better. A 50-word summary of a contract drops the clauses that carry risk.
Record the decisions as a brief
Write the three decisions down once, then reuse them in the prompt and later in evaluation. A small data structure keeps them together.
from dataclasses import dataclass
@dataclass
class SummaryBrief:
purpose: str
audience: str
length: str
def to_instruction(self):
return (
f"Write a summary for this purpose: {self.purpose}. "
f"The reader is {self.audience}. "
f"Length: {self.length}. "
"Use only information in the text."
)
brief = SummaryBrief(
purpose="help the reader decide whether the incident needs executive attention",
audience="a manager with no engineering background",
length="at most 4 bullet points",
)
print(brief.to_instruction())Running this prints one instruction string. You can place it ahead of any document text. Chapter 4 covers prompt wording in more detail. For now, the point is that the brief exists before the prompt does.
How the decisions connect
The three decisions feed the rest of the pipeline. Purpose and audience shape the prompt. Length affects how aggressively the text must be compressed, and that affects which strategy you choose for long documents. The brief also becomes the checklist you use when you evaluate the result.
Common mistakes
- Leaving purpose implicit. The model returns a generic overview, and you cannot judge whether it is good.
- Naming no audience. The output mixes jargon and basic explanation.
- Setting length by feel. Without a stated limit, outputs vary from run to run, which makes comparison and evaluation hard.
- Changing the brief halfway. If you edit the goal after seeing outputs, earlier results are no longer comparable.
Check your understanding
Exercise
A legal team wants a summary of a 60-page contract so that a lawyer can skip reading it and still catch every termination clause. Write the purpose, audience, and length for the brief, and say which purpose type this is and why it is demanding.
Show answer
Purpose: replace reading the contract for the purpose of identifying all termination clauses. Audience: a lawyer who knows contract terminology. Length: a list with one entry per termination clause, each in one or two sentences, with no fixed total cap. This is a replacement summary, which is the most demanding type. The lawyer will not check the source, so missing or misstated clauses cause real harm. A tight word limit would work against the goal.