A Vector Database is a database designed to store and search embeddings (vectors) efficiently.
After converting data such as text or images into vectors, we need to store them so we can search and use them later.
For example:
"pink windbreaker" → [0.12, -0.45, 0.78, ...]
A Vector Database stores this vector together with the original data and related information.
Suppose we have 10,000 vectors and want to find the one most similar to a query.
The simplest approach would be:
for vector in database:calculate_similarity(query, vector)
This means comparing the query with all 10,000 vectors.
As the number of vectors grows to millions, this becomes slow and expensive.
Vector Databases use indexes and algorithms such as ANN (Approximate Nearest Neighbor) to find similar vectors much faster, without comparing against every vector.
For example:
results = collection.query(query_texts=["pink windbreaker"],n_results=2)
The database returns the most relevant results based on vector similarity.
Most applications of Vector Databases are related to searching by meaning rather than exact keywords.
Common examples include:
In modern LLM applications, a Vector Database often works as an external knowledge store, allowing the LLM to retrieve information when needed.
Some popular options include:
You do not always need a dedicated Vector Database. For smaller datasets, you can store vectors in memory or use an existing database such as PostgreSQL with pgvector.