liveBook · Manning

Vector index

As explained in Machine Learning Platform Engineering

A vector index is an indexing structure that organizes numerical vector representations to support efficient similarity search.

A vector index organizes numerical representations of document chunks so an application can find semantically similar content quickly. In a retrieval-augmented generation (RAG) system, it avoids comparing a query sequentially against potentially millions of document vectors. Retrieved chunks can then become context for an LLM prompt. section 12.2.4 section 12.2.5

Build and use an index as a repeatable pipeline:

  • Load source documents and split them into coherent, overlapping chunks; chunk boundaries affect retrieval quality. section 12.2.4
  • Embed each chunk with the document embedding operation, then pass the chunks and embedding wrapper to `FAISS.from_documents` to construct the searchable index. section 12.2.4
  • Save the index and load it on restart instead of paying the time and API cost of rebuilding it. Use the same embedding model when reconnecting: dimension, normalization, or version differences can cause failures. section 12.2.4 section 12.2.5
  • Search the index or expose it as a retriever. Assemble the returned document chunks into context before sending them to the LLM. section 12.2.4 section 12.2.5
Listing 12.6 FAISS vector index creation from document chunks
from langchain_community.vectorstores import FAISS

def create_faiss_index(chunks: List[Document]) -> FAISS:  #1
    embeddings = GeminiEmbeddings()  #2
    vectorstore = FAISS.from_documents( #3
        chunks, embeddings)   #3
    return vectorstore  #4

The index-creation function shows the key integration point: `FAISS.from_documents(chunks, embeddings)` embeds prepared chunks and returns a searchable vector store. section 12.2.4

Check retrieval before prompt assembly

After indexing the Markdown documents, run `similarity_search("How do I rotate encryption keys?", k=3)` and inspect the three returned chunks. The query-processing step can then invoke a retriever and join returned page contents into prompt context. section 12.2.4 section 12.2.5

Treat the saved index as a deployment artifact alongside embeddings, chunking rules, and retrieval settings. Loading the shown FAISS index enables Python's dangerous deserialization option; secure the index files and consider integrity checks because tampered files can execute code. section 12.1.2 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

The loading example reconnects the persisted FAISS index to its embedding wrapper and exposes a LangChain retriever for queries. section 12.2.5

How Machine Learning Platform Engineering covers it

How deep it goes
Works through chunk preparation, embedding, FAISS creation, persistence, and querying; does not detail FAISS index internals.
Examples
Uses Markdown documents, a FAISS index, and an encryption-key question to test retrieved chunks.
What it assumes
Starts with document loading and chunking rather than requiring a prebuilt index; implements the pipeline with Python and an embedding API.
What you can do after
Build it from scratch with FAISS, persist it, and reconnect it to a retriever for RAG queries.
How it connects
Connects document chunking and embeddings to similarity search, retrievers, and retrieval-augmented generation.

Also explained in

Compare how 8 books explain vector index →

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.