Retrieval
Writing
Free lessons
Glossary terms
- ChunkingChunking is splitting documents into pieces small enough to index and retrieve individually. The size and boundaries decide what search can find: too large and a chunk mixes topics, too small and it loses the context that makes it meaningful. Splitting along headings and list items usually beats fixed character counts.
- GroundingGrounding means tying a model's answer to supplied sources: it should say only what the retrieved passages support, cite them, and admit when the sources do not contain the answer. A grounded system is checkable by a reader. Faithfulness is the metric that tests whether each claim appears in the sources.
- Hybrid searchHybrid search combines keyword search, which is good at exact terms such as error codes and names, with vector search, which is good at paraphrases and meaning. The two ranked lists are merged, commonly with reciprocal rank fusion. On most real corpora the combination beats either method alone.
- RAG (retrieval-augmented generation)RAG retrieves passages relevant to a question from your own documents and puts them into the prompt so the model can answer from them. It is two systems in sequence, a search step and a generation step. The answer can only be as good as the passages that the search returned.
- Recall at kRecall at k is the share of questions for which at least one relevant passage appears among the top k retrieved results. It measures the ceiling of a RAG system: if the right passage is not retrieved, the generator cannot use it. You compute it on a set of real questions with known answer locations.
- RerankingReranking is a second search stage in which a model reads the question together with each candidate passage and rescores relevance more precisely than vector similarity can. You typically retrieve a few dozen candidates cheaply and rerank them down to the best handful. It improves ranking but adds latency and cost.
- Vector databaseA vector database stores embeddings together with ids and metadata and finds the nearest vectors to a query quickly. Most use approximate nearest-neighbour indexes that trade a little accuracy for speed. You can use a dedicated store, or the pgvector extension in Postgres if you already run it.
More on Retrieval, by email
New writing on Retrieval goes out in the newsletter, with a note on why it is worth your time.