# What are vector embeddings?

> A vector embedding is a list of numbers that represents the meaning of text. OpenAI's text-embedding-3-large returns 3,072 of them by default.

Canonical: https://promptlyfound.com/llms/embeddings
Updated: 2026-11-20

## Short answer

A vector embedding is **a list of numbers that an embedding model produces to represent the meaning** of a text, image or other input. Inputs with similar meanings get vectors that are close together. Retrieval systems embed every passage and each query, then return the passages whose vectors are closest to the query, usually measured by cosine similarity.

## Key findings

- OpenAI's text-embedding-3-small returns 1,536 numbers per embedding by default, and text-embedding-3-large returns 3,072. A dimensions parameter shortens both. [1]
- OpenAI recommends cosine similarity. Its embeddings are normalized to length 1, so cosine similarity and Euclidean distance give identical rankings. [1]
- Google's gemini-embedding-001 scored 68.17 on the MTEB benchmark at 1,536 dimensions and 67.99 at 768 dimensions. [4]
- A retriever that used only embeddings outperformed a Lucene BM25 keyword system by 9 to 19 percentage points in top-20 passage retrieval accuracy. [9]
- The number of distinct top-k result sets that single-vector embeddings can return is limited by their dimension, and state-of-the-art models failed a simple dataset built to test this. [12]

Embeddings are how many AI retrieval systems match a question to your passages by meaning. Microsoft said in 2019 that Bing had turned more than 150 billion pieces of indexed data into vectors for web results. A vector embedding is a list of numbers that represents the meaning of an input, such as a sentence, a passage or an image. An embedding model produces it. Inputs with similar meanings get vectors that are close together, so software can compare meanings by comparing numbers. [OpenAI's embeddings guide](https://developers.openai.com/api/docs/guides/embeddings) lists search, clustering, recommendations, anomaly detection and classification as uses.[1] Retrieval for AI answers depends on the first of these, [semantic search](https://promptlyfound.com/ai-search/semantic-search).

## How models produce embeddings

Embedding models read a page in passages of limited length, so a long page is matched passage by passage. Early embeddings represented single words. The 2013 paper [Efficient Estimation of Word Representations in Vector Space](https://arxiv.org/abs/1301.3781) proposed two model architectures that learn a vector for each word from a large body of text. The authors trained vectors on a dataset of 1.6 billion words in less than a day.[2]

Search needs a vector for a whole query or passage. A Transformer model such as BERT can judge whether two sentences mean the same thing, but it has to read both sentences together. The [Sentence-BERT paper](https://arxiv.org/abs/1908.10084) calculated that finding the most similar pair among 10,000 sentences this way takes about 50 million model runs, or about 65 hours. Sentence-BERT changed BERT to output one embedding per sentence, which can be compared with cosine similarity. The same search took about 5 seconds.[3]

Embedding APIs from OpenAI, Google and Cohere work the same way. An application sends text to the model and gets a vector back. Each model has an input limit, measured in [tokens](https://promptlyfound.com/llms/tokens):

- OpenAI's text-embedding-3 models accept up to 8,192 tokens.[1]
- [Google's Gemini embeddings documentation](https://ai.google.dev/gemini-api/docs/embeddings) gives 8,192 tokens for gemini-embedding-2 and 2,048 for gemini-embedding-001. The page says gemini-embedding-2 silently truncates input over its limit.[4]

A long page has to be split into passages before it is embedded. The step is called chunking. [How retrieval-augmented generation works](https://promptlyfound.com/ai-search/rag) describes where chunking fits in a retrieval pipeline.

## Dimensions

For a team building its own retrieval, vector length trades storage and speed against quality. Each number in an embedding is one dimension. Providers set a default length and let developers request shorter vectors.

  <thead><tr><th scope="col">Model</th><th scope="col">Default dimensions</th><th scope="col">Shorter sizes</th><th scope="col">Max input (tokens)</th></tr></thead>
  <tbody>
    <tr><th scope="row">OpenAI text-embedding-3-small</th><td>1,536</td><td>Shorter sizes, with the dimensions parameter</td><td>8,192</td></tr>
    <tr><th scope="row">OpenAI text-embedding-3-large</th><td>3,072</td><td>Shorter sizes, with the dimensions parameter</td><td>8,192</td></tr>
    <tr><th scope="row">Google gemini-embedding-001</th><td>3,072</td><td>128 to 3,072</td><td>2,048</td></tr>
    <tr><th scope="row">Google gemini-embedding-2</th><td>3,072</td><td>128 to 3,072</td><td>8,192</td></tr>
    <tr><th scope="row">Cohere embed-v5.0-pro</th><td>Not stated</td><td>256, 512, 768, 1,024, 1,536 or 2,048</td><td>Not stated</td></tr>
  </tbody>

Shorter vectors take less storage and compare faster, but they lose some quality. OpenAI says a text-embedding-3-large vector shortened to 256 numbers still outperformed a full 1,536-number vector from its older text-embedding-ada-002 on the MTEB benchmark.[1] Google publishes MTEB scores for gemini-embedding-001 at each size: 68.17 at 1,536 dimensions, 67.99 at 768 and 63.31 at 128.[4] Google says both of its models are trained with Matryoshka Representation Learning, which makes the first part of a vector a usable shorter version of the whole.[4]

Precision is a second way to save space. [Cohere's embeddings documentation](https://docs.cohere.com/docs/embeddings) offers float, int8, uint8, binary and ubinary outputs. A binary embedding of 1,024 dimensions takes 128 bytes.[5]

## Similarity measures

For normalized embeddings such as OpenAI's, the choice of similarity measure matters less than using the same model for queries and documents. Retrieval compares a query vector with stored vectors and ranks them by similarity. [Microsoft's documentation of vector relevance in Azure AI Search](https://learn.microsoft.com/en-us/azure/search/vector-search-ranking) describes three common measures:[6]

- Cosine similarity measures the angle between two vectors and ignores their lengths.
- Dot product measures both the lengths and the angle. For vectors normalized to length 1, it gives the same result as cosine similarity and is slightly faster.
- Euclidean distance measures the length of the difference between two vectors.

Google's page says cosine similarity values range from -1, for opposite meanings, to 1, for the greatest similarity.[4] OpenAI recommends cosine similarity and says the choice of distance function typically does not matter much, because its embeddings are normalized to length 1, so cosine similarity and Euclidean distance produce identical rankings.[1] A vector shortened by hand has to be normalized again. Gemini-embedding-2 does this automatically for shorter sizes, and gemini-embedding-001 does not.[4]

The query and the documents must be embedded by the same model. OpenAI's code search example embeds the query "using the same model" as the indexed functions.[1] Some models also take a setting for the kind of input. Gemini-embedding-001 has separate task types for search queries and for documents to be retrieved. Cohere asks for `search_query` on queries and `search_document` on the passages being searched.[4][5]

## Vector databases

A vector database can search exactly or approximately, and the approximate option is faster and can miss some of the nearest passages. A vector database stores embeddings and returns the ones nearest to a query vector. OpenAI recommends one for searching many vectors quickly.[1]

The simplest search compares the query with each stored vector in turn. [pgvector](https://github.com/pgvector/pgvector), an open-source extension that adds vector search to Postgres, does this by default and calls it exact nearest neighbor search, with perfect recall. An approximate index trades some recall for speed. pgvector notes that queries can return different results after such an index is added.[7]

HNSW (Hierarchical Navigable Small World) is an approximate index. The [2016 paper that introduced it](https://arxiv.org/abs/1603.09320) builds a graph in several layers, with fewer points in the upper layers. A search starts at the top layer and moves down toward the nearest points, and its cost grows with the logarithm of the number of vectors.[8] Azure AI Search and pgvector both support HNSW. Microsoft says HNSW in Azure AI Search requires all data points to be in memory for fast access.[6][7]

## Embeddings in RAG retrieval

Embeddings beat keyword search in a 2020 test, and many RAG systems now combine the two, so the exact names and terms on a page still count. The 2020 paper [Dense Passage Retrieval for Open-Domain Question Answering](https://arxiv.org/abs/2004.04906) showed that a retriever can work with embeddings alone. Its retriever outperformed a Lucene BM25 keyword system by 9 to 19 percentage points in top-20 passage retrieval accuracy.[9] The paper that introduced [retrieval-augmented generation](https://promptlyfound.com/ai-search/rag) models, [Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks](https://arxiv.org/abs/2005.11401), used a dense vector index of Wikipedia as the model's external memory.[10]

Many RAG systems now use embeddings and keyword search together. [Anthropic's post on Contextual Retrieval](https://www.anthropic.com/news/contextual-retrieval) says embedding models capture meaning but can miss exact matches, such as an error code. Its pipeline splits documents into chunks of a few hundred tokens, retrieves chunks with both embeddings and BM25, and merges the two lists.[11] The retrieved chunks then go into the model's context window, which [how large language models work](https://promptlyfound.com/llms/how-llms-work) explains.

In [its announcement of the SPTAG vector search algorithm](https://news.microsoft.com/source/features/ai/bing-vector-search), Microsoft said in 2019 that Bing used vector search for web results. It had turned more than 150 billion pieces of indexed data into vectors.[14]

## Limits

Embeddings miss things in documented ways, and a retrieval system that relies on them alone inherits those gaps.

- Embeddings can miss exact strings. Anthropic's example is a support query for "Error code TS-999" that returns pages about error codes in general.[11]
- Embedding models do not always transfer to new kinds of data. The [BEIR benchmark](https://arxiv.org/abs/2104.08663) tested 10 retrieval systems on 18 datasets and found that dense retrieval models often performed worse than other approaches on data they were not trained for. The authors describe BM25 as "a robust baseline."[13]
- The size of a vector limits what it can retrieve. [On the Theoretical Limitations of Embedding-Based Retrieval](https://arxiv.org/abs/2508.21038) shows that the number of distinct top-k result sets a query can return is limited by the embedding dimension. State-of-the-art models failed LIMIT, a simple dataset the authors built to test this.[12]
- Gemini-embedding-2 silently truncates input beyond its token limit, so a long page has to be represented by its chunks.[4]
- Approximate indexes trade recall for speed. pgvector applies filters after the index scan, so a filtered query can return fewer results than requested.[7]

## Sources

1. Vector embeddings. OpenAI API documentation. https://developers.openai.com/api/docs/guides/embeddings
2. Efficient estimation of word representations in vector space. arXiv (Mikolov et al.), 2013-01-16. https://arxiv.org/abs/1301.3781
3. Sentence-BERT: Sentence embeddings using Siamese BERT-networks. arXiv (Reimers and Gurevych), 2019-08-27. https://arxiv.org/abs/1908.10084
4. Embeddings. Gemini API documentation, 2026-10-29. https://ai.google.dev/gemini-api/docs/embeddings
5. Introduction to embeddings at Cohere. Cohere documentation. https://docs.cohere.com/docs/embeddings
6. Vector relevance and ranking. Microsoft Learn. https://learn.microsoft.com/en-us/azure/search/vector-search-ranking
7. pgvector: open-source vector similarity search for Postgres. pgvector on GitHub. https://github.com/pgvector/pgvector
8. Efficient and robust approximate nearest neighbor search using Hierarchical Navigable Small World graphs. arXiv (Malkov and Yashunin), 2016-03-30. https://arxiv.org/abs/1603.09320
9. Dense passage retrieval for open-domain question answering. arXiv (Karpukhin et al.), 2020-04-10. https://arxiv.org/abs/2004.04906
10. Retrieval-augmented generation for knowledge-intensive NLP tasks. arXiv (Lewis et al.), 2020-05-22. https://arxiv.org/abs/2005.11401
11. Introducing Contextual Retrieval. Anthropic, 2024-09-19. https://www.anthropic.com/news/contextual-retrieval
12. On the theoretical limitations of embedding-based retrieval. arXiv (Weller et al.), 2025-08-28. https://arxiv.org/abs/2508.21038
13. BEIR: A heterogenous benchmark for zero-shot evaluation of information retrieval models. arXiv (Thakur et al.), 2021-04-17. https://arxiv.org/abs/2104.08663
14. As search needs evolve, Microsoft makes AI tools for better search available to researchers and developers. Microsoft Source, 2019-05-15. https://news.microsoft.com/source/features/ai/bing-vector-search

---

This is a plain-text copy of https://promptlyfound.com/llms/embeddings from Promptly Found. The web page is the canonical version and includes the charts.
