Embeddings are mathematical representations of objects such as text, and vector search compares those representations to find the closest matches. Together they form the retrieval layer of retrieval-augmented generation (RAG): a user’s question is embedded, the vector index returns the most semantically relevant chunks of your own documents, and those chunks are added to the prompt so a language model can answer from grounded information rather than from memory alone.
This explainer is for technically curious beginners and intermediate practitioners who want to understand what happens between “I have a pile of documents” and “the model answered correctly.” It covers what embeddings are, how vector search works, where each step sits in a RAG pipeline, and which decisions and limitations actually affect results.
What an embedding is, in plain language
An embedding is a mathematical representation of an object, such as text. When a neural network is trained, it creates many representations of an object, each with connections to other objects in the network. The embedding matters because it captures the semantic meaning of the object, so one object’s representation can be compared mathematically with another’s. Microsoft’s Azure architecture guidance puts it simply: embeddings let you compare objects mathematically.
The classic illustration is vector arithmetic: embedding(king) - embedding(man) + embedding(woman) = embedding(queen). The point is not that the model “knows” royalty, but that meaning is encoded as position and direction in a high-dimensional space. Microsoft
Because embeddings are numeric, you compare them using notions of similarity and distance. Sentences with similar meaning end up close together. In Microsoft’s example, “The cat is on the mat” and “The cat is sitting on the mat” sit near each other, while “It’s currently sunny in Phoenix” is far away. Microsoft
Two consequences follow. First, retrieval can be semantic rather than literal: a question phrased differently from the source document can still find the right passage. Second, retrieval quality depends heavily on the embedding model, because that model defines what “close” means.
Why RAG needs an embedding-and-search layer
Large language models offer powerful language understanding and generation capabilities, but they are not reliable information sources and they lack access to proprietary information or any other information they were not trained on. Databricks RAG addresses this by combining a user’s prompt with relevant external information to form a new, expanded prompt for the LLM, which enables more relevant, timely, and accurate responses. Databricks
The retrieval half of that combination is where embeddings and vector search live. Without a way to find the right external information, “adding context” is guesswork. Embeddings make the search semantic, and a vector index makes it fast enough to run on every query.
The RAG pipeline, step by step
Databricks describes RAG with vector search as a sequence: data preparation (getting an external information source into a vector database), retrieval, augmentation, generation, and evaluation. Databricks Embeddings and vector search are concentrated in the first two stages, but they shape everything downstream.
1. Data preparation and chunking
Before embeddings exist, documents are divided into chunks and enriched. Microsoft Chunking matters because the chunk — not the whole document — is what gets embedded, retrieved, and passed to the model as context. Enrichment can include metadata fields that you also plan to embed or filter on. Microsoft
A practical way to think about it: the chunk is the unit of retrieval. If a chunk mixes several unrelated ideas, its embedding becomes a blurry average that matches many queries weakly. If a chunk is too small, it may lack the surrounding context needed to answer. There is no universal chunk size; the right choice depends on document structure and query patterns, and it is worth testing rather than assuming.
2. Generate embeddings
In this step you generate embeddings for the chunks and for any metadata fields on which you plan to run vector searches. Microsoft The embedding model is the component that turns text into vectors, and the same model must be used consistently — a point that becomes critical at query time.
3. Retrieval and vector search
At query time, you embed the user query using the same embedding model as your chunks, then search your database for relevant vectors to return the most semantically relevant chunks. Microsoft This is the core mechanic of vector search: the query becomes a vector, and the index returns the vectors nearest to it under a similarity or distance measure.
The retrieved chunks are not passed to the model as vectors. The original text of the relevant chunks passes to the language model as grounding data. Microsoft Vectors are for finding; text is for reasoning.
4. Augmentation and generation
Augmentation is where the retrieved context is added to the user’s prompt. Databricks The model then generates an answer conditioned on that context. Because the model is now working from supplied passages, it can address topics it was not trained on — the proprietary and current information that LLMs otherwise lack. Databricks
5. Evaluation
Evaluation closes the loop. Databricks It is not a formality: a RAG system can fail at retrieval (the right chunk was never returned), at augmentation (the context was truncated or poorly formatted), or at generation (the model ignored the context). Measuring retrieval separately from generation is how you tell those failures apart.
Similarity and distance: how “closest” is decided
Embeddings are compared using notions of similarity and distance. Microsoft In practice, vector stores commonly rank neighbors with cosine similarity or Euclidean distance, and the choice of metric is usually tied to how the embedding model was trained. The important operational point is consistency: the metric and the model should be treated as one configuration, not tuned independently.
This is also where an “approximate nearest neighbor” index matters. Exact comparison against every vector in a large corpus is expensive; an index trades a small amount of recall for a large amount of speed. That tradeoff is invisible in a demo and very visible at scale, which is why retrieval quality should be measured with a real test set rather than judged from a handful of queries.
How vector search differs from keyword search
Keyword search matches literal terms. Vector search compares embeddings, so it can retrieve a passage that expresses the same meaning with entirely different words. That is the direct consequence of embeddings capturing semantic meaning. Microsoft
The two are not mutually exclusive. A common pattern is to combine semantic retrieval with metadata filters — for example, restricting results to a specific product version — because you can embed metadata fields on which you plan to run vector searches. Microsoft Structured constraints often make the difference between “relevant in general” and “relevant to this user.”
A concrete, illustrative example
Suppose a team has internal product documentation and wants a support assistant. The documents are chunked into passages, each passage is embedded, and the vectors are stored in a vector database alongside metadata such as product name and version.
A user asks, “How do I reset the device after a failed update?” The query is embedded with the same model used for the chunks. Vector search returns the passages whose vectors are closest — ideally a troubleshooting section that never uses the word “reset” but describes the recovery procedure. Those passages are inserted into the prompt, and the model answers from them.
This scenario is illustrative, not a report of a measured deployment. Its purpose is to show where each component sits: chunking determines what can be found, the embedding model determines what counts as similar, the vector index determines how fast, and the prompt determines what the model sees.
Decisions and tradeoffs that affect results
Embedding model consistency. The query and the chunks must be embedded with the same model. Microsoft Mixing models produces vectors that are not comparable, and retrieval quality collapses in a way that is easy to misdiagnose as a “bad database.”
Chunking strategy. Chunk boundaries determine the retrieval unit. Structure-aware chunking that respects headings, sections, or code blocks usually produces more coherent embeddings than fixed-length splitting, though the best approach depends on the corpus.
Metadata and filtering. Embedding metadata fields on which you plan to run vector searches Microsoft lets you combine semantic similarity with structured constraints. This is often what makes retrieval usable in production.
RAG versus fine-tuning and prompt engineering. RAG is one option among several. Databricks presents it alongside prompt engineering, fine-tuning, and pretraining, and notes that these methods can be combined. Databricks RAG is a natural fit when knowledge changes often or is proprietary, because the external source can be updated without retraining the model. Fine-tuning changes the model’s behavior; RAG changes what the model can see at answer time.
Evaluation scope. Because evaluation is an explicit stage of the RAG process, Databricks plan for it before launch. Track retrieval quality (did the right chunks appear?) and answer quality (did the model use them?) as separate signals.
Where this fits in real workflows
RAG with vector search supports question-answering systems, customer service, content generation, and code assistance. Databricks Those use cases share a pattern: a body of knowledge that is too large, too current, or too private to rely on a model’s training alone.
For teams running local models, the same architecture applies, with the embedding model and the vector store running on your own hardware. The tradeoff is operational: you own the index, the embedding model, and the update pipeline. For WordPress and automation workflows, the retrieval layer can sit behind a plugin or an API call, but the same rules hold — consistent embedding models, deliberate chunking, and metadata that reflects how users actually search.
Next steps
Start small and measurable. Pick one document set, choose a single embedding model, chunk with structure in mind, and build a retrieval test set of questions with known correct passages. Then measure retrieval before you tune generation. If you are comparing approaches, treat RAG, prompt engineering, and fine-tuning as complementary tools rather than competing ideologies. Databricks
If you are working through a RAG build — local or hosted — share your setup, your chunking approach, and the retrieval failures you are seeing in the Ai-Forum.org community so others can compare notes.
FAQ
Can I use different embedding models for my documents and my queries?
No. Microsoft's guidance is to embed the user query using the same embedding model as your chunks. Mixing models produces vectors that are not comparable, which breaks retrieval.
Is vector search the same as keyword search?
No. Keyword search matches literal terms, while vector search compares embeddings, so it can retrieve passages that express the same meaning with different words.
Does RAG replace fine-tuning?
No. Databricks presents RAG alongside prompt engineering, fine-tuning, and pretraining as methods that can be combined rather than mutually exclusive alternatives.
What actually gets passed to the language model — vectors or text?
The original text of the relevant chunks passes to the language model as grounding data. The vectors are used for retrieval, not for generation.