What it is
Retrieval-Augmented Generation fetches authoritative passages from a corpus before generation so the model answers from current, auditable facts instead of parametric memory. Hybrid retrieval combines semantic vectors with lexical keyword matching (such as BM25) and citation thresholds.
Why you need it
If retrieval misses the right chunk due to terminology mismatch, or passes noisy irrelevant chunks, an LLM will smoothly invent a plausible wrong policy with high confidence.
How it works
- Chunk documents along semantic boundaries while preserving titles and metadata.
- Retrieve candidates with hybrid semantic + keyword scoring and re-rank.
- Require citations to retrieved chunk IDs and reject low-relevance matches with an explicit fallback.
- Log retrieved chunks alongside answers so failures separate retrieval bugs from generation bugs.
Threshold-gated retrieval response
matches = hybridSearch(query, { tenantId: caller.orgId, topK: 5 })
relevant = matches.filter(chunk => chunk.score >= MIN_RELEVANCE)
if relevant.length === 0:
return { answer: "No verified policy found.", citations: [] }
return generateGroundedAnswer(query, relevant)Scoping retrieval by tenant before ranking prevents cross-customer leaks, and thresholding avoids forcing the model to synthesize an answer from irrelevant chunks.
Good practices and why
- Measure retrieval recall@k separately from final answer quality.
- Filter access permissions on chunks before putting them into the prompt context.
Common mistakes
- Simply raising top-k to 20 chunks when precision is poor.
- Forgetting to test vocabulary mismatches between customer phrasing and doc titles.
Try it yourself
Take five customer questions phrased informally and compare pure keyword overlap versus synonym/hybrid matching against a small set of policy notes, including one question with no answer in the docs.
What a successful result looks like
The out-of-scope question triggers the fallback instead of guessing, and relevant answers cite the exact source passage.
0 / 6000 characters · Saved on this device. Do not include passwords or private data.
Check your understanding
Answer the understanding check correctly to record exercise completion.
Related interview practice
- The model confidently gave the customer wrong information. ↗
- The answer is in the docs. The model does not find it. ↗
- The model forgets what the customer said three messages ago. ↗
These scenarios add constraints and follow-up questions to the concepts you just learned.
Further reading
Selected primary references · reviewed 2026-10-09. Examples are educational; use your framework’s documented integration guidance when building a deployed system.