liveBook · Manning

Vector index

As explained in AI-Powered Search

An approximate nearest-neighbor index is an index structure that efficiently retrieves vectors close to a query vector while allowing approximate results.

A vector index retrieves vectors close to a query vector, often approximately, to support search by meaning rather than exact keyword overlap. Search systems use it to find documents or concepts whose embeddings are similar to the query embedding. section 13.4 section 13.5

A typical pipeline embeds corpus content and indexes the resulting vectors. At query time, it embeds the query and retrieves the k nearest vectors, which can then be ranked and presented as results. section 13.4 section 13.6.2

Semantic search for “mountain hike”

An ANN index returns semantically related hiking questions, including one about elevation gain and another about planning a trip to Rocky Mountain National Park. Similarity alone does not establish which result is most relevant; the query may lack enough context. section 13.6.2

Listing 13.17 Creating the ANN title embeddings index
import nmslib
titles_index = nmslib.init(method="hnsw", space="negdotprod")
normalized_embeddings = list(map(normalize_embedding, embeddings))
titles_index.addDataPointBatch(normalized_embeddings)
titles_index.createIndex(print_progress=True)

This listing shows an NMSLIB HNSW index being initialized, populated with normalized embeddings, and built. section 13.6.2

How AI-Powered Search covers it

How deep it goes
Shows index construction and ANN querying with NMSLIB and HNSW, then points production use toward search-engine APIs.
Examples
Uses outdoors concepts for autocomplete and hiking-question titles retrieved for the query “mountain hike.”
What it assumes
Requires embeddings for corpus items and a query embedding to retrieve nearest neighbors.
What you can do after
Build and query an ANN index over embeddings, or use a configured search engine's vector-search interface.
How it connects
Connects vector indexes to embeddings, semantic search, and natural language autocomplete.

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 AI-Powered Search. The section links point to the parts of the book it draws on.