liveBook · Manning

Vector index

As explained in Domain-Specific Small Language Models

A data structure that accelerates retrieval by organizing vectors for efficient similarity search.

An index is a data structure that organizes vectors so similarity search retrieves nearby items efficiently instead of comparing every vector by brute force. In FAISS, it parallels a relational-database table index: it points retrieval toward stored data. Embeddings are normalized before indexing so vectors share a common scale. section 2.1.3

Operationally, an index connects embedding preparation with retrieval:

  • Create embeddings for text, choose an index compatible with the vector dimension, normalize vectors when required, and add them to the index. section 2.1.3
  • Embed each query using the same preparation steps, then search for a chosen number of neighbors. section 2.1.3
  • Use returned distances and vector positions to join similar results back to their source text or metadata. section 2.1.3
  • In RAG, build or update indexes offline as documents change, then query them online to retrieve context for generation. section 13.2

Classifying superhero text by nearest vectors

Encode four sentences labeled spiderman, ironman, or captainamerica, add their normalized embeddings to a FAISS L2 index, and search with “He throws webs.” The nearest results are the two spiderman sentences, with their distances and original positions returned for merging with the DataFrame. section 2.1.3

How Domain-Specific Small Language Models covers it

How deep it goes
Explains index construction, normalization, distance results, and offline-online placement, but does not compare index algorithms.
Examples
Demonstrates Marvel sentence classification with FAISS and PDF-chunk retrieval with an embedding-backed RAG pipeline.
What it assumes
Assumes vector embeddings and labeled or chunked text records, while demonstrating how embeddings become searchable indexes.
What you can do after
Apply it via FAISS by indexing normalized embeddings, searching query vectors, and mapping returned positions to source records.
How it connects
Connects vector embeddings, similarity search, vector databases, 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 Domain-Specific Small Language Models. The section links point to the parts of the book it draws on.