AI & Machine Learning · reviewed in August 2026
Embeddings
An embedding is a numeric representation of a piece of text (or an image) as a vector of numbers in a high-dimensional space, built so that elements with similar meaning end up close together in that space. It's the foundation of semantic search and systems like RAG.
# cosine similarity between two already-computed embeddings
import numpy as np
def similarity(a, b):
return np.dot(a, b) / (np.linalg.norm(a) * np.linalg.norm(b))Frequently asked questions
How is an embedding different from a token?
A token is a discrete unit of text; an embedding is the continuous numeric vector representing the meaning of a full piece of text (or a token) inside a model, letting you compare meanings with math operations like cosine similarity.
What is embedding similarity search used for?
Finding documents or passages relevant to a question even when they don't share the exact same words — searching by semantic closeness in the vector space instead of literal text matching.
Where are embeddings stored to query them quickly?
In a vector database (or a vector extension of a relational database), optimized to find the nearest vectors to a given one among millions of embeddings.