Skip to content
mlmentorship

RAG: retrieval-augmented generation

Trace an authorized, versioned passage from corpus to answer, then distinguish citation existence from actual claim support.

Published · 6 min read ·Role-specific ·Intermediate
Reading depth

Summary

Retrieval-augmented generation supplies external evidence as model context without requiring that evidence to be stored in model weights. Success requires authorized evidence to survive retrieval and selection, then support the actual response claims. A resolving citation alone proves neither support nor truth.

The architecture

Offline, parse documents into chunks while retaining source IDs, versions, boundaries, and access metadata. Build the chosen indexes and update or delete entries when their sources change. Keep each plan name and retention value together; preserve heading or neighbor references when splitting would separate them.

Online, apply the requester’s access policy, retrieve a bounded candidate set, select bounded context, and generate claim-linked citations. The pictured hybrid retrieval and reranking are possible choices, not mandatory stages for every corpus or latency budget. Query rewriting can also change intent, so evaluate it rather than assuming improvement.

For a hypothetical fully authorized corpus:

PassageVersionText
P1v1Plan A retains logs for seven days.
P2v1Plan B retains logs for thirty days.

Ask about plan B, with candidate limit two and context limit one. Retrieval returns P1/P2; selection retains P2 with its version and an allowed access decision. The answer “thirty days” linked to P2 follows the evidence path. A seven-day answer citing P2 resolves to an existing passage but fails support. If P2 never enters the candidate set, merely reranking P1 cannot recover it.

Trace the answer back through retrieval to one versioned source chunk

Keep the answer connected to one versioned source chunkA stable chunk identity and version connect the retrieved evidence to its source. A citation string alone is not that lineage receipt.Carry one chunk identity and versionthrough the answer lineageC7doc D v3; indexed C7C7request retrieves C7 v3C7claim cites actual C7 v3
Derivation
Follow one versioned chunk from the corpus into the answerFictional document D version three has c1 stating thirty-day returns and c2 giving a support email. Lexical retrieval returns c1 and dense retrieval c1/c2. Fusion retains both; the optional reranker removes c2 from answer context. The answer cites D@v3:c1. Corpus refresh need not retrain model weights, and authorization and support still apply.Toy authorized request: what is the returnwindow?OFFLINE document D@v3c1: "Returns within 30 days."c2: "Contact support by email."Same chunk IDs in both indexeslexical -> c1; dense -> c1,c2fusion -> {c1,c2}ONLINE reranker selects c1c2 removed from contextrequest authorization retainedAnswer: "30 days [D@v3:c1]"exact source version preservedA later corpus v4 changes indexed evidence,not necessarily the language model's weights.A citation still needs an independentsupport check.
The same c1 identity survives offline indexing, retrieval, selection, and citation. The reranker removes c2 here. Preserve access and source version; a citation alone still does not prove support.
Check: Which offline chunk becomes the final cited evidence? Which online stage removed its competing candidate?
Read it this way: A stable chunk identity and version connect the retrieved evidence to its source. A citation string alone is not that lineage receipt.
Does a citation string alone prove the retrieved evidence was C7 version three?

Change Matching Needs

New task: Retrieve both exact error identifiers and paraphrased descriptions.

Picture and change: Compare lexical and dense candidate sets, then fuse deduplicated document identities with their provenance. Tune candidates, fusion, and limits on development queries, not the final test set.

Check: A lexical ERR-42 match remains eligible rather than being vetoed solely by a low dense score. Inspect whether subsequent candidate/context cutoffs retain its supporting passage.

Use when: Query slices need complementary matching signals, rather than a universally mandated hybrid pipeline.

Change Evidence Availability

New task: The authorized corpus lacks the answer.

Picture and change: Return the defined no-evidence or partial-answer outcome instead of inventing a supporting passage.

Check: Neither P1 nor P2 supports a claim about plan C.

Use when: Coverage or authorization prevents a grounded answer.

Measure retrieval coverage at the actual candidate limit separately from context support, answer correctness, citation resolution, and abstention behavior. Use judged query slices and report denominators; first-hit utility and relevant-passage coverage are distinct targets. Time and cost budgets must include retrieval, selection, generation, and any verification actually used.

Revoking access or deleting a document must invalidate old index entries and context caches before serving its text again. Preserve source/version IDs through citations and recheck request authorization; a cached passage is not a permanent access grant. Retrieved instructions are untrusted data, not policy.

What an interviewer expects you to say

Explain one request’s evidence path, access decision, limits, and unsupported-answer outcome before discussing optional components.

Common confusions

Evidence availability does not guarantee evidence use, correct reasoning, or faithful citations. Embedding changes, reranking, and context selection need workload-specific evaluation, not fixed percentage-point promises.

Failure modes (in frequency order)

The retained heading is not a measured frequency ordering. Distinguish missing evidence, lost chunk boundaries, stale versions, access violations, unsupported claims, and distribution-shifted evaluation queries.

When RAG is and isn’t the right tool

Choose retrieval when selecting external, changing evidence fits the task. Compare direct context, structured queries, prompting, or fine-tuning against the required behavior and evidence lifecycle.

Tools (mid-2026)

Select storage and orchestration by measured recall, access filtering, update latency, cost, and operational constraints. No specific framework or document-count threshold follows from the RAG mechanism.

Why interviewers ask

The useful distinction is between finding evidence and producing claims that the evidence supports.


Related essay: Designing a RAG system that actually works for the long form. Related interview: When would you fine-tune vs prompt vs RAG?.