An embedding in AI is a numerical vector, or list of floating-point numbers, that represents text or other data in a mathematical space where similar meanings sit close together. Machine learning models use vector embeddings to measure relatedness between concepts, power semantic search, and retrieve relevant context in RAG systems.
When I explain embeddings to engineers building their first search pipeline, I ask them to picture a map where topics replace geography. Keyword matching checks whether two strings share exact letters, which fails when one document says canine and another says puppy. A vector embedding solves that gap by turning meaning into coordinates so software can compare ideas with basic geometry.
How does a vector embedding represent meaning?
A vector embedding represents meaning by converting complex inputs such as words, phrases, or images into coordinates inside a multi-dimensional embedding space. According to the Stanford HAI AI definitions glossary, embeddings place similar items close together in mathematical space, so words like dog and puppy receive nearby vectors while dog and toast end up far apart.
In OpenAI’s embeddings guide, an embedding is defined as a vector of floating-point numbers whose distance measures the relatedness of text strings. Small distances between two vectors signal high relatedness, while large distances signal low relatedness. IBM Think frames the same principle across data types: vector embeddings turn nonmathematical inputs like text or images into numeric arrays that machine learning models can process, ensuring that more similar real-world items receive more similar vectors.
Google’s Machine Learning Crash Course adds three practical properties of embedding spaces that shape how engineers work with them:
- Lower-dimensional projection: Models often project high-dimensional raw inputs into a denser, lower-dimensional embedding space where distance can be calculated mathematically as relative similarity.
- Opaque individual coordinates: Individual dimensions inside a learned embedding are rarely interpretable as clean, hand-labeled concepts. Meaning lives in the combined position and direction across all numbers in the array.
- Task specificity: Embeddings are usually trained for specific tasks, which means a vector space optimized for semantic text retrieval differs from one trained for product recommendations.
Because vectors encode relatedness rather than exact spelling, OpenAI lists six common production tasks for embeddings: search (ranking results by query relevance), clustering, recommendations, anomaly detection, diversity measurement, and classification (assigning a string to its closest label).
Word, sentence, and document embeddings explained
Word, sentence, and document embeddings differ in how much text a model compresses into a single vector. Choosing the right granularity determines whether your system tracks individual terms, short user queries, or multi-paragraph passages.
Word embeddings
A word embedding is a dense vector assigned to a single word or AI token. Static word embeddings such as word2vec, introduced by Tomas Mikolov and colleagues in 2013, assign one fixed global vector to each word in a vocabulary. As Google’s Machine Learning Crash Course explains, models trained to predict a word’s surrounding context assume that words appearing in similar contexts carry related meanings.
Static word embeddings have a well-known limitation: a single vector must represent every sense of a word at once, such as bank as a financial institution and bank as a river edge. Google also notes, citing François Chollet’s Deep Learning with Python, that static word embeddings commonly used dimension counts such as 256, 512, or 1024.
Sentence embeddings
A sentence embedding maps an entire phrase or sentence into one vector instead of producing separate vectors for every word. IBM notes that sentence embeddings capture the combined semantic meaning of a full phrase and are commonly used to encode user queries in search and question-answering workflows. Encoding the full sentence helps distinguish between strings that share identical words in different orders.
Document embeddings
A document embedding represents a longer passage, article section, or full document chunk as one vector. A simple baseline approach combines word vectors by averaging them together, though that method often loses structure and nuance. Purpose-built text embedding models encode the entire passage in one step. In real retrieval systems, teams rarely compress an entire book into one vector; instead, they split long files into smaller chunks and generate one embedding per chunk.
| Embedding type | Input granularity | Typical vector unit | Primary role and limitation |
|---|---|---|---|
| Word embedding | Single word or token | One vector per vocabulary item | Captures term similarity; static models like word2vec merge all word senses into one vector |
| Sentence embedding | Phrase or single sentence | One vector per query or line | Captures phrase-level intent; commonly used for search queries and question answering |
| Document embedding | Passage or document chunk | One vector per chunk or document | Supports corpus retrieval; long documents usually need chunking before embedding |
What do embedding dimensions mean?
Embedding dimensions measure the length of a vector, meaning how many floating-point numbers a model outputs for each input. Larger vectors carry more capacity to encode subtle semantic distinctions, while smaller vectors reduce memory usage, index size, and comparison compute.
OpenAI’s third-generation embedding models illustrate this tradeoff directly. As of November 14, 2026, OpenAI’s official documentation sets default output lengths at 1536 dimensions for text-embedding-3-small and 3072 dimensions for text-embedding-3-large. Both models accept an optional dimensions parameter in the API request, allowing developers to request a shorter vector without losing the embedding’s concept-representing properties.
OpenAI trained both third-generation models so trailing numbers can be removed cleanly. According to OpenAI’s embeddings guide as of November 14, 2026, shortening text-embedding-3-large down to 256 dimensions still outperforms an unshortened 1536-dimension text-embedding-ada-002 embedding on the MTEB benchmark. If a vector database enforces a hard ceiling of 1024 dimensions, OpenAI notes that developers can still call text-embedding-3-large with dimensions set to 1024, trading a small amount of accuracy for compatibility and smaller storage footprints.
Developers who shorten vectors manually after receiving them from an API must apply L2 length normalization afterward. Passing the dimensions parameter directly when creating the embedding avoids manual post-processing and is OpenAI’s recommended workflow.
How does cosine similarity compare embeddings?
Cosine similarity compares two embedding vectors by measuring the cosine of the angle between them. Because cosine similarity evaluates orientation in embedding space rather than raw vector magnitude, two passages pointing in the same semantic direction score high even if their lengths differ.
For general vectors, cosine similarity ranges from -1 to 1:
- 1: Both vectors point in the exact same direction, indicating maximum similarity.
- 0: Both vectors are orthogonal, indicating uncorrelated meanings.
- -1: Both vectors point in opposite directions.
Euclidean distance offers an alternative metric by measuring the straight-line distance between two points in embedding space. When developers ask which distance function to pick, OpenAI’s embeddings FAQ explicitly recommends cosine similarity while noting that the choice of metric typically makes little difference on OpenAI vectors. Every embedding returned by OpenAI’s API is already normalized to a length of 1, which means cosine similarity equals the dot product, and cosine similarity and Euclidean distance produce identical search rankings.
How are embeddings used in RAG?
Embeddings power retrieval-augmented generation (RAG) by matching a user’s question against stored document chunks before a language model writes an answer. Instead of relying solely on facts memorized during pretraining, a RAG pipeline searches private or up-to-date text collections using vector similarity.
Consistent with OpenAI’s question-answering and text search guidance, a standard RAG pipeline follows five steps:
- Chunk the corpus: Split long source documents into smaller passages so each vector represents a focused idea. Specific splitting strategies are covered in our guide on how to chunk documents for RAG.
- Embed and index chunks: Send each chunk to an embedding model and store the resulting vectors alongside their source text. OpenAI recommends storing vectors in a vector database when searching quickly across large collections.
- Embed the user query: Pass the incoming question through the exact same embedding model so the query lands in the same mathematical space as the indexed chunks.
- Retrieve nearest neighbors: Compute similarity scores, such as cosine similarity or dot product on normalized vectors, and fetch the top matching chunks.
- Pass context to the model: Insert the retrieved text chunks into the language model’s prompt so it can generate a grounded answer from your source material.
Chunk size and retrieval thresholds vary widely depending on document structure and query patterns, so teams should test splitting strategies against their actual corpus rather than relying on a single universal chunk size.
OpenAI embedding models, limits, and pricing
OpenAI’s embedding API provides three main text models with fixed token limits and per-token pricing as of November 14, 2026. Developers generate vectors by sending a POST https://api.openai.com/v1/embeddings request containing input and model, with optional dimensions (on third-generation models) and encoding_format (float by default, or base64).
All three listed OpenAI embedding models share the same request limits: a maximum of 8,192 tokens per single input, up to 2,048 items per input array, and at most 300,000 total tokens summed across all inputs in one API call. Empty strings are rejected. To count tokens locally before sending requests, OpenAI advises using the cl100k_base encoding with tiktoken. All three models also support OpenAI’s Batch API.
| Model | Default dimensions | Max input tokens | Price per 1M tokens (Nov 14, 2026) | Approx. pages per dollar (~800 tokens/page) | OpenAI-published MTEB score |
|---|---|---|---|---|---|
text-embedding-3-small |
1536 | 8,192 | $0.02 | 62,500 | 62.3% |
text-embedding-3-large |
3072 | 8,192 | $0.13 | 9,615 | 64.6% |
text-embedding-ada-002 |
1536 | 8,192 | $0.10 | 12,500 | 61.0% |
These figures come directly from OpenAI’s pricing page and embeddings guide as of November 14, 2026. OpenAI describes text-embedding-3-small as an improved successor to text-embedding-ada-002 and positions text-embedding-3-large as its most capable model for both English and non-English tasks. Treat the MTEB percentages above strictly as OpenAI’s own published documentation benchmarks as of this date, not as a live, independent industry-wide ranking across every embedding provider.
FAQ
What is the difference between a vector embedding and a token?
A token is a chunk of input text, such as a word or subword, that a model reads and bills against. A vector embedding is the dense array of floating-point numbers the model outputs to represent the meaning of one or more tokens. You can pass up to 8,192 tokens into an OpenAI embedding model to receive one vector.
Does OpenAI’s dimensions parameter reduce embedding accuracy?
Shortening a vector with the dimensions parameter trades a small amount of accuracy for lower storage and compute costs. OpenAI states that its third-generation models were trained so trailing numbers can be dropped while preserving concept representation. As of November 14, 2026, OpenAI reports that a 256-dimension text-embedding-3-large vector still beats an unshortened 1536-dimension text-embedding-ada-002 vector on MTEB.
Should I use cosine similarity or Euclidean distance for OpenAI embeddings?
Cosine similarity is OpenAI’s recommended metric, though both functions give identical rankings on OpenAI vectors. Because OpenAI embeddings are normalized to a length of 1, cosine similarity is mathematically equivalent to taking the dot product, and Euclidean distance preserves the exact same ordering. For general unnormalized vectors from other sources, cosine similarity isolates angle instead of magnitude.
Do embedding models know about recent events?
OpenAI’s third-generation embedding models, text-embedding-3-small and text-embedding-3-large, lack knowledge of events that occurred after September 2021. OpenAI notes in its embeddings FAQ that this knowledge cutoff is generally less limiting for embeddings than for text generation models, though certain domain-specific or post-cutoff queries can still see reduced matching quality.
Who owns the embeddings generated through the OpenAI API?
Customers own both the inputs they send and the output vectors generated by OpenAI models, including embeddings, according to OpenAI’s official FAQ. OpenAI states that ownership applies across its embedding endpoints while users remain responsible for ensuring their use of the API complies with applicable law.



