Prompt
Our answer quality dropped after switching embeddings and I can’t tell if the index or the prompt is responsible. How do I debug that?
Latest observation
A good way to debug this is to separate retrieval problems from generation/prompt problems and test them in isolation.
1) First determine: is the right context being retrieved?
Before blaming the prompt, check whether the new embeddings changed what gets retrieved.
Do a retrieval-only audit
For a set of representative questions:
- Log the top-k retrieved chunks
- Compare old embeddings vs new embeddings
- Check:
- Is the relevant document present in top-k?
- Are the chunks too broad, too narrow, or off-topic?
- Did ranking change in a way that hides the answer?
Useful metrics
If you have labeled queries:
- Recall@k: does the correct chunk appear in top-k?
- MRR / nDCG: is the correct chunk ranked highly?
- Hit rate by question type: factual lookup vs multi-hop vs definition questions
Signs the index/embeddings are the issue
- The answer is in the corpus, but not retrieved
- Retrieved chunks are semantically “near” but miss key terms
- Short queries get worse after the embedding change
- Retrieval quality varies a lot across domains or jargon-heavy queries
2) Then isolate the prompt/generator
If retrieval is good, the issue may be the prompt or how the model uses the retrieved context.
Run a “gold context” test
Feed the model:
- the correct chunk(s) only
- a fixed prompt
- the same question
If the answer is still bad, the issue is likely:
- prompt instructions
- context formatting
- model behavior
- chunking or context window overload
Compare prompts
Test:
- old prompt vs new prompt
- with the exact same retrieved context
Look for:
- Does the model ignore context?
- Does it hallucinate despite good evidence?
- Does it answer in the wrong style/format?
- Is the prompt too verbose, conflicting, or underspecified?
Signs the prompt/generation is the issue
- Retrieval is clearly correct, but the model still answers incorrectly
- The model paraphrases instead of citing the context
- It invents details that are not in the chunks
- Performance changes when you change wording but keep retrieval fixed
3) Build a simple 2x2 diagnostic
This is the fastest way to pinpoint the source.
| Test | Retrieval | Prompt | Expected outcome |
|---|---|---|---|
| A | Old | Old | Baseline |
| B | New | Old | Isolate embedding/index impact |
| C | Old | New | Isolate prompt impact |
| D | New | New | Real-world combo |
Interpretation:
- B drops, C okay → embeddings/index issue
- C drops, B okay → prompt issue
- B and C both drop → both changed, or interaction effect
- Only D drops → interaction between retrieval and prompt formatting
4) Check the index/embedding pipeline itself
A quality drop after switching embeddings often comes from one of these:
Common embedding/index issues
- Dimension mismatch or wrong vector space
- Using embeddings from one model with an index built for another
- Not re-embedding the full corpus after model change
- Different normalization/cosine settings
- Chunking no longer matches the new embeddings
- Metadata filters or hybrid search weights changed unintentionally
- ANN index parameters changed and hurt recall
Validate with a “known-nearest-neighbor” test
Pick a few documents:
- Query with their own titles, unique phrases, or paraphrases
- Confirm the expected doc appears near the top
- If not, the retrieval stack is likely broken or misconfigured
5) Inspect the chunks, not just the embeddings
Sometimes embeddings are fine, but the chunking strategy makes retrieval worse.
Check:
- Chunk size too large → embeddings blur multiple topics
- Chunk size too small → missing context needed to answer
- Chunk boundaries split key facts
- Overlap too low
- Tables/code lists get mangled
A retrieval regression after embedding changes can actually be a chunking regression exposed by different similarity behavior.
6) Use “oracle retrieval” to isolate the generator
This is the most decisive test:
- Manually provide the exact correct context
- Ask the model to answer
- If it fails, the retriever is not the problem
If oracle retrieval works, but normal RAG fails:
- retrieval ranking/recall
- prompt context selection
- context truncation
- too many irrelevant chunks
7) Log the full chain
For each test query, save:
- query text
- embedding model/version
- top-k chunks and scores
- final prompt sent to model
- model output
- answer evaluation
Without this, it’s hard to tell whether the issue is:
- bad retrieval,
- bad prompt,
- or bad context assembly.
8) Practical debugging order
I’d do this in order:
- Pick 20–50 representative failed queries
- Compare retrieved chunks old vs new
- Run gold-context/oracle tests
- Run the 2x2 matrix
- Check index config, chunking, normalization, ANN parameters
- Only then tune the prompt
9) If you want a quick heuristic
- If the right text isn’t retrieved: fix index/embeddings/chunking
- If the right text is retrieved but ignored: fix prompt/context formatting
- If both are mediocre: you likely have a retrieval + prompt interaction issue
If you want, I can give you:
- a step-by-step debugging checklist
- a sample evaluation script
- or a template for logging RAG failures.