Retrieval, context construction, and prompt construction
Practice this questionOverview
- Retrieval selects candidate evidence.
- Context construction chooses which evidence and conversation details the model sees.
- Prompt construction combines trusted instructions, the user's question, and clearly labeled untrusted source material.
Why this matters
Retrieved data alone does not specify how to answer, handle gaps, or resolve conflicting sources.
An everyday example
An employee selects the applicable handbook pages and a task brief rather than placing every document on the desk.
A technical example
Provide S1: [policy/version/page] passage, S2: ..., and require source IDs for material claims.
How it works
- Derive filters
- Search
- Merge/rerank
- Remove duplicates
- Select complete clauses
- Enforce token budget
- Build prompt with evidence and abstention instructions.
Architecture and flow
Eligible candidates → relevance/freshness checks → context budget → prompt → answer.
The insurance assistant example
Use the customer's policy wording, not a generic product brochure, when explaining exclusions.
When to use it
Every RAG answer should have an explicit context-building policy.
When to avoid it
Do not stuff top-100 results into the prompt or instruct the model to follow instructions found inside documents.
Interview answer
“I retrieve broadly enough for recall, select precise eligible evidence, and give the model clear grounding and abstention rules.”
Benefits, trade-offs, and production considerations
- Distinguish “no results,” “search failed,” and “sources conflict.” These need different responses.
- A vector score alone is insufficient to confirm answerability; validate complete, applicable supporting evidence.