A vector database stores embeddings, the number vectors that represent the meaning of text, images or audio, and retrieves the entries closest to a query. It ranks by similarity instead of by exact matches.
How does a vector database work?
The usual sequence has four steps. A model converts the data into vectors, and the database stores and indexes them. A user query is converted by the same model into a vector. The database then compares that vector with the stored ones using a similarity measure such as cosine similarity or Euclidean distance. It returns the nearest entries, ranked by similarity. Many systems store metadata next to each vector so results can also be filtered, for example by language or date.
Comparing a query with millions of vectors one by one would be slow, so these systems use approximate nearest neighbor (ANN) indexes. They trade a small loss in accuracy for speed. Traditional databases handle exact queries on structured rows and columns, while vector databases handle similarity queries on embeddings. Some established databases now also offer vector search as a feature.
What role does it play in RAG and AI search?
Vector databases are a common building block of retrieval-augmented generation (RAG). A system splits documents into passages, creates embeddings and stores them. For a question, it retrieves the closest passages and passes them to a language model as source material. For website owners this suggests that individual sections of a page can be retrievable on their own (assessment).
Example
A help center with 5,000 articles is split into passages and stored as vectors. The question “How do I change my shipping address?” also finds a section titled “Edit delivery details”, because both phrasings produce similar vectors. A plain keyword search could miss it.
FAQ
Is a vector database a SQL or NoSQL database? It is a separate category built for similarity search over vectors. Some SQL and NoSQL databases offer vector features, and dedicated products exist as well.
Does every AI application need one? No. Whether an existing database with vector support is enough depends on data volume and requirements.
Sources
- What is a vector database? - Google Cloudcloud.google.com
- What is a vector database? - lakeFS (secondary source)lakefs.io
- What is a vector embedding? - IBM Thinkibm.com
- What is vector search? - Elasticelastic.co
Last updated: