What Retrieval Actually Does
Retrieval-augmented generation looks up relevant passages from your own material and hands them to a language model together with the question. The model writes the answer from what it was given.
That means the answer can only be as good as the passages. If the search returns an outdated policy, the reply will be confidently outdated.
Prepare the Source Material
Before tuning prompts, spend time on the collection itself.
- Remove superseded versions, or mark which version is current
- Split documents on headings so each passage keeps its context
- Store the title, section, date, and access rights with every passage
- Filter by the user's permissions before searching, not after answering
Measure Before You Improve
Collect thirty to fifty real questions with the passages that should answer them. Run them after every change and record two things separately: whether the right passage was retrieved, and whether the answer used it correctly.
type EvalCase = { question: string; expectedSourceIds: string[] };
export async function retrievalHitRate(cases: EvalCase[]) {
let hits = 0;
for (const c of cases) {
const results = await search(c.question, { limit: 5 });
if (results.some((r) => c.expectedSourceIds.includes(r.sourceId))) hits++;
}
return hits / cases.length;
}Let the Assistant Decline
A useful assistant can say that the documents do not cover a question and point to a person. Require citations, show them to the reader, and treat a missing source as a reason not to answer.



