---
title: "What are embeddings in AI and LLMs?"
description: "Embeddings are numeric vectors that represent the meaning of text, images, or other data. Learn how embeddings work in AI and how they differ from tokens."
type: "glossary-term"
canonical_url: "https://theaiengineering.com/glossary/embeddings"
markdown_url: "https://theaiengineering.com/glossary/embeddings.md"
topic: "RAG and vector search"
author: "The AI Engineering Editors"
publisher: "The AI Engineering"
updated: "2026-11-06"
keywords: ["Embeddings","embedding","vector embeddings","text embeddings"]
citation: "The AI Engineering Editors. \"What are embeddings in AI and LLMs?\" The AI Engineering, updated Nov 06, 2026. https://theaiengineering.com/glossary/embeddings"
---

# What are embeddings in AI and LLMs?

Also called embedding, vector embeddings, text embeddings.

> **Definition of Embeddings:** 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](https://arxiv.org/abs/1908.10084) (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](https://theaiengineering.com/glossary/cosine-similarity).

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

- **Semantic search and [RAG](https://theaiengineering.com/glossary/retrieval-augmented-generation)**: embed documents once, store them in a [vector database](https://theaiengineering.com/glossary/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](https://theaiengineering.com/glossary/semantic-caching) reuses answers for queries whose embeddings are close.

Choosing a model takes testing. The [MTEB benchmark](https://arxiv.org/abs/2210.07316) (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](https://theaiengineering.com/glossary/tokens) 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](https://theaiengineering.com/articles/what-is-rag) shows where embeddings fit in a full retrieval pipeline.

## Related terms

- [Vector database](https://theaiengineering.com/glossary/vector-database): A vector database is a database built to store embedding vectors and quickly return the vectors most similar to a query vector, usually with approximate nearest neighbor indexes such as HNSW.
- [Tokens](https://theaiengineering.com/glossary/tokens): Tokens are the units of text a language model processes, typically whole words, word fragments, punctuation, or bytes, each mapped to an integer ID from the model's fixed vocabulary.
- [Retrieval-augmented generation (RAG)](https://theaiengineering.com/glossary/retrieval-augmented-generation): Retrieval-augmented generation (RAG) is a technique that retrieves relevant passages from an external knowledge source at query time and adds them to a language model's prompt so the answer is grounded in that data.
- [Semantic caching](https://theaiengineering.com/glossary/semantic-caching): Semantic caching is a technique that returns a stored LLM response when a new query is close in meaning to an earlier one, measured by embedding similarity instead of exact text match.
- [Reranking](https://theaiengineering.com/glossary/reranking): Reranking is a second retrieval stage that rescores an initial list of candidate documents with a more accurate but slower model, usually a cross-encoder, and keeps only the most relevant ones.
- [Cosine similarity](https://theaiengineering.com/glossary/cosine-similarity): Cosine similarity is a measure of how closely two vectors point in the same direction, computed as their dot product divided by the product of their lengths, with values from -1 to 1.
- [Late chunking](https://theaiengineering.com/glossary/late-chunking): Late chunking is an embedding technique that runs a long-context embedding model over a whole document first, then splits the token embeddings at chunk boundaries and averages each span into one chunk vector.

## Guides that cover embeddings

- [What is retrieval-augmented generation (RAG)? How RAG works](https://theaiengineering.com/articles/what-is-rag): Retrieval-augmented generation (RAG) grounds LLM answers in your documents. Learn the RAG pipeline, hybrid search, agentic RAG, evaluation, and failure modes.
- [Semantic caching for LLMs: how it works and when it pays off](https://theaiengineering.com/articles/semantic-caching): Semantic caching returns a stored LLM response for prompts with similar meaning. Learn how a semantic cache works, how to tune it, and what never to cache.
- [LLM routing: strategies, fallbacks, and learned routers](https://theaiengineering.com/articles/llm-routing): LLM routing guide: rule-based and cost-aware strategies, fallbacks, load balancing, semantic and learned routers like RouteLLM, router evals, and pitfalls.
- [Chunking strategies for RAG: how to choose, tune, and evaluate them](https://theaiengineering.com/articles/chunking-strategies-for-rag): Chunking strategies for RAG compared: fixed-size, recursive, document-aware, semantic, parent-child, and late chunking, with tested Python and an eval method.
- [AI engineer roadmap: skills, projects, and resources by stage](https://theaiengineering.com/articles/ai-engineer-roadmap): A practical AI engineer roadmap in seven stages, each with the skills to learn, a project to ship, and resources worth the time, from Python to production.

Part of the [RAG and vector search](https://theaiengineering.com/topics/rag) topic hub.

## 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: 2026-11-06
- URL: https://theaiengineering.com/glossary/embeddings
- Markdown: https://theaiengineering.com/glossary/embeddings.md
