Embeddings are lists of numbers that represent the meaning of a piece of text (or an image), placed so that similar meanings end up close together. This guide explains how they work without math, what they are used for, how to pick an embedding model and how to compute similarity in a short Python example.
- An embedding turns text into a vector, a list of a few hundred to a few thousand numbers, where nearby vectors mean similar things.
- Similarity search compares vectors, usually with cosine similarity, so a query finds relevant text even when no words match.
- Embeddings power semantic search, retrieval augmented generation (RAG), recommendations, clustering, deduplication and classification.
- Always embed queries and documents with the same model, and re-embed everything when you switch models.
- Combine embeddings with keyword search for names, codes and exact phrases, which pure vector search can miss.
What are embeddings?
Embeddings are numerical representations of meaning. An embedding model reads a piece of text and outputs a vector, a fixed-length list of numbers such as 384 or 1,536 values, positioned so that texts with similar meanings get similar vectors. "How do I reset my password?" and "I forgot my login" end up close together even though they share no words.
A helpful picture is a map. On a city map, two cafes on the same street have similar coordinates. An embedding is a coordinate in a "meaning space" with hundreds of dimensions instead of two. You cannot picture 1,536 dimensions, but the rule is the same: close together means related, far apart means unrelated.
That single property makes embeddings useful far beyond chat:
- Find documents that answer a question, even when the wording differs.
- Group thousands of support tickets by topic without reading them.
- Recommend articles similar to the one someone just read.
- Spot duplicates and near-duplicates in a catalog.
Anthropic's embeddings guide describes them as numerical representations of text that enable measuring semantic similarity.
How do embedding models create vectors?
An embedding model is a neural network trained so that related texts produce nearby vectors and unrelated texts produce distant ones. During training it sees huge numbers of pairs (a question and its answer, a title and its article, two paraphrases) and adjusts itself until matching pairs land close together.
The result is a model that captures meaning rather than spelling:
| Text A | Text B | Shared words | Embeddings close? |
|---|---|---|---|
| "cheap flights to Rome" | "low-cost airfare to Italy's capital" | None | Yes |
| "Python list sorting" | "how to order an array in Python" | "Python" | Yes |
| "Apple stock price" | "apple pie recipe" | "apple" | No |
| "bank account fees" | "river bank erosion" | "bank" | No |
Keyword search gets the last two rows wrong and misses the first one entirely. That is the main reason embeddings took over search and retrieval in AI applications.
Embeddings are not limited to text. Multimodal embedding models place images, and in some cases video, in the same space as text, so a written query such as "red running shoes on a white background" can find matching product photos. Anthropic's guide lists a Voyage multimodal model that embeds interleaved text, images and video. The same idea works for code: code-specific models put a function and a plain-English description of what it does close together, which some code search tools use to find relevant files in a large repository.
Each number in a vector does not have a human-readable meaning on its own. Meaning lives in the overall position, which is why you compare whole vectors rather than reading individual dimensions. If you want the background on how language models represent text internally, our explainer on what a large language model is covers tokens and training without math.
How does similarity search work?
Similarity search embeds your query with the same model as your documents, then finds the document vectors closest to the query vector. Closeness is usually measured with cosine similarity, which compares the direction of two vectors and returns a score where higher means more similar.
The three common measures:
| Measure | What it compares | Notes |
|---|---|---|
| Cosine similarity | Angle between vectors | The usual default |
| Dot product | Angle and length | Same ranking as cosine when vectors are normalized |
| Euclidean distance | Straight-line distance | Same ranking as cosine for normalized vectors |
Many providers normalize their vectors to length 1, which makes these measures interchangeable for ranking. OpenAI's embeddings guide recommends cosine similarity and notes its embeddings are normalized to length 1, so a dot product gives the same result faster. Anthropic's guide says the same of Voyage AI embeddings.
A typical search flow:
- Index once: split your documents into chunks, embed each chunk and store the vectors with the original text.
- Query: embed the user's question.
- Compare: compute similarity between the query vector and every stored vector (or let an index find the nearest ones).
- Return the top results, usually 3 to 20 chunks.
For a few thousand chunks, comparing against every vector in memory takes milliseconds. Beyond that, an approximate nearest neighbor index in a vector database keeps search fast. Our guide to vector databases covers when Postgres with pgvector is enough and when a dedicated store helps.
What are embeddings used for?
Embeddings are used wherever you need to compare meaning at scale. The most common use today is retrieval for AI assistants, but they were powering search and recommendations long before chatbots.
| Use case | How embeddings help | Example |
|---|---|---|
| Semantic search | Match queries to content by meaning | Help center search that understands paraphrases |
| RAG | Fetch relevant passages to give an LLM | A chatbot that answers from your docs |
| Recommendations | Find items similar to ones a user liked | "Related articles" |
| Clustering | Group similar texts automatically | Topic analysis of survey answers |
| Deduplication | Flag near-identical entries | Merging duplicate product listings |
| Classification | Label text by nearest examples | Routing tickets to the right team |
| Anomaly detection | Find items far from everything else | Unusual log messages |
OpenAI's guide lists search, clustering, recommendations, anomaly detection, diversity measurement and classification as the main uses.
Retrieval augmented generation is the use most people meet first: embed your documents, retrieve the passages closest to a question and hand them to a language model to answer from. Our RAG guide builds a minimal working example, and the fine-tuning vs RAG comparison explains why retrieval is usually the first thing to try when a model needs your data.
A tiny embeddings example in Python
You can try embeddings locally in about 20 lines, with no API key, using the open-source Sentence Transformers library and the small all-MiniLM-L6-v2 model, which produces 384-dimensional vectors.
pip install sentence-transformersfrom sentence_transformers import SentenceTransformermodel = SentenceTransformer("sentence-transformers/all-MiniLM-L6-v2")docs = [ "To reset your password, click 'Forgot password' on the login page.", "Invoices are emailed on the first business day of each month.", "You can export any report as CSV from the Reports page.", "Our office is closed on public holidays.",]doc_vectors = model.encode(docs)print(doc_vectors.shape) # (4, 384)query = "I can't log in to my account"query_vector = model.encode([query])scores = model.similarity(query_vector, doc_vectors)[0]for score, doc in sorted(zip(scores.tolist(), docs), reverse=True): print(f"{score:.2f} {doc}")The password document should come out on top even though the query never uses the words "password" or "reset". The first run downloads the model once; after that, it runs on a laptop CPU.
To see what similarity does, here is cosine similarity by hand with NumPy:
import numpy as npdef cosine(a, b): return float(np.dot(a, b) / (np.linalg.norm(a) * np.linalg.norm(b)))print(cosine(query_vector[0], doc_vectors[0]))Swap in a hosted model when you need better quality, longer inputs or multilingual support. The structure of the code stays the same: embed documents once, embed each query, compare.
How do you choose an embedding model?
Choose an embedding model by testing a few candidates on your own data, starting from a widely used general model. Retrieval quality on your queries matters more than a leaderboard score, and the cost difference between models is often small next to the cost of the chat model that uses the results.
Some current options, with figures from each provider's documentation as of October 2026:
| Model | Provider | Default dimensions | Max input | Notes |
|---|---|---|---|---|
all-MiniLM-L6-v2 | Sentence Transformers (open source) | 384 | Short passages | Free, local, English-focused |
text-embedding-3-small | OpenAI | 1,536 | 8,192 tokens | Cheap general-purpose option |
text-embedding-3-large | OpenAI | 3,072 | 8,192 tokens | Higher quality, larger vectors |
voyage-4 | Voyage AI (MongoDB) | 1,024 | 32,000 tokens | Also 256, 512 or 2,048 dims |
voyage-code-4 | Voyage AI (MongoDB) | 1,024 | 32,000 tokens | Tuned for code retrieval |
Things to check before you commit:
- Domain. Code, legal and finance text can benefit from specialized models. Voyage lists models for code, law and finance.
- Languages. Use a multilingual model if queries and documents may be in different languages.
- Input length. Longer limits let you embed bigger chunks, though smaller chunks often retrieve more precisely.
- Dimensions. Several models let you request shorter vectors (OpenAI's
dimensionsparameter, Voyage'soutput_dimension) to save storage. - Query vs document mode. Some models embed questions and passages differently. Voyage's docs say to always set
input_typetoqueryordocumentfor retrieval.
What mistakes should you avoid with embeddings?
Most embedding problems come from mismatched models, poor chunking or expecting vector search to handle exact matches. These are the ones that cost teams the most time:
- Mixing models. Vectors from different models live in different spaces and cannot be compared. If you switch models, re-embed everything.
- Chunks that are too big or too small. A whole 30-page document in one vector blurs its meaning; a single sentence loses context. A few paragraphs per chunk, with some overlap, is a common starting point to test.
- Relying on vectors for exact terms. Product codes, error numbers and people's names are often better found with keyword search. Hybrid search (keyword plus vector, then merge the results) fixes most of these misses.
- No evaluation. Write 20 to 50 real queries with the documents that should come back, and measure how often they appear in the top results before and after any change.
- Ignoring updates. When source documents change, their stored vectors go stale. Re-embed changed documents as part of your update pipeline.
Store the model name and version next to every vector. When you upgrade models later, you will know exactly which records need re-embedding.
How to start using embeddings today
Get a feel for embeddings in an hour, then build from there:
- Run the Sentence Transformers example above with 20 to 50 of your own documents or FAQ entries.
- Write ten real questions and check whether the right document lands in the top three.
- Try one hosted model on the same test and compare.
- If results look good, store vectors in Postgres with pgvector or a vector database.
- Add keyword search alongside for names and codes.
- Feed the top results to a chat model and you have a basic RAG system.
For quick definitions of related terms such as chunking, reranking and vector index, see our AI glossary. And if you build this kind of pipeline with a coding agent and want it to keep working after you close your laptop, Orkio runs agents like Claude Code on an always-on cloud box.
Frequently asked questions
What is the difference between an embedding and a token?
A token is a piece of text, roughly a word fragment, that a model reads one at a time. An embedding is a vector of numbers representing meaning. Language models turn each token into an embedding internally, and embedding models produce one vector for a whole sentence or passage that you can store and compare.
Does Claude or ChatGPT have an embedding model?
OpenAI offers embedding models through its API, such as text-embedding-3-small and text-embedding-3-large. Anthropic does not offer its own embedding model; its documentation points to Voyage AI, now part of MongoDB, as one provider. You can use embeddings from any provider alongside any chat model.
How many dimensions should an embedding have?
Common models produce 384 to 3,072 dimensions. More dimensions can capture finer distinctions but cost more storage and slightly more compute per search. Several current models let you request shorter vectors, so you can test whether 256 or 512 dimensions keep enough quality for your data.
Are embeddings the same as a vector database?
No. Embeddings are the vectors themselves. A vector database stores them and finds the nearest ones quickly using an index. For small collections, a plain array in memory or the pgvector extension for Postgres is often enough.
Can embeddings work across languages?
Multilingual embedding models place sentences with the same meaning in different languages close together, so a Spanish query can find an English document. English-only models do not do this reliably, so check the model card if your content is multilingual.


