LESSON 34 / 215·2 min readIntermediate

Retrieval, context construction, and prompt construction

Must knowConcept lesson
01 Understand02 Recall03 Prepare

Words made simple

A few useful meanings before you read the explanation.

Retrieval
Finding and fetching information that is useful for the current question.
Token
A small piece of text processed by a model. It may be a whole word, part of a word, or punctuation.
Vector
An ordered list of numbers. An embedding is a vector used to represent content for tasks such as similarity search.
More words from this lesson
RAG
Find relevant information first, then give it to a model to help answer the question. The answer is only as reliable as the information and checks used.
Grounding
Connecting an answer to supplied evidence, such as a policy document or a verified database result.

Overview

  • 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

  1. Derive filters
  2. Search
  3. Merge/rerank
  4. Remove duplicates
  5. Select complete clauses
  6. Enforce token budget
  7. 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.
PAUSE & RECALL

Can you explain it without the notes?

Retrieval, context construction, and prompt construction

Use your own words. Explain an example and one limitation before checking the explanation.

Check your explanation

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.

CONNECT IT TO YOUR INTERVIEW

Turn this concept into a clear answer.

Practice this concept
YOUR NEXT STEP

Keep connecting the ideas.

Next lesson: Citations and source attribution

Adapted from 13_AI.MD · “Retrieval, context construction, and prompt construction”. Examples are study fragments; framework behavior can depend on your version.