Notes

Document Indexing

Chunked text sitting in a folder is not searchable. Document indexing is the build step between having documents and being able to retrieve from them: every chunk is turned into a vector, filed in a structure that supports fast nearest-neighbour lookup, and tagged with enough metadata to find its way back to the page it came from.

What one indexed record holds
  • The embedding of the chunk, produced by one specific embedding model.
  • The chunk text itself, because the retrieved passage is what goes into the prompt.
  • Metadata — source file, page or heading, date, access permissions — which the retriever filters on and the answer cites.
  • Frequently a keyword index over the same text, so lexical and vector matches can be combined.
The structure underneath

Comparing a query against every stored vector is exact and too slow past a few hundred thousand chunks. The index therefore builds an approximate structure — an HNSW graph or an IVF partitioning — that searches a small fraction of the collection and accepts a measured loss of recall. Faiss, Milvus, Pinecone and Weaviate all expose that choice as build time, memory and recall traded against one another.

Why the index constrains everything above it

An index is a snapshot. New documents have to be upserted and withdrawn ones removed, or the assistant answers confidently from a policy that was retracted last quarter. Swapping the embedding model invalidates every vector in the store and forces a full rebuild, a job measured in GPU hours on a large corpus. That is why the embedding model and the chunking plan are chosen together, before the first build, rather than tuned later.

Document indexing is the build step that makes a corpus retrievable: each chunk is embedded, stored alongside its text and metadata, and organised into a structure — typically an HNSW graph or IVF partitions — that answers nearest-neighbour queries in milliseconds. The index fixes which embedding model the system uses and governs retrieval latency and recall. It is a snapshot: changed documents need re-indexing, and a new embedding model invalidates all of it.

The index at the back of a textbook is what makes the book usable — without it you would read 600 pages to find one fact. Document indexing builds that kind of index for a computer, over your own files. Each piece of text is turned into a string of numbers that captures its meaning, and all of them are filed so the closest match to a question can be found instantly. The work happens before anyone asks anything, which is why a new document is invisible to the assistant until the index is updated. Skip that upkeep and it keeps answering from last year's handbook.