An embedding is a list of numbers that represents the meaning of something (a word, sentence, image or product) so that similar things sit close together. Comparing embeddings lets software find related items by meaning rather than exact words. This is the engine behind semantic search, retrieval-augmented generation (RAG), recommendations and clustering.

How do embeddings capture meaning?

An embedding model is trained on huge amounts of data to place items with similar meaning near each other in a high-dimensional space. "Train ticket booking" and "IRCTC reservation" end up close; "train a neural network" ends up somewhere else, even though it shares a word. Distance between vectors, often measured with cosine similarity, becomes a measure of relatedness.

Where are embeddings used?

UseHow embeddings help
Semantic searchFind documents that match the meaning of a query, not just keywords
RAGRetrieve the most relevant chunks to ground an LLM's answer
RecommendationsSuggest products, courses or articles similar to what someone liked
ClusteringGroup support tickets or reviews by topic automatically
DeduplicationSpot near-duplicate questions or records

How does embedding search work in a RAG app?

  1. Split documents into chunks of a sensible size.
  2. Create an embedding for each chunk and store it, usually in a vector database.
  3. Embed the user's question with the same model.
  4. Retrieve the nearest chunks and pass them to the LLM with the question.
  5. Generate an answer that cites those chunks.

Read what is RAG for the full pipeline and its pitfalls.

What should you watch out for?

  • Use the same embedding model for documents and queries.
  • Chunk size changes results: too small loses context, too large dilutes it.
  • Embeddings for Indian languages vary in quality by model; test on your data.
  • Re-embed when you change models; vectors from different models aren't comparable.

Learning embeddings in Program Zero

Program Zero teaches tokenization and embeddings at the start of Phase 8, then uses them for RAG with vector databases and for agents. The maths behind similarity (vectors and dot products) is covered earlier, so the idea is intuitive by the time you use it.