NV-Retriever: Improving text embedding models with effective hard-negative mining
TL;DR. Hard negatives make contrastive training work, but the top-ranked “negatives” for a query often include unlabelled positives. NV-Retriever proposes positive-aware mining: keep a mined negative only if the teacher scores it below the positive’s score minus a margin (TopK-MarginPos) or below a percentage of it (TopK-PercPos). With E5-Mistral as the teacher and a bidirectional Mistral-7B student, NV-Retriever-v1 scored 60.9 on MTEB Retrieval and was ranked first on 2024-07-11.
Key idea
Section titled “Key idea”For a query with positive , a teacher scores candidate negatives . Earlier filters ignore : top-k shifted by N skips the first ranks, and TopK-Abs drops any above a fixed score. NV-Retriever’s rule is relative to the positive:
with best settings and , then the top-k survivors are used as hard negatives. The paper also compares teachers and ensembles of teachers.
The model is Mistral-7B-v0.1 with bidirectional attention, mean pooling of the last layer and 4,096-d embeddings, trained with LoRA (rank 16, α 32) and query and passage lengths of 192 and 512 tokens. Training has two stages of 12 epochs each: retrieval data with 1 hard negative plus in-batch negatives, then 5 hard negatives on a blend that adds non-retrieval tasks. It takes about 90 hours on 8 A100s.
Results
Section titled “Results”With an e5-large-unsupervised student (top-4 negatives, average over NQ, HotpotQA and FiQA), naive top-k gives 0.5407, top-k shifted by 10 gives 0.5695, TopK-Abs 0.5759, TopK-MarginPos 0.5835 and TopK-PercPos 0.5856 (Table 3). With a Mistral-7B student, PercPos lifts the same average from 0.6214 to 0.6479 (Table 4). In the scaled setup, MarginPos reaches 59.77 and PercPos 60.55 on full MTEB Retrieval, against 54.66 (shifted) and 55.81 (Abs). The released NV-Retriever-v1 scores 60.9. Its training sets follow E5-Mistral and NV-Embed-v1, so several of them are training splits of BEIR datasets. The arXiv record lists no venue.
Connections
Section titled “Connections”- Recipe hub: Embedding recipes compared.
- Teacher and sibling: E5-Mistral (the mining teacher) and NV-Embed, which applies positive-aware mining to curate its training data.
- Adopted by: Nomic Embed v2 and Llama-Embed-Nemotron, which uses TopK-PercPos at 0.95.
- Bidirectional decoders: LLM2Vec.
- Background: E5 for the earlier large-batch, in-batch-negative recipe.
Questions to think through
These questions have no single right answer. Write or say your answer before you open the hints. Mark a question once you could defend your answer in a reading group.
- Mechanism
Explain, at the level of the InfoNCE gradient, why a false negative in the hard-negative set hurts more than a random one, and why a threshold relative to the positive score (TopK-PercPos keeps n only if s(q,n) < 0.95 · s(q,p)) handles this better than a fixed rank shift (skip the top 10) or an absolute threshold (drop n if s(q,n) > 0.7).
What a strong answer covers
- With softmax over the positive and negatives, the gradient pushes each negative down in proportion to its softmax weight. A false negative is, by construction, scored about as high as the positive, so it gets a large weight and a strong push in the wrong direction: the model is taught to separate two relevant passages.
- A random negative has a low score and a small weight, so even if it were relevant its effect is small. Hard negatives help precisely because they carry large weights, which is also why they are dangerous when mislabelled.
- A rank shift ignores scores: for a query with many relevant passages, ranks 11–20 may still be positives; for a query with one, it throws away the most useful hard negatives at ranks 1–10.
- An absolute threshold ignores the query: score scales differ across queries, so 0.7 can be too strict for one and too loose for another.
- Tying the threshold to the positive score calibrates per query: it removes negatives that the teacher cannot tell apart from the known positive, and keeps the rest as close to it as possible.
- Derive / compute
From Table 3 (e5-large-unsupervised student, top-4 negatives, average nDCG@10 over NQ, HotpotQA and FiQA): naive top-k 0.5407, top-k shifted by 10 0.5695, TopK-Abs 0.7 0.5759, TopK-MarginPos 0.05 0.5835, TopK-PercPos 95% 0.5856. In the scaled Mistral-7B setup over 15 BEIR datasets (Table 5): naive 51.44, shifted 54.66, Abs 55.81, MarginPos 59.77, PercPos 60.55. (a) Compute each method's gain over naive in both setups, in absolute points and as a share of the PercPos gain. (b) For a positive scored 0.80, what is the highest negative score each positive-aware rule allows? (c) What does the comparison of the two setups suggest about how false negatives scale?
What a strong answer covers
- (a) Small setup (×100): shifted +2.88, Abs +3.52, MarginPos +4.28, PercPos +4.49; as shares of PercPos: 64%, 78%, 95%, 100%. Scaled setup: +3.22, +4.37, +8.33, +9.11; shares 35%, 48%, 91%, 100%.
- (b) MarginPos: 0.80 − 0.05 = 0.75. PercPos: 0.95 × 0.80 = 0.76. Similar at this score; they diverge at the extremes (for a positive at 0.40, 0.35 vs 0.38).
- (c) The gap between positive-aware and score-agnostic methods is much larger at scale (4.7 points over Abs at scale vs about 1.0 in the small setup). With more training data and a stronger 7B student, mislabelled hard negatives do more damage, or the model has more capacity to learn from them, so filtering matters more.
- Caveat: one run per configuration, no seeds, and the best thresholds come from an ablation evaluated on the same three datasets reported in Table 3.
- Design
You are training a retriever for a deep-research agent on synthetic queries generated from web pages, where each query has exactly one labelled positive (its source page) but the corpus surely contains other relevant pages. You have E5-Mistral as a teacher and a budget for one LLM judge pass on a sample. Design the hard-negative pipeline with NV-Retriever's method and a way to set the threshold without tuning on the test set.
What a strong answer covers
- Mine the top 50–100 candidates with the teacher, then keep the top k (for example 4–7) with s(q,n) < perc · s(q,p). Single-positive synthetic queries are exactly where naive top-k produces many false negatives (the paper measures 38.8% on NQ and 47% on StackExchange with an LLM judge).
- Set perc on a held-out validation split, not on BEIR test sets. Use the LLM judge on a sample of kept negatives to estimate the false-negative rate at several thresholds, and choose the point where the rate stops dropping quickly.
- Teacher choice matters as much as the filter: in Table 1, E5-Mistral gives 0.5810 vs 0.5002 for BM25 negatives. Ensembling four teachers did not help (0.5825 at best, Table 2).
- Check the cost: mining with E5-Mistral takes about 1.5 hours per 1M documents on 8 A100s, so mine once and reuse across runs.