Hard-negative mining and false negatives
Mine informative confusions without equating unjudged passages with proven negatives or treating teacher labels as certainty.
On this page
The question for today
What you’ll understand
- Explain why difficult negatives change a contrastive training signal.
- Identify false-negative risk in pooled and mined candidates.
- Compute the local effect of a mislabeled positive in a declared softmax objective.
A random unrelated document can be easy for a retriever to reject. A high-scoring but truly irrelevant document can teach a more useful distinction. The difficulty is that high-scoring unlabeled documents can also be genuinely relevant. DPR and RocketQA provide concrete primary examples of negative selection and denoising, while their task-specific results should not be generalized into a universal false-negative rate.
Hardness is relative to a model and objective
A hard negative scores highly under the current retriever despite being irrelevant under the task’s relevance policy. Lexical overlap, a shared entity, or an answer with the wrong date can create an informative confusion. Mining from the current index exposes the model to its own mistakes, but the mining checkpoint, corpus snapshot, and candidate filters determine which mistakes it sees. Negatives mined once can become easy as training changes. Track that provenance rather than treating hardness as an intrinsic label attached permanently to a document.
Contrastive softmax training pushes the designated positive above the listed negatives. Its probability is normalized over that training candidate set, not over every document in the collection, and it is not automatically a calibrated relevance probability. The number and distribution of negatives influence the optimization signal. In-batch negatives are convenient, but another query’s positive can also answer the current query. A batch construction that silently marks all cross-query documents negative can therefore penalize relevant evidence even when every original annotation was correct.
Unlabeled is not a relevance verdict
Collections often contain only a small set of judged positives for each query. A top-ranked passage missing from that set is unjudged, not necessarily nonrelevant. Duplicates, paraphrases, alternate supporting passages, and different legitimate interpretations increase the risk. RocketQA specifically studies denoising top-retrieved hard negatives with a cross encoder. That procedure can reduce one observed error source, but a teacher can also make systematic mistakes. Validate its filtering behavior on a human-reviewed sample rather than treating the teacher’s score as ground truth.
Choose a policy appropriate to the evidence: exclude uncertain candidates, collect judgments, use validated soft labels, or support multiple positives in a declared objective. Do not simply keep the hardest items until training loss falls; a model can learn to suppress legitimate answers. Audit query classes and near-duplicate groups, and keep evaluation examples out of mining and teacher training. A decrease in contrastive loss may reflect fitting contaminated labels rather than better retrieval on the intended relevance task.
Inspect the labels as well as the margins
Log which retriever version mined a negative, its rank and score, its document identity, and the evidence for its label. Compare a clean easy-negative baseline with reviewed hard negatives under the same data and evaluation protocol. Monitor retrieval quality by query type, candidate recall, and annotation coverage rather than using training loss alone. If denoising removes too many candidates, inspect whether the teacher is rejecting useful difficult distinctions or discovering alternate valid answers; those cases call for different corrections.
The probability lab models a hypothetical contamination assumption only. Reset, set false-negative probability to 0.2 and number of mined items to 5, predict the chance of at least one false negative, then Step: 0.67232. Independence and a common known rate are assumptions. The instrument does not judge passages, mine documents, or estimate a real contamination rate. Correlated near duplicates can make this binomial model inappropriate, so use it to expose assumptions rather than certify a training set.
Work it through
A mislabeled alternate answer changes the loss
For one query, use positive logit 2, one true-negative logit 1, and an alternate relevant passage incorrectly labeled negative with logit 2. Use the displayed single-positive loss at temperature one. Compare with excluding the uncertain alternate passage.
With all three candidates, the designated positive probability is e²/(2e² + e) = 1/(2 + e⁻¹), approximately 0.4223. Its loss is approximately 0.8620.
The falsely negative alternate has the same approximately 0.4223 probability and a positive logit derivative of that size. The local gradient pushes down a passage that the relevance policy says should be useful.
Excluding the uncertain alternate gives probability e²/(e² + e) = 1/(1 + e⁻¹), approximately 0.7311, and loss approximately 0.3133. The lower loss alone does not establish a better real retriever; labels and held-out quality still matter.
A supervision error changes the optimization target, not merely the apparent difficulty of the batch.
The living notebook
Explore the model
Interactive lab · probability
Assumed contamination risk in a mined set
Reset, set p = 0.2 and n = 5, predict the chance of at least one false negative, then Step: 0.67232. This exact binomial model assumes independent equal-rate contamination; it does not mine candidates, label relevance, or estimate an actual training-set error rate.
- Mean · np
- 5
- Variance · np(1−p)
- 2.5
- Total probability
- 1
These are exact binomial probabilities for independent trials with one fixed success probability. Playback tours the distribution; it does not resample outcomes. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.
Look forMore difficult candidates can include mislabeled positives, and their risk requires evidence beyond a model score.
Pause & reason
Check your understanding
Your turn
Try it yourself
A single-positive softmax batch has three equal logits zero: one labeled positive, one true negative, and one unlabeled but relevant alternate answer labeled negative. Compute positive probability and loss, then the values after excluding the uncertain alternate.
Take a moment to make a prediction or work it out on paper. Open a hint when you need one.
Give me a hint
All exponentials are one, so only the denominator changes.
Compare with the solution
With three candidates, the positive probability is 1/3 and loss ln 3, approximately 1.0986. Excluding the alternate leaves probability 1/2 and loss ln 2, approximately 0.6931. Under the original labels, the alternate’s logit derivative is positive 1/3, pushing it down locally. A multi-positive objective is another possible declared policy; simply lowering loss is not evidence that labels or retrieval quality improved.
Keep the idea
Take it with you
- A useful hard negative is both confusing to the model and nonrelevant under the task policy.
- Unjudged candidates and teacher scores require an explicit uncertainty policy.
- Contrastive-loss improvements can hide harmful supervision errors.
Read further
Original sources and deeper explanations to follow at your own pace.
Optional progress, saved in this browser when available. Revisit any lesson at any time.
Lesson not marked complete.