Prompt
Why are my embeddings returning irrelevant results?
Latest observation
“Bad” embedding search usually comes from one of a few predictable issues. Here’s a practical checklist to debug it.
1) Your data may be chunked poorly
If chunks are too large, embeddings become vague. If too small, they lose context.
- Too large: one chunk contains multiple topics, so similarity gets fuzzy.
- Too small: the chunk lacks enough meaning to match well.
Rule of thumb: aim for chunks that are semantically coherent, often a few hundred tokens each, with overlap if needed.
2) You may be embedding the wrong text
Common mistakes:
- embedding only titles when the body has the real content
- embedding raw HTML/JSON/noisy metadata
- embedding text after heavy truncation
- embedding OCR or parsed text with lots of errors
Make sure the text being embedded is actually the content you want retrieved.
3) Query text may not match document style
Embedding models work best when query and document have similar semantic signal. If your documents are written formally but the user query is short and vague, results can be weak.
Try:
- expanding the query with more context
- using a query rewrite step
- adding synonyms / domain terms
4) You might be using the wrong similarity metric
Check whether your vector store expects:
- cosine similarity
- dot product
- Euclidean distance
If vectors aren’t normalized and the metric is mismatched, rankings can be off. A very common setup is:
- use cosine similarity
- normalize embeddings if required by your stack
5) Embedding model mismatch
If you use different embedding models for:
- documents
- queries
…retrieval quality can break badly.
Make sure:
- the same embedding model is used for both
- the model is appropriate for your domain
- you’re not mixing old vectors with a new model
6) Your preprocessing may be harming meaning
Things that can reduce retrieval quality:
- removing stopwords excessively
- aggressive stemming/lemmatization
- lowercasing or punctuation stripping in a way that destroys meaning
- collapsing whitespace/formatting that matters
- translating or normalizing domain terms incorrectly
Embeddings generally prefer fairly natural text.
7) Your index may be stale or incorrectly built
Possible issues:
- vectors were never reindexed after document updates
- some documents were embedded but not inserted
- IDs/metadata don’t match the actual content
- you’re querying an old index version
Verify the pipeline end to end.
8) You may need metadata filtering
If results are “relevant” semantically but from the wrong category, add filters:
- language
- product line
- date range
- customer segment
- document type
This narrows the candidate set before semantic ranking.
9) Pure embedding search may not be enough
Embeddings are great for semantic similarity, but not perfect for:
- exact names
- IDs
- error codes
- legal clauses
- very specific keywords
A hybrid search often works better:
- keyword/BM25 for exact matching
- embeddings for semantic matching
- reranking on the top candidates
10) The top-k may be too small or too large
- Too small: you miss relevant results
- Too large: you see many irrelevant ones and think retrieval is poor
Try inspecting the top 20–50 results and measure where relevant items appear.
11) Your evaluation may be misleading
Sometimes the system is fine, but the expectations are off.
Ask:
- What is the true relevant document?
- Is relevance semantic or exact-match?
- Are there multiple valid answers?
- Is the query ambiguous?
Quick debugging steps
- Pick 5 queries where retrieval fails.
- Manually inspect:
- the query
- the chunk text
- the returned results
- Compare top result against the actual relevant text.
- Check:
- chunk size
- embedding model
- similarity metric
- preprocessing
- index freshness
Best-practice setup
A strong default is:
- coherent chunks with modest overlap
- same embedding model for docs and queries
- cosine similarity
- minimal text preprocessing
- metadata filters where appropriate
- hybrid retrieval + reranking
If you want, I can help you debug your specific setup. Paste:
- your chunking strategy
- embedding model
- vector DB
- similarity metric
- an example query and the top returned results
…and I’ll help pinpoint the issue.