ElemedexA pocket encyclopedia of AI architectures

Glossary (TM) › Use: prompts, sampling, systems

TM165

Vector database

Also: vector store, vector index

In Spanish: Base de datos vectorial

A system that stores texts or other objects as vectors (embeddings) and quickly retrieves those most similar to a query, rather than those satisfying an exact condition.

To search by meaning rather than by keywords, documents are first split into chunks and each chunk is turned into an embedding: a point in a high-dimensional space where texts with similar meanings lie close together. These vectors are stored in an index. When a query arrives, it is turned into a vector with the same model and its nearest neighbors are retrieved, for instance by cosine similarity (Alammar & Grootendorst, 2024, pp. 228–230).

With thousands of vectors, computing every distance is enough. With millions, one uses approximate nearest-neighbor libraries such as Annoy or FAISS, which return results in milliseconds at the price of not guaranteeing the exact nearest neighbor. Vector databases proper (Weaviate, Pinecone and others) add what one expects from a database: adding and deleting vectors without rebuilding the index, and filtering by other criteria (Alammar & Grootendorst, 2024, pp. 238–239). The original RAG system used a FAISS index over 21 million Wikipedia passages (P. Lewis et al., 2020, sec. 3). Today they are the standard infrastructure for retrieval augmentation and semantic search, with models such as Sentence-BERT producing the vectors.

For a logician, the contrast with a classical database is instructive. An SQL query is, at bottom, a first-order formula: it returns exactly the rows that satisfy it, and the answer is true or false for each one. A vector query has no truth conditions: it returns what is most similar, it always returns something, and "similar" is defined by the geometry a model has learned. It is a theory of meaning as position and distance (distributional hypothesis), with the virtues and risks of similarity: two texts can be close because they say the same thing or because they say opposite things about the same topic.

Sources

  • Alammar, J., & Grootendorst, M. (2024). Hands-on large language models: Language understanding and generation. O’Reilly Media. §
  • Lewis, P., Perez, E., Piktus, A., Petroni, F., Karpukhin, V., Goyal, N., Küttler, H., Lewis, M., Yih, W.-T., Rocktäschel, T., Riedel, S., & Kiela, D. (2020). Retrieval-augmented generation for knowledge-intensive NLP tasks. In Advances in Neural Information Processing Systems (Vol. 33, pp. 9459–9474). Curran Associates. https://proceedings.neurips.cc/paper_files/paper/2020/hash/6b493230205f780e1bc26945df7481e5-Abstract.html §