71. Your vector search returns irrelevant results despite high similarity scores. How do you fix it?
Require a defensible correction plan centered on embedding suitability, normalization and metric choice, hubness, missing filters, hard negatives, reranking, and labeled error analysis and objective proof that the risk is reduced.
I would label good and bad results, then test embedding fit, normalization and metric choice, hubness, required filters, and ANN recall. I would use hard negatives to improve the embedding model, rerank top candidates, and prove the change on held-out data before deployment.
The problem is that the system gives large scores to items that do not really help the user. A large score only means the current matching rules think two items are close. It does not prove the result answers the user's need. I would collect examples of good and bad results, find the pattern behind the mistakes, change one cause at a time, and compare the new results with the old ones. The goal is not larger scores. The goal is more useful results that stay better on unseen examples.
- Do we have labeled examples showing which results are relevant and irrelevant?
- Are query and document embeddings produced by the same compatible embedding model and representation?
- Which similarity metric is configured, and are vectors normalized when that setup requires it?
- Which metadata rules must restrict retrieval, such as tenant, access scope, document type, language, or time?
- Is the problem present with exact nearest-neighbor search too, or only with the approximate index?
- Can we retrain or fine-tune the embedding model with hard negatives, or are we limited to retrieval and reranking changes?
I would treat this as a relevance-debugging problem, not a similarity-threshold problem.
First, I would build a labeled evaluation set. For each query, I need examples marked relevant and irrelevant. I would include hard negatives. A hard negative is a document that looks similar to the query but is still the wrong answer. This gives me a stable test set for comparing changes.
Next, I would check the embedding model. Source documents remain the authoritative data. Their embeddings and the vector index are derived data. Documents are embedded during ingestion, while the user query is embedded at search time. Both sides must use a compatible embedding model and representation. If the model does not represent the domain well, a high similarity score can still describe the wrong meaning. I would compare alternative models or a fine-tuned model on labeled queries rather than choosing one by intuition.
Then I would verify normalization and the similarity metric as one contract. For example, if I use cosine similarity, L2-normalizing vectors makes each vector length equal to 1. On unit-length vectors, cosine similarity and dot-product ranking are equivalent. I would not switch blindly among cosine similarity, dot product, and Euclidean distance because each changes how vectors are ranked. The metric must match the embedding model and the way vectors were prepared.
I would also check for hubness. Hubness means a small set of vectors appears as nearest neighbors for many unrelated queries. Generic documents can then receive high similarity scores again and again. I would measure how often each document appears in retrieved neighborhoods. If the data shows real hubness, I would test a defensible mitigation such as centering or whitening the representation, or a local-scaling method. These transformations change the vector space, so they must be evaluated carefully and may require re-embedding and re-indexing.
Next, I would verify metadata filters. The search should only consider documents allowed for the request. Examples include tenant, access scope, document type, language, and time. A document can be mathematically similar and still be invalid for the user. Authorization-sensitive restrictions must be applied before restricted content is exposed. Different vector databases apply filters differently around approximate search, so I would verify the actual behavior instead of assuming it.
I would also separate document ingestion from query-time retrieval. During ingestion, source documents are embedded with the compatible model and their vectors are stored in the vector index. At query time, the query is embedded, normalized when required, and searched against that index. HNSW and IVF-PQ are examples of approximate nearest-neighbor index approaches. They are alternatives unless a specific implementation explicitly combines techniques.
If I suspect the approximate index, I would compare it with exact nearest-neighbor search on the same embeddings and labeled queries. If exact search finds good neighbors but the approximate index misses them, I would measure ANN recall and tune or rebuild the index. If exact search is also bad, the problem is more likely the embeddings, metric, normalization, filters, or labeling.
If the embedding model cannot separate relevant documents from near-but-wrong ones, I would use hard negatives during training or fine-tuning. Hard negatives are part of model improvement, not a live query-processing stage. When the embedding model or its representation changes, stored document embeddings must be regenerated and the vector index rebuilt or migrated consistently.
After retrieval, I would rerank the top-k candidates. A cross-encoder or another stronger relevance reranker reads the query together with each candidate and assigns a better relevance score. Vector search quickly finds a candidate set. Reranking spends more compute on that smaller set and returns the best top-n results. The tradeoff is extra latency and model cost, so I would choose k from measured quality and latency rather than making it unnecessarily large.
Finally, I would prove that the risk went down. I would classify failures into embedding mismatch, normalization or metric mismatch, hubness, missing filters, hard-negative gaps, weak reranking, or index-recall problems. I would measure Recall@K, nDCG@K, MRR@K, and Precision@K before and after important changes on a held-out set. I would deploy only when relevance improves without breaking required filtering or access rules. After deployment, I would monitor the same signals and alert on regression.
- Build a labeled set of relevant and irrelevant results, including near-but-wrong hard negatives.
- Reproduce failures and group them by likely cause instead of changing the similarity threshold first.
- Verify that the embedding model fits the domain and that query and document embeddings use a compatible model and representation.
- Verify the normalization and similarity-metric contract. Normalize vectors when the chosen setup requires it.
- Measure hubness by checking whether a small set of documents appears unusually often across unrelated queries.
- Verify required metadata filters such as tenant, access scope, document type, language, and time.
- Compare approximate nearest-neighbor results with exact search on a labeled sample when index recall may be part of the problem.
- Add hard negatives during training or fine-tuning when the embedding model cannot separate relevant documents from near-but-wrong documents.
- Re-embed documents and rebuild or migrate the vector index when the embedding representation changes.
- Retrieve top-k candidates, rerank them with a stronger relevance model, and return the best top-n.
- Compare Recall@K, nDCG@K, MRR@K, and Precision@K before and after on held-out data.
- Deploy only after objective improvement, then monitor for relevance regression.
The main costs come from creating embeddings, storing vectors, building and searching the index, applying filters, and reranking candidates. Approximate indexes such as HNSW or IVF-PQ avoid comparing the query with every stored vector, but they add index memory, build time, tuning work, and possible recall loss. Metadata filters can reduce the candidate set, but their interaction with approximate search depends on the vector database. Reranking usually improves final relevance but adds latency and model cost for each candidate. Changing the embedding representation can be expensive because documents may need to be re-embedded and the index rebuilt or migrated. Labeled evaluation also needs ongoing review and maintenance.
This correction process is used in semantic search, retrieval-augmented generation, enterprise knowledge search, support-document retrieval, product discovery, recommendation candidate retrieval, and multi-tenant document systems. It is especially useful when similarity scores look strong but users still receive off-topic results, generic documents dominate many queries, metadata or access rules are missing, ANN recall is weak, or a fast vector retriever needs a stronger reranker for final relevance.
This question tests whether the candidate understands that high vector similarity is not the same as high user relevance. It evaluates judgment across embedding suitability, normalization, metric choice, approximate retrieval, metadata filtering, hubness, hard negatives, reranking, and labeled evaluation. A strong candidate also separates authoritative source documents from derived embeddings and the vector index, understands when re-embedding and re-indexing are required, and proves that a correction works instead of relying on a few good-looking examples.
A common mistake is treating a high similarity score as proof of relevance. Another is changing the similarity threshold before finding the real failure mode. Candidates may also use an embedding model that does not fit the domain, mix incompatible query and document representations, forget required normalization, or change cosine similarity, dot product, and Euclidean distance without understanding how ranking changes. Missing tenant or access filters can return invalid content even when similarity is high. Hard negatives should not be shown as a live processing step on retrieved candidates; they are mainly training and evaluation data. It is also wrong to imply that HNSW and IVF-PQ must run together. They are alternative ANN approaches unless a specific implementation says otherwise. Changing the embedding representation without re-embedding stored documents can make the index incompatible. Finally, testing only a few hand-picked queries is weak evidence; the correction should be measured on labeled held-out data and monitored after deployment.
Start by saying that similarity is only a ranking signal, not proof of relevance. Then move through the failure modes in order: labeled examples, embedding fit, normalization and metric, hubness, filters, ANN recall, hard negatives, reranking, and objective evaluation. Keep source documents, derived embeddings, indexing, and query-time retrieval clearly separated.










