Retriever
Before a model can answer from your documents, something has to find them. The retriever is that component: given a question, it searches a prepared index and returns the handful of passages most likely to contain the answer.
Sparse, dense, and bothA sparse retriever matches words. BM25 scores a passage by how many of the query's rare terms it contains, which makes it excellent at part numbers, surnames and error codes — anything where the exact string matters. A dense retriever matches meaning: an embedding model turns the question and every passage into vectors, and similarity in that space connects “how do I cancel” to a paragraph headed “terminating your subscription” with no shared vocabulary. Each fails where the other is strong, which is why production systems run both and merge the rankings — hybrid search.
Where the quality comes from- The embedding model: a general-purpose one blurs domain jargon, and swapping it means re-embedding the entire corpus.
- Chunk size: too large and the relevant sentence is diluted, too small and it loses the context that makes it interpretable.
- Index type: Faiss, HNSW and their hosted equivalents are approximate, so recall is a tuning knob rather than a given.
The retriever sets the ceiling on everything downstream. A frontier generator reading three irrelevant paragraphs produces a fluent, well-structured, wrong answer — the hardest kind to catch.
A retriever is the component of a RAG system that, given a query, searches an index of document chunks and returns the top candidates for the model to read. Sparse retrievers such as BM25 match exact terms; dense retrievers compare embedding vectors and so match meaning. Its recall bounds the whole system — the generator can only reason over what the retriever returns, and a missed passage becomes an answer invented from memory.
When you ask a librarian a question, they do not read you the whole library. They walk to the right shelf and pull out a few books. A retriever does that job inside an AI system. It takes your question, searches through a pile of documents that were prepared in advance, and brings back the few passages most likely to hold the answer. Some retrievers look for the same words you used, which is handy for names and codes. Others look for the same idea, so they find the right paragraph even when it is worded completely differently.