Sub topic 2
Why passages, not pages, are what get retrieved
Assume you know basic HTML, can edit web content, and understand how search engines display results. This chapter focuses on the unit that AI answer systems usually retrieve: a passage, or chunk, from a page.
What gets retrieved?
AI answer systems rarely treat an entire web page as one usable answer. A retrieval system first finds pages that may contain relevant information. It then splits those pages into smaller sections called chunks. Each chunk is often a paragraph, a group of paragraphs, a list, a table, or a section around a heading.
The system compares the user’s question with these chunks. It selects the chunks that appear most relevant, then gives them to a language model to summarize or quote. A page can rank well while a particular passage remains too vague, incomplete, or unrelated to be selected.
| Unit | What it contains | Main risk |
|---|---|---|
| Page | All content at one URL | Relevant information may be buried |
| Section | A heading and its content | The section may depend on missing context |
| Passage | A small, meaningful answer | It must be specific and self-contained |
The exact chunking method differs by product. Some systems use heading boundaries. Others use fixed token limits, where a token is a small unit of text used by a language model. Many use overlapping chunks so that a sentence near a boundary is not lost. You cannot control the final chunks, but you can write content that remains useful when separated from its page.
Make each passage stand alone
A passage survives retrieval better when a reader can understand it without the paragraphs before and after it. Include the subject, the action, and the important condition in the same passage.
Weak passage:
## Caching
This is usually a good starting point. You can adjust it later.The reader does not know what “this” means. A retrieval system may select the passage without the missing explanation.
Stronger passage:
## How long should you cache product API responses?
Cache product API responses for 5 to 15 minutes when the data changes several times a day and a short period of stale data is acceptable. Reduce the time-to-live, or TTL, when price or inventory changes must appear quickly.This version names the subject, answers the question, defines TTL, and states the condition. It can be quoted without requiring surrounding text.
Keep chunk boundaries meaningful
Use headings to signal a change in question or task. Put the direct answer in the first sentence or two under each heading. Follow it with explanation, examples, limits, or evidence.
Avoid placing one answer across several unrelated sections. A chunk that contains only a setup sentence may be retrieved instead of the conclusion.
A useful pattern is:
- Ask one specific question in the heading.
- Answer it immediately.
- Define unfamiliar terms.
- Add conditions, numbers, or exceptions.
- Link to the next related question with a new heading.
Short paragraphs also help. A paragraph with one clear claim is easier to match than a long paragraph containing several topics. Lists and tables work well for procedures and comparisons, but introduce them with a sentence that states what they describe.
A simple chunking check
You can inspect whether your paragraphs carry enough context with a small script. This example flags paragraphs that are unusually short or begin with vague pronouns.
import re
text = """
Cache product API responses for 5 to 15 minutes when a short period of stale data is acceptable.
This is usually a good starting point. Adjust it later.
Reduce the time-to-live, or TTL, when price or inventory changes must appear quickly.
"""
for number, paragraph in enumerate(
(part.strip() for part in text.split("\n\n") if part.strip()), start=1
):
words = re.findall(r"\b[\w'-]+\b", paragraph)
starts_vaguely = re.match(r"^(This|That|It|They|These|Those)\b", paragraph)
if len(words) < 12 or starts_vaguely:
print(f"Review paragraph {number}: {paragraph}")The script does not predict retrieval. It only identifies passages that deserve a manual review. Read each flagged passage by itself and ask whether it still states a useful answer.
Exercise
Rewrite this passage so it can be retrieved and quoted on its own: “It depends on how often the data changes. For most cases, this is fine.”
Show answer
“Cache a response for 5 to 15 minutes when its data changes several times a day and a short period of stale data is acceptable. Use a shorter time-to-live when users need near-real-time updates.”