Vector Database
What is a vector database?
A vector database is a database designed to store, index and search vectors: long lists of numbers that represent the meaning of a piece of content such as a text, an image or a product. These vectors are called embeddings. Instead of looking for exact matches on keywords, a vector database finds the items whose vectors are closest to the vector of a query, which means the items closest in meaning.
This capability is the foundation of semantic search, recommendation engines and retrieval-augmented generation (RAG), where an AI model answers using documents retrieved from your own data.
How does a vector database work?
The process has three steps. First, an embedding model converts each document into a vector. Second, the database stores these vectors with an index and optional metadata. Third, at query time, the question is converted into a vector and the database returns the nearest neighbors.
query_vector = embed('How do I reset my password?')
results = index.search(query_vector, top_k=3, filter={'lang': 'en'})Closeness is measured with a similarity metric such as cosine similarity, dot product or Euclidean distance. To stay fast on millions of vectors, most systems use approximate nearest neighbor (ANN) indexes such as HNSW, which trade a small loss of accuracy for a large gain in speed.
Vector database vs relational database
| Criterion | Relational database (SQL) | Vector database |
|---|---|---|
| Stored data | Structured rows and columns | Embeddings plus metadata |
| Query type | Exact match, filters, joins | Similarity search by meaning |
| Result | Deterministic | Ranked by similarity score |
| Typical use | Transactions, accounts, orders | Semantic search, RAG, recommendations |
The two are complementary. Some relational databases, such as PostgreSQL with the pgvector extension, can also store vectors, which lets you keep both kinds of data in one place.
Common use cases
- Semantic search: find answers even when the words differ from the query.
- RAG: give a large language model relevant passages from your documents.
- Recommendations: suggest similar products, articles or contacts.
- Deduplication: detect near-identical content.
- AI agent memory: let an agent recall earlier information.
Best practices and pitfalls
- Use the same embedding model for indexing and for queries, otherwise results are meaningless.
- Split long documents into chunks of a sensible size before embedding them.
- Store metadata (language, date, source) and filter on it to improve precision.
- Combine vector search with keyword search (hybrid search) for exact terms such as product codes.
- Re-embed your content when you change the embedding model.
Vector database at BeBranded
At BeBranded, we use vector databases to build AI assistants and internal search tools that answer from a company's own documents. We connect them to your existing tools and workflows as part of our automation service.
