TechBuzzPro

Embedding Evaluation for RAG: Why Fast Retrieval Still Misses

· 7 min read · Apps & Browsers

In this article
  1. Background: What Embeddings Do in RAG
  2. How Embedding Evaluation Works
  3. Why Fast Retrieval Misses: Common Causes
  4. How to Choose an Embedding Model for RAG
  5. Common Problems and Misconceptions
  6. Comparing Embedding Models: What to Look For
  7. Costs and Trade-offs
  8. Alternatives to Pure Embedding Retrieval
  9. Frequently Asked Questions

Embedding evaluation for RAG reveals that fast retrieval still misses relevant documents because embedding models optimize for semantic similarity, not the exact lexical or factual matches that question-answering tasks require. This article explains why retrieval failures happen, how to evaluate embeddings for RAG, and how to reduce misses without sacrificing speed.

Background: What Embeddings Do in RAG

Retrieval-augmented generation (RAG) systems use embeddings to convert text into high-dimensional vectors, then retrieve documents whose vectors are closest to the query vector. This approach works well for finding topically related content, but it often fails for questions that demand precise facts, numbers, or named entities. The reason is that embedding models are trained on general text similarity, not on the specific task of answering questions. For example, a query like "What is the capital of France?" may retrieve a document about French culture that never mentions Paris, because the vector distance is small even though the answer is absent.

How Embedding Evaluation Works

Evaluating embeddings for RAG involves measuring how well the retrieval step finds documents that contain the correct answer. The standard approach uses a test set of queries paired with relevant documents. You embed all documents and queries, then for each query you retrieve the top-k documents and check whether the relevant document appears in that set. Common metrics include:

  • Recall@k: the fraction of queries for which the correct document is in the top-k results.
  • Precision@k: the fraction of retrieved documents that are relevant.
  • Mean Reciprocal Rank (MRR): the average of the reciprocal of the rank of the first relevant document.
  • Normalized Discounted Cumulative Gain (NDCG): a ranking quality metric that accounts for the position of relevant documents.

These metrics give a quantitative view of retrieval quality, but they don't tell you why misses occur. To diagnose failures, you need to inspect the retrieved documents for a sample of queries and categorize the errors.

Why Fast Retrieval Misses: Common Causes

Fast retrieval methods, such as approximate nearest neighbor (ANN) search, trade a small amount of accuracy for speed. However, even exact search with a good embedding model can miss relevant documents. The main causes are:

  1. Semantic vs. lexical mismatch: The query uses different words than the document. For example, "how to fix a leaky faucet" may not match a document titled "Plumbing Repairs" because the embedding model doesn't capture the synonymy well enough.
  2. Short queries: A query like "RAG evaluation" has few tokens, so the embedding vector is less specific and may retrieve generic documents about evaluation in other contexts.
  3. Long documents: If the relevant information is buried in a long document, the overall document embedding may be dominated by other topics, pushing the vector away from the query.
  4. Out-of-domain vocabulary: Embedding models trained on general text may not understand specialized terms (e.g., medical or legal jargon), leading to poor matches.
  5. ANN approximation: Approximate search methods like HNSW or FAISS use a trade-off parameter (e.g., efSearch) that can reduce recall if set too low.

How to Choose an Embedding Model for RAG

Selecting the right embedding model is a balance between retrieval quality and speed. Here are the key factors:

  • Model size: Larger models (e.g., 7B parameters) generally produce better embeddings but are slower and require more memory. Smaller models (e.g., 300M) are faster but may miss nuanced matches.
  • Training data: Models fine-tuned on domain-specific data (e.g., biomedical or legal text) perform better on those domains.
  • Dimension: Embeddings with higher dimensions (e.g., 1024 vs. 384) can capture more information but require more storage and computation.
  • Context length: Some models handle longer documents better, which is relevant if your documents are long.

You should evaluate several models on your own test set, measuring both retrieval metrics and latency. A common misconception is that a higher benchmark score on a general dataset (like MTEB) guarantees good RAG performance. In practice, your domain and query style matter more.

Common Problems and Misconceptions

One frequent issue is that teams optimize the embedding model for similarity on a generic corpus, but then the RAG system fails on questions that require exact matches. For example, a query "What is the dosage of ibuprofen?" might retrieve a document about pain relief that doesn't mention dosage. This happens because the embedding model sees the words "ibuprofen" and "pain relief" as similar, but the query's intent (dosage) is not captured.

Another misconception is that adding more documents to the index always improves recall. In reality, a larger index can increase the chance of retrieving irrelevant documents that are semantically close to the query, especially if your embedding model is not discriminative enough. This is why you should evaluate retrieval on a representative set of queries, not just on the documents you have.

Comparing Embedding Models: What to Look For

When comparing embedding models, you should look at both retrieval quality and operational costs. Here are the practical steps:

  1. Create a test set of at least 100 real queries with known relevant documents.
  2. Run each model on the same test set, using the same retrieval method (e.g., exact search) to isolate the model's effect.
  3. Measure recall@k for k=1,5,10 and MRR.
  4. Measure latency and memory usage on your hardware.
  5. Inspect failure cases to see if the model is making obvious mistakes (e.g., missing a document that contains the exact answer).

You may find that a slightly slower model with better recall reduces the need for re-ranking, which can actually improve end-to-end speed.

Costs and Trade-offs

Improving retrieval quality often comes at a cost. Larger models require more GPU memory and have higher inference latency. For a RAG system that serves many queries per second, this can be a bottleneck. You can mitigate this by:

  • Using a smaller model for initial retrieval and a larger model for re-ranking the top results.
  • Quantizing embeddings to reduce memory usage (e.g., int8 instead of float32).
  • Using a hybrid approach that combines keyword search (e.g., BM25) with embedding search. This is often a simple way to catch exact matches that embeddings miss.

There is no free lunch: you must measure the trade-off between recall and latency on your own data.

Alternatives to Pure Embedding Retrieval

If embedding retrieval still misses too many relevant documents, consider these alternatives:

  • Hybrid search: Combine embedding similarity with keyword matching. BM25 (a classic lexical algorithm) is good at exact matches, while embeddings capture semantic similarity. Many systems use a weighted combination of both scores.
  • Re-ranking: Retrieve a larger set (e.g., top 50) with a fast method, then use a cross-encoder model to re-rank the results. Cross-encoders are slower but more accurate because they consider the query and document together.
  • Query expansion: Expand the query with synonyms or related terms before embedding, which can improve recall for short queries.
  • Chunking strategies: For long documents, split them into smaller chunks and embed each chunk separately. This can help when the answer is in a specific section.

These methods add complexity and latency, but they can significantly reduce misses.

Frequently Asked Questions

Why does my RAG system return irrelevant documents even with a good embedding model?

The embedding model may not capture the specific intent of the query. For example, if the query asks for a number or a date, the model might retrieve documents that are topically related but lack the exact fact. Also, if your documents are long, the relevant information may be diluted. Try hybrid search or re-ranking to improve precision.

What is the best metric to evaluate retrieval for RAG?

Recall@k is the most important metric because it measures whether the correct document is found at all. MRR is also useful because it rewards higher ranking of the correct document. You should also track precision to avoid overwhelming the LLM with irrelevant context.

How many test queries do I need to evaluate embeddings?

At least 100 is a good starting point, but more is better. The key is to have a diverse set that represents real user queries, including edge cases like short queries, synonyms, and domain-specific terms. If your test set is too small, the results may be unreliable.

Is a larger embedding model always better for RAG?

Not necessarily. Larger models often have better semantic understanding, but they can be slower and more expensive. On your specific data, a smaller fine-tuned model might outperform a larger general model. Always evaluate on your own test set.

Can I use exact search instead of ANN to avoid misses?

Yes, if your corpus is small (e.g., a few thousand documents), exact search is feasible and eliminates ANN approximation errors. For larger corpora, you can use ANN with a high recall setting (e.g., increasing efSearch in HNSW) to get close to exact results, but this increases latency.

What is the role of chunk size in retrieval misses?

Chunk size matters because embeddings are computed for each chunk. If chunks are too large, the relevant information may be diluted; if too small, the chunk may lack context. A common practice is to use 300-500 tokens per chunk with some overlap. You should experiment with different sizes on your data.