What are embeddings in AI and LLMs?

Also called embedding, vector embeddings, text embeddings

Definition

Embeddings are fixed-length vectors of numbers that represent data such as text or images so that items with similar meaning sit close together, which lets software compare meaning with arithmetic.

Embeddings are vectors of numbers that represent a piece of data, such as a sentence, a document, an image, or a product, in a way that places similar items close together. An embedding model converts each input into a fixed-length vector, often with hundreds or thousands of dimensions. Distance between two vectors then stands in for difference in meaning.

How embeddings work#

Embeddings work by training a neural network so that related inputs produce nearby vectors and unrelated inputs produce distant ones. Text embedding models are usually transformer encoders trained on pairs of related texts, such as a question and its answer, so that matching pairs end up close together. Sentence-BERT (Reimers and Gurevych, 2019) is an early example: it fine-tuned BERT with siamese networks so that sentences could be embedded independently and compared with cosine similarity.

At query time, similarity is measured with cosine similarity or a dot product. Common uses:

  • Semantic search and RAG: embed documents once, store them in a vector database, and embed each query to find the nearest documents.
  • Clustering and deduplication: group items whose vectors are close.
  • Classification and recommendations: use vectors as features, or match users to similar items.
  • Caching: semantic caching reuses answers for queries whose embeddings are close.

Choosing a model takes testing. The MTEB benchmark (Muennighoff et al., 2022) found that no single text embedding method dominates across all tasks, so candidates should be compared on the application's own retrieval data. Vectors from different embedding models are not compatible with each other, so switching models means re-embedding the whole corpus.

Embeddings vs tokens#

Tokens and embeddings are two stages of the same pipeline. A token is a discrete unit of text with an integer ID; an embedding is a continuous vector. Inside an LLM, each token ID is looked up in an embedding table to get one vector per token. A text embedding model goes a step further and pools those per-token vectors into a single vector for the whole input, which is the vector retrieval systems store.

What is RAG shows where embeddings fit in a full retrieval pipeline.

Cite this definition

The AI Engineering Editors. "What are embeddings in AI and LLMs?" The AI Engineering, updated Nov 06, 2026. https://theaiengineering.com/glossary/embeddings

Title
What are embeddings in AI and LLMs?
Author
The AI Engineering Editors
Publisher
The AI Engineering
Updated
View as Markdown

Part of the RAG and vector search hub · Updated