liveBook · Manning

Retriever

As explained in Machine Learning Platform Engineering

A retrieval component is a system stage that finds information relevant to a query and supplies it to downstream processing.

A retriever is the RAG stage that finds information relevant to a query and supplies document chunks to downstream context assembly. Retrieval quality directly affects the answers an LLM can produce, so the component must be treated as a production integration rather than a standalone similarity lookup. section 12.2.4 section 12.2.5

A practical retriever pipeline typically:

  • Loads source Markdown files recursively and splits them into overlapping chunks, preserving useful document structure through configured separators. section 12.2.4
  • Embeds document chunks with a document-specific retrieval task and stores the vectors in a FAISS index. section 12.2.4
  • Persists the index and reloads it with the same embedding model, because dimension, normalization, or model-version changes can break compatibility. section 12.2.5
  • Exposes similarity search through a retriever interface, allowing a query to produce documents that can be joined into LLM context. section 12.2.5

Retrieving an encryption-key procedure

A query such as “How do I rotate encryption keys?” is passed to the retriever, which returns the most relevant indexed chunks. The chunks are joined into context before being supplied to the LLM. section 12.2.4 section 12.2.5

Listing 12.9 Persistent FAISS index and LangChain retriever
from langchain_community.vectorstores import FAISS
from index import GeminiEmbeddings

embeddings = GeminiEmbeddings()  #1
vector_store = FAISS.load_local(
    "DATA/faiss_index",
    embeddings=embeddings,
    allow_dangerous_deserialization=True  #2
)
retriever = vector_store.as_retriever()  #3

Shows how a persistent FAISS index becomes a LangChain retriever after being loaded with the matching embedding wrapper. section 12.2.5

Listing 12.10 RAG query processing with retrieval and context
query = "How do I rotate encryption keys?"  #1
docs = retriever.invoke(query)  #2
context = "\n\n".join( #3
    [doc.page_content for doc in docs])   #3

Shows the runtime handoff from a user query to retrieved documents and assembled context. section 12.2.5

How Machine Learning Platform Engineering covers it

How deep it goes
Builds indexing, persistence, compatibility, and query flow, while deferring sophisticated production context assembly beyond basic concatenation.
Examples
Uses Markdown documents, overlapping chunks, a FAISS index, and an encryption-key-rotation query.
What it assumes
Assumes document chunks and embeddings, while demonstrating loading, chunking, indexing, persistence, and query retrieval.
What you can do after
Apply it via FAISS and LangChain to build a persistent retriever that returns documents for a RAG query.
How it connects
Connects semantic search, embeddings, vector databases, FAISS, LangChain, RAG, and augmentation.

Also explained in

Compare how 3 books explain Retriever →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Machine Learning Platform Engineering. The section links point to the parts of the book it draws on.