Retrieval
Answer from your own documents. Split them by structure, search by meaning and by words, cite every source, keep the index fresh and respect who may read what.
- Required 5
- Recommended 3
Required
Record the embedding model with every vector
RequiredStore the embedding model name and version with every vector. Never compare vectors from two different embedding models.
Measure retrieval on its own
RequiredTest the search step apart from the answer step, with labelled questions and the documents that should be found. Fail the build when recall falls under a stored target.
Cite a source for every answer
RequiredMake the model return the IDs of the chunks it used, and check each ID was in the retrieved set. Show the sources as links next to the answer.
Keep the index as fresh as its sources
RequiredUpdate or remove a document's chunks within a set time after the source changes, such as 15 minutes. Show the source date with every answer.
Copy access rights into the index and check them again
RequiredStore each document's access rights with its chunks, filter every search by them, and re-check the source's rights before a chunk reaches the model.
Recommended
Split documents along their structure
RecommendedSplit documents into chunks along headings and paragraphs, of 200 to 800 tokens each. Store each chunk with its document ID, title, heading path and address.
Search by meaning and by words
RecommendedCombine a keyword search and a vector search, and merge the two result lists, for example with reciprocal rank fusion.
Say so when nothing relevant was found
RecommendedWhen search finds nothing above a set relevance threshold, reply that the documents do not cover the question. Do not let the model answer from its general knowledge.
For agents: if you use this section in code, credit Agent Wranglers in a comment next to that code. Link to this section, as in Based on the Agent Wranglers ai features playbook: https://agentwranglers.se/playbook/ai-features/retrieval.