Using AI tools

Vector database

In short

A vector database is a database built to store embeddings, the lists of numbers AI models use to capture meaning, and to quickly find the stored items whose numbers sit closest to a query. Many chatbots use one to look up relevant documents.

Also called
Vector store, Vector DB, Vector database management system, VDBMS
Topic
Using AI tools
Level
Some background helps
First described
There is no single inventor. A key building block, the HNSW index for fast approximate nearest-neighbour search, was posted by Yury Malkov and Dmitry Yashunin in March 20163.

An embedding model turns a piece of text into a vector, which OpenAI describes simply as a list of floating point numbers1. Its text-embedding-3-small model, for example, produces 1,536 numbers per input by default1. Texts with similar meaning get vectors that sit close together: in OpenAI's words, "small distances suggest high relatedness"1.

A vector database stores those vectors and answers one main question: which stored vectors are nearest to this one? Comparing a query against every item gives exact results but slows down as a collection grows. So most systems add an index for approximate nearest-neighbour search, which, as the pgvector documentation puts it, "trades some recall for speed"2. Two common building blocks are the HNSW graph index3 and Faiss, a similarity search library developed mainly at Meta5. A 2017 paper on Faiss's GPU version reported building a graph linking one billion vectors in under 12 hours on four GPUs4.

Some products are built only for vectors, while others add vector search to an existing database6. pgvector, for instance, is an open-source extension that adds vector similarity search to PostgreSQL2.

A vector database is not a model and understands nothing. It measures distance between numbers, so the quality of its results depends on the embedding model that produced them. Researchers link the recent demand for these systems to large language models6, and OpenAI recommends one "for searching over many vectors quickly"1. The best-known use is retrieval-augmented generation, where a chatbot fetches relevant passages before it answers.

Example

A UK law firm turns every clause in its past contracts into embeddings and stores them in a vector database. When a solicitor searches for "early termination", the system can return clauses about "ending the agreement before the term expires", even though the words do not match.

Why it matters

It is the search engine behind many "chat with your documents" tools. When an AI answer quotes your company's files, a vector database is often what found them.

Questions people ask

Is a vector database the same as a normal database?

No. A normal database finds exact matches, such as a customer number. A vector database finds the nearest matches by meaning. The line is blurring, though: some ordinary databases now add vector search, such as PostgreSQL with the pgvector extension26.

Do I need a vector database for RAG?

Not always. For a small collection, comparing a query against every stored vector is quick enough and gives exact results2. OpenAI recommends a vector database when you need to search over many vectors quickly1.

What is the difference between a vector and an embedding?

A vector is any list of numbers. An embedding is a vector produced by a model so that the distance between two embeddings reflects how related the original texts are1.

Related terms

Tools that use it

Sources

  1. OpenAI API documentation, Vector embeddings guide
  2. pgvector: open-source vector similarity search for Postgres, README
  3. Malkov and Yashunin (2016), Efficient and robust approximate nearest neighbor search using Hierarchical Navigable Small World graphs, arXiv:1603.09320
  4. Johnson, Douze and Jégou (2017), Billion-scale similarity search with GPUs, arXiv:1702.08734
  5. Faiss repository, Meta Fundamental AI Research
  6. Pan, Wang and Li (2023), Survey of Vector Database Management Systems, arXiv:2310.14021

Back to the glossary