Vector Database
Retrieval for a language model does not work by matching words. Documents become embeddings — long lists of numbers that place each passage by meaning — and a question is answered by finding the passages nearest to it in that space. A vector database is the system built to hold those vectors and answer "what is nearest to this?" quickly across millions of them.
What it adds to a search libraryThe nearest-neighbour search itself is available from a library such as Faiss. A database wraps it in what production actually needs:
- approximate index structures — HNSW graphs, inverted lists with product quantisation — trading a sliver of recall for millisecond answers;
- live inserts, overwrites and deletes, so the corpus can change while serving, with no index rebuild;
- metadata filters restricting a search to one tenant, date range or document type, evaluated together with the vector comparison rather than after it;
- hybrid search, fusing keyword scores with vector similarity so exact identifiers and product codes are not lost to semantics.
This is the retrieval tier: the pipeline chunks documents, embeds them, writes them here, then at query time embeds the question and pulls the top passages into the prompt. Decisions made in this layer cap answer quality — tuning an index for speed quietly lowers recall, and nothing in the finished answer announces that the relevant paragraph was never retrieved. One constraint catches teams out: vectors are only comparable within the embedding model that produced them, so changing that model means re-embedding the entire collection. Choices run from Pinecone, Milvus, Weaviate, Qdrant and Chroma to the pgvector extension, which keeps the vectors inside a Postgres database you already run.
A vector database stores text embeddings alongside their metadata and answers nearest-neighbour queries over them, using approximate indexes such as HNSW to return results in milliseconds at scale. Beyond a search library it adds live inserts and deletes, metadata filtering, hybrid keyword-plus-vector search, and ordinary operational guarantees. In a RAG system it is the retrieval tier, and its recall caps how factual the final answer can be.
Computers can turn a paragraph into a long list of numbers that captures roughly what it means, so that passages about the same thing end up with similar numbers. A vector database is a filing system for those numbers. Hand it a question and it returns the handful of stored passages closest in meaning — including ones that share no words with the question at all. This is what lets an assistant answer from your own documents: it looks up the relevant pages first, then writes using them. Ordinary search hunts for matching words; this hunts for matching ideas, which is usually what you wanted.