In this guide
An embedding is a list of numbers that represents the meaning of a piece of text, an image or other data, so that similar things end up with similar numbers. A vector database stores many embeddings and can quickly find the ones closest to a query. Together they let software search by meaning instead of exact words.
What is an embedding?
Computers handle numbers better than ideas. An embedding model, a type of neural network, reads a piece of text and outputs a long list of numbers called a vector. Real vectors have hundreds or thousands of values, but you can picture a simple version with two.
Imagine a map where each sentence is a point. "How do I reset my password?" and "I forgot my login details" would sit close together, because they mean nearly the same thing. "Best pasta recipe" would sit far away. The model learns to place points like this during training, so closeness on the map reflects closeness in meaning.
This differs from keyword search. A keyword search for "reset password" misses a page titled "Recover your account". An embedding search can find it, because the meanings are near.
How similarity is measured
Once text is turned into vectors, "how similar are these two?" becomes a maths question. Common measures include:
- Cosine similarity, which compares the direction of two vectors.
- Dot product, which is related and often used with normalised vectors.
- Euclidean distance, which measures straight-line distance.
You rarely calculate these yourself. Each gives a score for how related two pieces of content are.
Embeddings are also related to how models read text. Text is first split into tokens, and the model works from those pieces.
What is a vector database?
If you have a few hundred embeddings, you can compare your query against every one. With millions, that is too slow. A vector database is built to store embeddings alongside their original content and to run nearest-neighbour search quickly.
To do this at scale, many systems use approximate nearest-neighbour methods. They trade a small amount of accuracy for large gains in speed. They organise vectors so a search only checks a promising fraction of them.
Typical features include:
- Storing a vector plus metadata, such as title, date, author or access group.
- Filtering by metadata, for example "only documents from this year" or "only those this user may see".
- Updating and deleting entries as source documents change.
- Returning the top results with similarity scores.
Some general-purpose databases now offer vector search as a feature. Whether you need a dedicated product depends on scale and requirements. This area changes quickly, so check what current tools support.
How embeddings and vector databases are used
- Semantic search. Find help articles or documents by meaning.
- Retrieval for AI answers. Fetch relevant passages to feed a model, the core of RAG.
- Recommendations. Suggest items similar to ones a person liked.
- Duplicate detection and clustering. Spot near-identical tickets or group feedback into themes.
A simple search flow
- Split your documents into passages.
- Run each passage through an embedding model and store the vector with its text.
- When a user searches, embed the query with the same model.
- Ask the database for the nearest vectors.
- Show or use the matching passages.
A key rule: use the same embedding model for the documents and the queries. Vectors from different models are not comparable. If you change models, you must re-embed everything.
Limits and pitfalls
- Similar is not the same as correct. The closest passage may be related but not answer the question.
- Exact terms can be missed. Product codes, names and rare words often work better with keyword search. Many systems combine both.
- Chunk size matters. Passages that are too long blur several ideas. Passages that are too short lose context.
- Bias and gaps. Embedding models reflect their training data and may handle some languages or specialist fields less well. See AI bias and fairness.
- Privacy. Embeddings are derived from your content. Sending text to an external embedding service shares that text, so apply the same care as with any data, as covered in AI privacy and data security.
Do you need one?
If you only have a small set of documents, a simple search or even pasting text into the prompt may be enough. If you have a large, changing collection and users ask in varied wording, embeddings help. When deciding how to give a model your knowledge, RAG vs fine-tuning lays out the trade-offs.
The QAM.AI programme introduces these building blocks in short, text-first lessons, and you can sample the format with the free preview lessons.
Key takeaways
- An embedding is a vector of numbers that captures the meaning of content.
- Similar meanings produce nearby vectors, enabling search by meaning rather than keywords.
- A vector database stores embeddings and finds nearest matches quickly, often approximately.
- Use the same embedding model for stored content and queries.
- Combine with keyword search and test results, since closest does not always mean correct.
Frequently asked questions
Is an embedding the same as a token?
No. A token is a small piece of text that a model reads, such as a word or part of a word. An embedding is a numerical representation of meaning, and it can be produced for a token, a sentence or a whole document.
Can I use embeddings without a vector database?
Yes. For small collections you can store vectors in a file or ordinary database and compare them directly. A dedicated vector index becomes useful when the collection is large or search speed matters.
Do embeddings understand language like a person does?
Not in a human sense. They capture statistical patterns of how words and ideas appear together, which is often good enough to find related content. They can still miss subtle differences, such as negation or context.
This guide is general educational information and is reviewed periodically. AI tools change quickly, so check each vendor's current documentation before relying on specific features or limits.