Sub topic 9
Extracting Passages into the Model’s Context
Assume you understand basic crawling, indexing, HTML, and HTTP requests. This chapter focuses on what happens after an answer engine finds candidate pages: selecting useful passages and placing them into the language model’s context.
From a page to a passage
An answer engine rarely sends an entire web page to the model. Pages can contain thousands of words, navigation links, cookie notices, advertisements, and repeated footer text. Sending everything wastes context space and can add irrelevant or conflicting information.
The system first converts the page into readable content. It may remove menus, scripts, styles, and duplicated elements. It preserves signals such as:
- The page title and URL
- Headings and their hierarchy
- Paragraphs, lists, and tables
- Author and publication dates
- Links and nearby explanatory text
The remaining content is divided into smaller sections called chunks. A chunk is a passage-sized unit that can be retrieved independently. Chunk boundaries may follow headings, paragraphs, or token limits. A token is a small unit of text used by a language model. It can be a word, part of a word, or punctuation.
Good chunking keeps related claims together. For example, a heading, its definition, and its example usually belong in the same retrieval unit. A chunk that begins with “This method” but excludes the earlier definition is harder for the model to understand.
Selecting and expanding passages
A query may match a sentence directly, but the surrounding text often supplies necessary meaning. Retrieval systems therefore select a matching chunk and may include neighboring chunks. This is called context expansion.
A reranker can then score passages using deeper language understanding. It considers whether the passage answers the rewritten query, not just whether it contains the same words. A passage with a clear definition may outrank a page that repeats the query many times.
The system also tracks provenance. Provenance is information about where a passage came from. It can include the canonical URL, page title, section heading, and character or token offsets. This metadata helps the answer engine attach a citation to the correct page.
> The passage in the model’s context is not necessarily the exact text displayed in the final citation. The engine may summarize, trim, or combine retrieved material while retaining the source reference.
What page authors can control
You cannot control an engine’s chunk size or reranking model, but you can make extraction easier:
- Put one main question or task in each section.
- Use descriptive headings instead of clever or vague headings.
- State the answer directly before adding background.
- Keep important claims in complete paragraphs.
- Define pronouns and terms locally instead of relying on distant context.
- Avoid placing key content only inside images, scripts, or interactive widgets.
- Keep unrelated topics on separate pages or clearly separated sections.
A self-contained passage gives the model enough information to answer accurately even when it retrieves only part of the page.
Exercise
Why might a passage containing the exact search phrase still be a poor source?
Show answer
It may lack the surrounding definition, conditions, or evidence needed to interpret the phrase correctly.