Embeddings and vector databases explained
Embeddings describe the meaning of text as a list of numbers, and vector databases find similar texts quickly. How search by meaning works and when you need it.
An embedding is a list of numbers that describes the meaning of a text. Texts with similar meaning get similar lists. A vector database stores such lists and quickly finds the entries closest to a query. Together they make search by meaning possible, so a question can find a passage even when it uses different words.
What is an embedding?
An embedding model turns a text into a vector, a list of often several hundred to a few thousand numbers. You can think of it as coordinates in a very high-dimensional space. Sentences with a similar sense lie close together there; sentences with different senses lie far apart.
Embeddings are computed by dedicated models, which differ from the chat and text-generation models described in tokens and context windows. It is important to use the same model for documents and queries, otherwise the vectors are not comparable.
What is a vector database for?
If you have many texts, such as thousands of document sections, you need to find the most similar ones for a query. Comparing every vector one by one becomes slow for large collections. A vector database builds special index structures so that similar vectors can be found quickly even in large sets.
It usually uses an approximate search: much faster, but in rare cases it returns a slightly less fitting hit than an exact comparison would.
How does this differ from keyword search?
Classic keyword search finds texts that contain the words you typed. It is exact and easy to follow, but misses hits that use other wording or synonyms. Search with embeddings finds such hits, but can fall short with proper names, article numbers or technical terms.
In practice the two are combined. A mixed search uses the strengths of both, and re-ordering the hits afterwards can improve quality further.
Do you need a separate database?
Often not. For small to medium amounts of data, common databases offer extensions for vector search, for example PostgreSQL with a suitable extension. That avoids an extra system to run and keeps data and vectors together. A specialized vector database is worth considering only for very large collections or special demands on speed.
Where does this show up?
This is the basis of RAG, where matching passages are found by meaning and handed to a language model. It matters whenever a search or an AI assistant should find content by meaning, for example in manuals, offers or support documents.
Frequently asked questions
What is an embedding?
An embedding is a list of numbers that describes the meaning of a text. Similar texts have similar lists.
What is a vector database for?
It quickly finds the texts with the most similar meaning to a query, even in very large collections.
Does vector search always find the right thing?
No. It can miss with proper names or numbers and returns approximate hits. That is why it is often combined with keyword search.
Do I need a separate database for this?
Often not. For small amounts of data, an existing database with a vector search extension is enough.
Let us talk about your project
Write to kontakt@phronox.de or use the contact form.
Request a project Book a consultation