Vector search always returns the nearest neighbours, even when nothing in the index is actually relevant. Without a threshold, a question with no answer in the documents still gets a confident-looking answer built from the least-bad chunks. OpenAI recommends cosine similarity for its embeddings, and its embeddings are normalized to length 1, so cosine similarity is a simple dot product. A threshold on that score is what turns a nearest-neighbour list into a relevance filter.
What you need
- A set of question-and-chunk pairs labelled relevant or not
- The similarity scores for those pairs from your model
- A rule for what happens below the threshold: return nothing
Step 1: Score labelled pairs and find the split
Compute the similarity score for known relevant pairs and known irrelevant pairs. Look for the score that separates the two groups: most relevant pairs above it, most irrelevant pairs below it.
Step 2: Set the threshold at the split and test it
Set the cutoff at that score and run the test questions. Check that relevant chunks still pass and irrelevant ones are dropped, and record how many questions now return nothing.
Step 3: Handle the empty result honestly
When nothing passes the threshold, the answer should say the documents do not contain the answer, not invent one from the weakest match. A refusal is the correct response to missing evidence.
Worked example: synthetic threshold calibration on 4 pairs
The table below is a synthetic example. It shows the expected result of calibrating a threshold; no search was run.
| Pair | Cosine score | Above 0.70? |
|---|---|---|
| Refund question, refund chunk | 0.82 | Yes – kept |
| Refund question, shipping chunk | 0.55 | No – dropped |
| Setup question, setup chunk | 0.78 | Yes – kept |
| Pricing question, FAQ chunk | 0.61 | No – dropped |
Expected result (UNTESTED). a threshold of 0.70 keeps the 2 relevant chunks and drops the 2 weak matches. This check was not run live; the table shows the expected result for the synthetic example.
Limits
- A threshold calibrated on one model does not transfer to another: scores are not comparable across models.
- Cosine similarity and Euclidean distance give identical rankings for normalized embeddings, but the threshold values differ.
- A threshold that is too high hides good answers; one that is too low lets noise through.
- Re-calibrate the threshold whenever the embedding model or the chunking changes.
