Embeddings and vector search are the retrieval building block behind most AI search and RAG systems. An embedding model turns each piece of text into a…
Understand embeddings as meaning turned into a vector of numbers.
An embedding is what you get when an embedding model reads a piece of text and outputs a vector — a fixed-length list of numbers — that represents its meaning. The key property is that texts with similar meaning get vectors that are close together, and unrelated texts get vectors far apart.
So 'how do I reset my password' and 'steps to recover my account' end up near each other even though they share almost no words. Meaning becomes position, and position is something a computer can measure.
See how a query finds the closest stored vectors.
Vector search takes a query, embeds it into a vector with the same model, and finds the stored vectors closest to it, returning the top-k most similar items. Closeness is measured with a metric — cosine similarity is the common choice for text — that scores how aligned two vectors are.
At small scale you can compare the query against every stored vector. At larger scale, an approximate nearest neighbor index keeps search fast by finding very-close vectors without scanning everything.
# index once for item in items: store.add(vector=embed(item.text), text=item.text) # search q = embed("reset my password") hits = store.query(vector=q, top_k=3) # 3 closest by cosine
Each item is embedded and stored once; a query is embedded the same way, and the store returns the three closest vectors. Using the same embedding model for both is required, or the vectors aren't comparable.
Combine embeddings and vector search into a retrieval step.
Embeddings plus vector search give you semantic retrieval: given a query, fetch the most meaning-relevant items from a large collection. This is the core of AI search, recommendations, and retrieval-augmented generation (RAG).
In RAG, this step retrieves the passages most relevant to a user's question and hands them to a language model, which answers from them. So understanding embeddings and vector search is the foundation for understanding RAG — everything else builds on getting the right items back.
Get the practical details right and avoid the common errors.
A few rules make it work. Use the same embedding model to index and to query. Split long documents into focused chunks before embedding, so each vector represents one clear idea. Store useful metadata (source, date) alongside each vector so you can filter and cite. Choose the distance metric your embedding model was trained for — usually cosine for text.
Watch for: mixing embedding models between indexing and querying (vectors become incomparable); embedding entire documents so one vector blurs many topics; expecting semantic search to nail exact identifiers like error codes (keyword or hybrid search handles those); and forgetting that quality depends on the embedding model — a weak model means weak retrieval no matter the database.
Embeddings turn text into meaning-bearing vectors so similar texts sit close together; vector search embeds a query and returns the nearest stored vectors, ranking by a metric like cosine similarity. Together they enable semantic retrieval — the building block of AI search and RAG, where retrieved passages feed a model's answer. Use one embedding model everywhere, chunk documents, store metadata, and remember exact-identifier queries may need keyword or hybrid search.
You want to build search over a company wiki. Explain how you would turn its pages into a searchable vector index, what happens when a user query comes in, and one reason a search for an exact error code might still need keyword search alongside vectors.
What is an embedding?
Embeddings turn meaning into position, letting a computer measure semantic similarity by vector distance.
How does vector search find results?
Vector search ranks by nearness in embedding space, returning the top-k most semantically similar items to the query.
Why are embeddings and vector search the foundation of RAG?
RAG depends on this retrieval step to supply relevant context; getting the right items back is what makes the model's answer grounded.
What is a common mistake with embeddings and vector search?
Vectors only share a space if produced by the same model; mismatched models, whole-document embeddings, and weak models all hurt retrieval.