liveBook · Manning

Composite index

As explained in Natural Language Processing in Action, Second Edition

A composite index combines multiple indexing algorithms or stages into a single retrieval structure.

A composite index combines multiple indexing algorithms or stages into one retrieval pipeline. Common combinations include product quantization (PQ) before inverted-file indexing (IVF) or HNSW, reducing vector memory before search. section 10.3.6

The payoff is memory efficiency for high-dimensional vectors, especially when GPU or RAM capacity is limited. The cost is configuration sensitivity: latency, throughput, and resource use depend on how each stage is tuned, and a poor configuration can underperform simpler pipelines. section 10.3.6

IVFPQ and HNSW plus PQ

Faiss uses IVFPQ for high-dimensional vectors, while HNSW plus PQ has been adopted by frameworks such as Weaviate. These combinations target web-scale search, but simpler indexing may be preferable when the dataset fits comfortably in memory. section 10.3.6

Listing 10.14 Quantizing numpy floats
>>> import numpy as np
>>> v = np.array([1.1, 2.22, 3.333, 4.4444, 5.55555])
>>> type(v[0])
numpy.float64
>>> (v * 1_000_000).astype(np.int32)
array([1100000, 2220000, 3333000, 4444400, 5555550], dtype=int32)
>>> v = (v * 1_000_000).astype(np.int32)       #1
>>> v = (v + v) // 2
>>> v / 1_000_000
array([1.1    , 2.22   , 3.333  , 4.4444 , 5.55555])    #2

Inspect a small NumPy quantization experiment to see the representation-compression step that can precede another indexing algorithm. section 10.3.6

How Natural Language Processing in Action, Second Edition covers it

How deep it goes
Defines multi-stage indexing and explains memory and configuration tradeoffs, but stops short of implementation procedures or tuning recipes.
Examples
Uses IVFPQ, HNSW plus PQ, NumPy quantization, Faiss, Weaviate, and a New York Times ANN comparison.
What you can do after
Evaluate composite-index tradeoffs and recognize when memory savings justify added configuration complexity.
How it connects
Connects product quantization with inverted-file indexing, HNSW, vector search, and nearest-neighbor algorithms.

Also explained in

Compare how 3 books explain composite index →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Natural Language Processing in Action, Second Edition. The section links point to the parts of the book it draws on.