A retriever is the search component that finds and ranks information relevant to a user query. It relies on indexed content for fast lookup across a growing corpus, returning documents or passages ordered by relevance rather than generating an answer itself. section 3.0 section 5.3.1
In a RAG pipeline, the retriever acts as a knowledge retriever between query processing and generation. Its selected context gives a decoder factual, domain-specific material to use when composing a response, helping ground output in external information. section 6.1
A practical semantic retriever can be built as a short pipeline:
- Collect a knowledge base, such as hotel reviews, and select the documents to search. section 6.1
- Encode documents into embeddings, normalize them, and add them to a FAISS inner-product index. section 6.1
- Encode and normalize the query, search for the top K nearest entries, then return ranks, text, and similarity scores. section 6.1
- Pass the retrieved results as context to a decoder when an end-user answer is needed. section 6.1
Hotel-view retrieval
For the query “Hotel with a view of the Eiffel tower,” a semantic search over Paris hotel reviews ranks reviews for Pullman Paris Eiffel Tower Hotel at the top and exposes their cosine-similarity scores. Those ranked reviews can then become cited context for an answer about suitable hotels. section 6.1
Retriever quality is evaluated separately from generation quality. Precision@K measures noise among top results; recall measures coverage of relevant documents; MRR emphasizes the first relevant result; NDCG weighs relevance by rank; and context relevance asks whether retrieved material can answer the query. section 6.5.1
Figure 6.1 Architecture of a Retrieval Augmented Generation (RAG) system showcasing the integration of retrieval and generative components for enhanced natural language processing tasks.
Use the RAG architecture diagram to locate the retriever between the knowledge base and the context supplied to the decoder. section 6.1





