What Is a Vector Database?

A vector database stores text, images and other data as embeddings — lists of numbers that capture meaning — so you can search by meaning instead of exact words. It is the memory behind RAG apps and AI agents. Here is how it works, when you need one, the popular options, and a tested Python example.

By Abdul Rahman Azam, founder of AI Season · Updated

Learn RAG live →

Key facts

What it stores Embeddings (vectors) plus the original content and metadata
What it does Finds the most similar items to a query — semantic search
Used for RAG, AI agent memory, recommendations, duplicate detection
Popular options Chroma, Pinecone, Qdrant, Weaviate, Milvus, pgvector
Example Chroma in Python — runs locally, no account needed

What is a vector database?

A normal database finds rows that match exact values. A vector database finds items that are *similar in meaning*. It does this by storing an embedding for each item — a vector of hundreds or thousands of numbers produced by an embedding model — and comparing vectors to find the nearest ones to your query.

That is why a search for "When is the test?" can find a note that says "The midterm exam is on 14 November" even though they share no words: their embeddings are close together.

How it works

  1. Embed — each document or chunk is turned into a vector by an embedding model.
  2. Store — the vector is saved with the original text and metadata such as source, date or topic.
  3. Index — the database builds an approximate-nearest-neighbour index so search stays fast across millions of vectors.
  4. Query — your question is embedded with the same model, and the database returns the closest vectors, usually by cosine similarity or distance.
  5. Filter — metadata filters narrow results, for example to one course or one user.

Try it: a vector database in Python

Chroma is an open-source vector database that runs inside your Python program, so it is ideal for learning. Install it with pip install chromadb; on first run it downloads a small default embedding model.

import chromadb

client = chromadb.Client()  # in memory; chromadb.PersistentClient(path="db") saves to disk
notes = client.create_collection("uni_notes")

notes.add(
    ids=["n1", "n2", "n3", "n4"],
    documents=[
        "The midterm exam is on 14 November in Hall B.",
        "Library hours are 8 am to 10 pm on weekdays.",
        "Hostel fees must be paid before the semester starts.",
        "The AI society meets every Thursday after classes.",
    ],
    metadatas=[{"topic": "exams"}, {"topic": "library"}, {"topic": "fees"}, {"topic": "societies"}],
)

results = notes.query(query_texts=["When is the test?"], n_results=2)
for doc, distance in zip(results["documents"][0], results["distances"][0]):
    print(f"{distance:.3f}  {doc}")
Tested with chromadb 1.5. A smaller distance means a closer match.
0.866  The midterm exam is on 14 November in Hall B.
1.425  Library hours are 8 am to 10 pm on weekdays.
Output — the exam note ranks first although it never uses the word "test".

Vector databases in RAG and AI agents

In RAG, you chunk your documents, store their embeddings, and at question time retrieve the most relevant chunks and give them to the LLM with an instruction to answer only from them and cite them. That is how chatbots answer from a university handbook or company policy instead of guessing. The full pipeline is in RAG for AI agents.

In AI agents, a vector database can also serve as long-term memory — past conversations or user preferences retrieved when relevant. If LLMs themselves are new to you, start with what an LLM is.

Learn RAG and vector databases live

The AI Season bootcamp teaches embeddings, vector databases and RAG as part of building real AI agents — 12 live sessions over 6 weeks, explained in Urdu, coded in English. Cohort 02 starts 1st January 2027.

Frequently asked questions

What is a vector database in simple words?

A database that stores the meaning of text or images as lists of numbers, so it can find items that are similar in meaning to your search, not just items with the same words.

Why do LLM apps need a vector database?

LLMs do not know your private or recent documents. A vector database finds the relevant passages quickly so they can be given to the model, which lets it answer accurately and cite sources.

Which vector database is best for beginners?

Chroma, because it runs inside Python with no account or server. pgvector is a good next step if you already use PostgreSQL.

Is FAISS a vector database?

FAISS is a similarity-search library rather than a full database: it indexes and searches vectors very fast, but storage, metadata and updates are up to you.

What is an embedding?

A list of numbers produced by an embedding model that represents the meaning of a piece of content. Similar meanings produce vectors that are close together.