How AI turns meaning into numbers.

A map analogy, a worked example you can run in any Python, and the pitfalls that trip up most first projects.

A nebula surrounded by stars in the night sky
Photo by Samuel PASTEUR-FOSSE on Unsplashdithered by Cyborb

An embedding is a list of numbers that stands for the meaning of a piece of text, or of an image or a sound. Texts that mean similar things get similar numbers, so software can find related content by measuring how close two lists are. That one trick powers semantic search, RAG, recommendations and clustering.

You do not need math to understand what embeddings are or to use them well. You need a good mental picture, a feel for how the search works, and a short list of mistakes to avoid. This guide gives you all three, plus a tiny example you can run yourself.

The short version
  • An embedding turns text into a long list of numbers, like coordinates on a map of meaning.
  • Similar meanings land close together, so “I can’t log in” can find “Reset your password” without sharing a word.
  • Embeddings power semantic search, RAG, recommendations, deduplication and clustering.
  • As of September 2026, major embedding APIs cost $0.02 to $0.20 per million tokens, and strong open models cost nothing but hardware.
  • Pick one model and stick with it, because vectors from different models do not mix.

What are embeddings? Start with a map

A city’s position on a map takes two numbers, latitude and longitude. With those alone, you can tell that Paris is closer to Brussels than to Tokyo, without knowing anything else about the cities.

Embedding models do the same with meaning. They read a piece of text and place it on a map, except this map has hundreds or thousands of directions instead of two. OpenAI’s text-embedding-3-small returns 1,536 numbers per text, and its large sibling returns 3,072.

This map has two quirks. Its directions have no human labels: no single number means “about animals”, because meaning is spread across all of them. And closeness is usually measured by direction rather than distance, with cosine similarity. A score near 1 means two texts point the same way; a score near 0 means they are unrelated.

Language models use embeddings internally too. Every token becomes a vector before any processing happens, as our explainer on how LLMs work shows.

A tiny worked example you can run

Real embeddings are too long to read, so here is a toy version with three hand-made numbers per text. Pretend the numbers mean “about accounts”, “about money” and “about delivery”. A user types “I can’t log in”, and we look for the closest help article.

similarity.py
import math

# Hand-made 3-number "embeddings". Pretend the numbers mean
# [about accounts, about money, about delivery].
docs = {
    "How to reset your password": [0.9, 0.1, 0.0],
    "Change the email on your account": [0.7, 0.3, 0.1],
    "Request a refund": [0.1, 0.9, 0.3],
    "Track your parcel": [0.0, 0.2, 0.9],
}
query = [0.8, 0.1, 0.1]  # "I can't log in"

def cosine(a, b):
    dot = sum(x * y for x, y in zip(a, b))
    length_a = math.sqrt(sum(x * x for x in a))
    length_b = math.sqrt(sum(y * y for y in b))
    return dot / (length_a * length_b)

ranked = sorted(docs, key=lambda title: cosine(query, docs[title]), reverse=True)
for title in ranked:
    print(f"{cosine(query, docs[title]):.2f}  {title}")

It needs no libraries. We ran it with Python 3.10 and 3.14 and got the same output:

Text
0.99  How to reset your password
0.96  Change the email on your account
0.26  Request a refund
0.15  Track your parcel

The query shares no words with “How to reset your password”, yet it ranks first because its numbers point the same way. That is semantic search in miniature. In a real system, an embedding model does the part we did by hand: it produces the numbers, having learned from huge amounts of text that logging in and passwords belong together.

How similarity search works

Every embedding search, from a help center to an agent’s memory, follows the same five steps:

  1. Split and embed your documents once

    Break long documents into passages of a few paragraphs, then send each passage to an embedding model. Many models accept up to about 8,000 tokens per input, and some take 32,000.

  2. Store the vectors

    Keep each vector next to its passage. A few thousand fit in a plain file or array; millions belong in a vector database.

  3. Embed the question

    When a query arrives, turn it into a vector with the same model.

  4. Find the nearest vectors

    Compare the query vector with the stored ones and keep the closest few. Vector databases use approximate search shortcuts, so this takes milliseconds even across millions of passages.

  5. Use the results

    Show them as search results, or hand them to a language model as context for its answer.

That last option is RAG, retrieval-augmented generation. Our RAG guide walks through the full pipeline, including reranking and citations.

What embeddings power

Once software can measure how alike two things are, a lot of features follow:

UseWhat the embeddings doExample
Semantic searchMatch a query to passages by meaning“Cancel my plan” finds a page titled “Ending your subscription”
RAGFetch the right passages for a model to answer fromA support bot quoting your real refund policy
RecommendationsFind items close to ones a person liked“Readers of this article also read”
ClusteringGroup texts by topic without labelsSorting 5,000 survey answers into themes
DeduplicationFlag near-identical itemsMerging duplicate bug reports
ClassificationCompare new items with labeled examplesRouting tickets to billing, tech or sales

Agents use the same trick for memory: they store notes as vectors and pull back the relevant ones later. Our guide to how AI agents remember covers that and the other kinds of memory they use.

Embedding models and prices in 2026

Embedding is cheap next to text generation: you pay only for input tokens, because the model reads but never writes. Prices below are per million input tokens, from each vendor’s page in September 2026.

ModelMakerPrice per 1M tokensVector sizeGood to know
text-embedding-3-smallOpenAI$0.021,536A dimensions setting shortens vectors
text-embedding-3-largeOpenAI$0.133,072Higher quality, bigger vectors
gemini-embedding-2Google$0.20 for text128 to 3,072Also embeds images, video, audio and PDFs
voyage-4-lite, voyage-4, voyage-4-largeVoyage AI$0.02, $0.06, $0.12256 to 2,048First 200 million tokens free; Anthropic’s docs point here
voyage-4-nanoVoyage AINo fee, you run it256 to 2,048Open weights, Apache 2.0
Qwen3-Embedding 0.6B, 4B, 8BQwen (Alibaba)No fee, you run itUp to 1,024, 2,560 or 4,096Open weights, Apache 2.0, 100+ languages

For scale, OpenAI estimates that text-embedding-3-small covers about 62,500 pages per dollar. At that rate, a 10,000-page knowledge base costs about 16 cents to embed once.

Which one to pick? For English text on a budget, text-embedding-3-small or voyage-4-lite is a sensible default. For images and audio in the same index, Gemini Embedding 2 puts them in one space. If data must stay on your own machines, run an open model such as Qwen3-Embedding. The public MTEB leaderboard compares quality across tasks, but your own test data has the final say.

Pitfalls that trip up first projects

Embeddings are easy to start with and easy to get subtly wrong. These mistakes are behind many disappointing results:

  • Mixing models. Vectors from different models live on different maps, so they cannot be compared. Google’s docs warn that moving from gemini-embedding-001 to gemini-embedding-2 means re-embedding everything. Voyage’s 4 series is a rare exception, with models that share one space.

  • Chunks that are too big or too small. A whole chapter in one vector blurs its topics together. A single sentence loses the context that gives it meaning.

  • Expecting exact matches. Product codes, error numbers and rare names are often better found by plain keyword search. Many good systems run both and merge the results.

  • Confusing similar with correct. Embeddings capture topic better than logic, so “flights that allow pets” and “flights that do not allow pets” can land close together.

  • Forgetting to re-embed. When a document changes, its old vector still describes the old text.

Before you ship an embedding feature0 of 6

FAQ

What is the difference between embeddings and tokens?

Tokens are the chunks text is split into. Embeddings are numbers that represent meaning. A language model turns each token into an embedding internally, while an embedding model turns a whole passage into one vector.

Do I need a vector database?

Not at first. A few thousand vectors fit in memory, and comparing a query with all of them is quick. Reach for a vector database, or a vector extension for the database you already use, once you have hundreds of thousands of items or need filtering at scale.

How many dimensions do I need?

Often fewer than the default. OpenAI reports that its large model, shortened to 256 numbers, still beat its older 1,536-number model on the MTEB benchmark. Start with the default, then test smaller sizes to save storage.

Can embeddings search images and audio too?

Yes, with a multimodal model. Google’s Gemini Embedding 2 maps text, images, video, audio and PDFs into one space, so a text query can find a matching photo.

Key takeaways
  • An embedding is a list of numbers that places meaning on a map.
  • Nearby vectors mean similar meaning, usually measured with cosine similarity.
  • Search, RAG, recommendations, clustering and agent memory all run on this idea.
  • Embedding is cheap. The real work is chunking well, testing on real queries and sticking to one model.

Next, put embeddings to work with RAG, or decide between fine-tuning, RAG and prompting.

Sources
  1. Vector embeddings, OpenAI, accessed September 2026
  2. API pricing, OpenAI, accessed September 2026
  3. Embeddings, Google AI for Developers, accessed September 2026
  4. Gemini Embedding 2 model, Google AI for Developers, April 2026
  5. Gemini Developer API pricing, Google AI for Developers, accessed September 2026
  6. Pricing, Voyage AI, August 2026
  7. Text embeddings, Voyage AI, accessed September 2026
  8. voyage-4-nano model card, Voyage AI, January 2026
  9. Qwen3-Embedding-0.6B model card, Qwen, June 2025
  10. Embeddings, Anthropic docs, accessed September 2026
  11. MTEB leaderboard, MTEB, accessed September 2026
  12. Text embeddings reveal (almost) as much as text, Morris et al., October 2023
cyborb.ai

Stop reading about it. Build it.

Describe what you want in plain words. Cyborb plans the work, writes and runs the code, makes the assets, and puts the result online.

Download Cyborb

Free to start. No card required.