A PPROXIMATE N EAREST N EIGHBOR N EGATIVE C ONTRASTIVE L EARNING FOR D ENSE T EXT R ETRIEVAL
Anonymous authors
Paper under double-blind review
A BSTRACT
Conducting text retrieval in a dense representation space has many intriguing advantages.
Yet the end-to-end learned dense retrieval (DR) often underperforms word-based sparse retrieval.
In this paper, we ﬁrst theoretically show the learning bottleneck of dense retrieval is the domination of uninformative negatives sampled locally in batch, which yield diminishing gradient norms, large stochastic gradient variances, and slow learning convergence.
We then propose Approximate nearest neighbor Negative Contrastive Learning (ANCE), a learning mechanism that selects hard training negatives globally from the entire corpus, using an asynchronously updated ANN index.
Our experiments demonstrate the effectiveness of ANCE on web search, question answering and in a commercial search environment, showing
ANCE dot-product retrieval nearly matches the accuracy of BERT-based cascade IR pipeline, while being 100x more efﬁcient.
We also empirically validate our theory that negative sampling with ANCE better approximates the oracle gradient-norm based importance sampling, thus improves the convergence of stochastic training.
I NTRODUCTION
Many language systems rely on text retrieval as their ﬁrst step to ﬁnd relevant information.
For example, search ranking (Nogueira & Cho, 2019), open domain question answering (OpenQA)
(Chen et al., 2017), and fact veriﬁcation (Thorne et al., 2018)
all ﬁrst retrieve relevant documents for their later stage reranking, machine reading, and reasoning models.
All these later-stage models enjoy the advancements of deep learning techniques (Rajpurkar et al., 2016; Wang et al., 2018), while, the ﬁrst stage retrieval still mainly relies on matching discrete bag-of-words, e.g., BM25, which has become the pain point of many systems (Nogueira & Cho, 2019; Luan et al., 2020;
Zhao et al., 2020).
Dense Retrieval (DR) aims to overcome the sparse retrieval bottleneck by matching texts in a continuous representation space learned via deep neural networks (Lee et al., 2019;
Karpukhin et al., 2020; Luan et al., 2020).
It has many desired properties: fully learnable representation, easy integration with pretraining, and efﬁciency support from approximate nearest neighbor (ANN) search (Johnson et al., 2019).
These grant dense retrieval an intriguing potential to fundamentally overcome some intrinsic limitations of sparse retrieval, for example, vocabulary mismatch (Croft et al., 2010).
A key challenge in dense retrieval is to construct proper negative instances when learning the representation space (Karpukhin et al., 2020).
Unlike in reranking (Liu, 2009) where the training negatives are naturally the irrelevant documents from previous retrieval stages, in ﬁrst stage retrieval,
DR models need to distinguish relevant documents from all irrelevant ones in a corpus with millions or billions of documents.
As illustrated in Fig.
1, these global negatives are quite different from negatives retrieved by sparse models.
Recent research explored various ways to construct negative training instances for dense retrieval (Huang et al., 2020;
Karpukhin et al., 2020), e.g., using contrastive learning (Faghri et al., 2017; Oord et al., 2018;
He et al., 2019; Chen et al., 2020a) to select hard negatives in current or recent mini-batches.
However, as observed in recent research (Karpukhin et al., 2020), the in-batch local negatives, though effective in learning word or visual representations, are not signiﬁcantly better than spare-retrieved negatives in representation learning for dense retrieval.
In addition, the accuracy of dense retrieval models often underperform BM25, especially on documents (Lee et al., 2019; Gao et al., 2020b; Luan et al., 2020).
[Figure]
In this paper, we ﬁrst theoretically analyze the convergence of dense retrieval training with negative sampling.
Using the variance reduction framework (Alain et al., 2015; Katharopoulos & Fleuret, 2018), we show that, under conditions commonly met in dense retrieval, local in-batch negatives lead to diminishing gradient norms, resulted in high stochastic gradient variances and slow training convergence — the local negative sampling is the bottleneck of dense retrieval’s effectiveness.
Based on our analysis, we propose Approximate nearest neighbor Negative Contrastive Estimation (ANCE), a new contrastive representation learning mechanism for dense retrieval.
Instead of random or in-batch local negatives, ANCE constructs global negatives using the beingoptimized DR model to retrieve from the entire corpus.
This fundamentally aligns the distribution of negative samples in training and of irrelevant documents to separate in testing.
From the variance reduction perspective, these ANCE negatives lift the upper bound of per instance gradient norm, reduce the variance of the stochastic gradient estimation, and lead to faster learning convergence.
We implement ANCE using an asynchronously updated ANN index of the corpus representation.
Similar to Guu et al.
, we maintain an Inferencer that parallelly computes the document encodings with a recent checkpoint from the being optimized DR model, and refresh the ANN index used for negative sampling once it ﬁnishes, to keep up with the model training.
Our experiments demonstrate the advantage of ANCE in three text retrieval scenarios: standard web search (Craswell et al., 2020), OpenQA (Rajpurkar et al., 2016; Kwiatkowski et al., 2019), and in a commercial search engine’s retrieval system.
We also empirically validate our theory that the gradient norms on ANCE sampled negatives are much bigger than local negatives, thus improving the convergence of dense retrieval models.
P RELIMINARIES
In this section, we discuss the preliminaries of dense retrieval and its representation learning.
Task Deﬁnition:
Given a query q and a corpus C , the ﬁrst stage retrieval is to ﬁnd a set of documents relevant to the query D + = { d 1 , ..., d i , ..., d n } from C ( | D + | (cid:28) | C | ), which then serve as input to later more complex models (Croft et al., 2010).
Instead of using sparse term matches and inverted index, Dense Retrieval calculates the retrieval score f
() using similarities in a learned embedding space (Lee et al., 2019;
Luan et al., 2020; Karpukhin et al., 2020):
[Equation]
where g () is the representation model that encodes the query or document to dense embeddings.
The encoder parameter θ provides the main capacity.
The similarity function (sim()) is often simply cosine or dot product to leverage efﬁcient ANN retrieval (Johnson et al., 2019; Guo et al., 2020). BERT-Siamese Model: A standard instantiation of Eqn.
1 is to use the BERT-Siamese/twotower/dual-encoder model (Lee et al., 2019;
Karpukhin et al., 2020; Luan et al., 2020): f (
[Equation]
BERT
[Equation] BERT [Equation] ( (cid:126)
[CLS
[Equation]
[Equation]
( (cid:126)
[CLS] d ) .
It encodes the query and document separately with BERT as the encoder g () , using their last layer’s
[CLS] token representation, and applied dot product ( · ) on them.
This enables ofﬂine precomputing of the document encodings and efﬁcient ﬁrst-stage retrieval.
In comparison, the BERT reranker (Nogueira et al., 2019) applies BERT on the concatenation of each to-rerank query-document pair: BERT( q ◦ d ), which has explicit access to term level interactions between query-document with transformer attentions, but is often infeasible in ﬁrst stage retrieval as enumerating all documents in the corpus for each query is too costly.
Learning with Negative Sampling:
The effectiveness of DR resides in learning a good representation space that maps query and relevant documents together, while separating irrelevant ones.
The learning of this representation often follows standard learning to rank (Liu, 2009):
Given a query q , a set of its relevant document D + q and irrelevant ones D − q , ﬁnd the best θ ∗ that:
[Equation]
The loss l () can be binary cross entropy (BCE), hinge loss, or negative log likelihood (NLL).
A unique challenge in dense retrieval, targeting ﬁrst stage retrieval, is that the irrelevant documents to separate are from the entire corpus ( D − q =
C \ D + q ) .
This often leads to millions of negative instances, which have to be sampled in training:
[Equation]
Here we start to omit the subscript q in D q .
All D + and D − are query dependent.
A natural choice is to sample negatives ˆ D − from top documents retrieved by BM25.
However, they may bias the DR model to merely mimic sparse retrieval (Luan et al., 2020).
Another way is to sample negatives in local mini-batches, e.g., as in contrastive learning (Oord et al., 2018), however, these local negatives do not signiﬁcantly outperform BM25 negatives (Karpukhin et al., 2020; Luan et al., 2020).
A NALYSES ON T HE C ONVERGENCE OF D ENSE R ETRIEVAL T RAINING
In this section, we theoretically analyze the convergence of dense retrieval training.
We ﬁrst show the connections between learning convergence and gradient norms (Sec. 3.1), then how local negatives in dense retrieval yield less optimal convergence (Sec. 3.2). 3. O RACLE N EGATIVE S AMPLING A CCORDING TO P ER -I NSTANCE G RADIENT -N ORM
Let l ( d + , d − ) =
l ( f ( q, d + ) , f ( q, d − ) be the loss function on the training triple ( q, d
+ , d − ) , P D − the negative sampling distribution for the given ( q, d + ) , and p d − the sampling probability of negative instance d − , a stochastic gradient decent (SGD) step with importance sampling (Alain et al., 2015) is:
[Equation]
(5) with θ t the parameter at t -th step, θ t +1 the one after, and N the total number of negatives.
The scaling factor [Equation] − ensures Eqn. 5 is an unbiased estimator of the non-stochastic gradient on the full data.
Then we can characterize the converge rate of this SGD step as the movement to optimal θ ∗ .
Following derivations in variance reduction (Katharopoulos & Fleuret, 2018; Johnson & Guestrin, 2018), let g d −
=
Np d − ∇ θ t l ( d + , d − ) the weighted gradient, the convergence rate is:
[Equation]
[Equation] [Equation] [Equation] This shows we can obtain better convergence rate by sampling from a distribution P D − that minimizes the variance of the stochastic gradient estimator E P D − ( || g d − || 2 ) , or Tr ( V P D − ( g d − ))
as the estimator is unbiased.
The variance reﬂects how good the stochastic gradient from negative sampling represents the full gradient on all negatives—the latter is ideal but infeasible thus sampling is required.
Intuitively, we prefer the stochastic estimator to be stable and have smaller variances.
A well known result in importance sampling (Alain et al., 2015; Johnson & Guestrin, 2018) is that there exists an optimal distribution that:
[Equation]
[Equation]
q 𝑑 !
𝐷 ! !"
Trainer
Inferencer q 𝑑 !
𝐷 ! !"
$ "
Checkpoint k- …
Checkpoint k q 𝑑 !
𝐷 ! !"
$ " q 𝑑 !
𝐷 ! ! "
Checkpoint k+ q 𝑑 !
𝐷 ! !"
Inferencing
Index & Search
[Figure]
To prove this, one can apply Jensen’s inequality on the gradient variance and verify that Eqn.achieves the minimum. The detailed derivations can be ﬁnd in Johnson & Guestrin (2018).
Eqn. 11 shows that the convergence rate can be improved by sampling negatives proportional to their per-instance gradient norms (though too expensive to calculate). Intuitively, an negative instance with larger gradient norm is more likely to reduce the non-stochastic training loss more, thus should be sampled more frequently than those with diminishing gradients. The correlation of larger gradient norm and better training convergence is also observed in BERT ﬁne-tuning (Mosbach et al., 2020).
Diminishing Gradients of Uninformative Negatives: Though the close form of gradient norms often does not exist, Katharopoulos & Fleuret (2018) derives the following upper bound: [Equation]
(12) where L is the number of layers, ρ is composed by pre-activation weights and gradients in intermediate layers, and ||∇ φ L l ( d + , d − )
|| [-
-]2 is the gradient on the last layer. The derivation of this upper bound is on multi-layer perception with any depths and any activation function that is Lipschitz continuous (Katharopoulos & Fleuret, 2018). On complicated neural networks, the intermediate layers are regulated by various normalization and this upper bound often holds empirically (Sec. 6.3). In addition, for many loss functions, for example, BCE loss and pairwise hinge loss, we can verify that when the loss goes to zero the gradient norm of the last layer also goes to zero:
{+l ( d + , d − ) → 0 ⇒ ||∇ φ L l ( d + , d − ) || 
+}
→ 0 (Katharopoulos & Fleuret, 2018).
Putting everything together, using uninformative negative samples with near zero loss results in the following chain of undesirable properties:
[Equation]
The uninformative negative samples yield diminishing gradient norms, larger variances of the scholastic gradient estimator, and less optimal learning convergence.
Inefﬁcacy of Local In-Batch Negatives: We argue that, when training DR models, the in-batch local negatives are unlikely to provide informative samples due to two properties of text retrieval.
Let D −∗ be the set of informative negatives that are hard to distinguish from D + , and b be the batch size, we have (1) b (cid:28) | C | , the batch size is far smaller than the corpus size; (2) | D −∗ | (cid:28) | C | , that only a few negatives are informative and the majority of corpus is trivially unrelated.
Both conditions can be veriﬁed empirically in dense retrieval.
The two together make the probability that a random mini-batch includes meaningful negatives ( p = b | D −∗ | | C | 2 ) close to zero.
Selecting negatives from local training batches unlikely provides optimal training signals for dense retrieval.
A PPROXIMATE N EAREST N EIGHBOR N OISE C ONTRASTIVE E STIMATION
Our analyses show the importance, if not necessity, to construct negatives globally from the corpus to avoid uninformative negatives for better learning convergence.
In this section, we propose A pproximate nearest neighbor N egative C ontrastive E stimation (ANCE), which selects negatives from the entire corpus using an asynchronously updated ANN index.
ANCE samples negatives from the top retrieved documents via the DR model from the ANN index:
[Equation]
with D − ANCE =
ANN f ( q,d ) \ D + and ANN f ( q,d ) the top retrieved documents by f () from the ANN index.
By deﬁnition, D − ANCE are the hardest negatives for the current DR model: D − ANCE ≈ D −∗ .
In theory, these more informative negatives have higher training loss, elevate the upper bound on the gradient norms (ﬁrst component of Eqn 13), and prevent the slow convergence indicated in Eqn 13.
ANCE can pair with many DR models.
For simplicity, we use BERT-Siamese (Eqn. 2), with shared encoder weights between q and d and negative log likelihood (NLL) loss (Luan et al., 2020).
Asynchronous Index Refresh:
During stochastic training, the DR model f () is updated each minibatch.
Maintaining an update-to-date ANN index to select fresh ANCE negatives is challenging, as the index update requires two operations: 1) Inference : refresh the representations of all documents in the corpus with an updated DR model; 2) Index : rebuild the ANN index using updated representations.
Although Index is efﬁcient (Johnson et al., 2019), Inference is too expensive to compute per batch as it requires a forward pass on a corpus much bigger than a training batch.
Thus we implement an asynchronous index refresh similar to Guu et al.
(2020), and update the ANN index once every m batches, i.e., with checkpoint f k .
As illustrated in Fig.
2, besides the Trainer, we run an Inferencer that takes the latest checkpoint (e.g., f k ) and recomputes the encodings of the entire corpus.
In parallel, the Trainer continues its stochastic learning using D − f k − 1 from ANN f k − 1 .
Once the corpus is re-encoded, the Inferencer updates the index (ANN f k ) and feed it to the Trainer.
In this process, the ANCE negatives ( D − ANCE ) are asynchronously updated to “catch up” with the stochastic training, with an async-gap determined by the computing resources allocated to the Inferencer.
Our experiment in Sec 6.4 studies the inﬂuence of this async-gap in learning convergence.
E XPERIMENTAL M ETHODOLOGIES
This section describes our experimental setups.
More details can be found in Appendix A.1 and A.2.
Benchmarks: The web search experiments use the TREC 2019 Deep Learning (DL) Track (Craswell et al., 2020).
It is a standard ad hoc retrieval benchmark: given web queries from Bing, to retrieval passages or documents from the MS MARCO corpus (Bajaj et al., 2016).
We use the ofﬁcial setting and focus on the ﬁrst stage retrieval, but also show results when reranking top 100 BM25 candidates.
The OpenQA experiments use the Natural Questions (NQ) (Kwiatkowski et al., 2019) and TriviaQA (TQA)
(Joshi et al., 2017), following the exact settings from Karpukhin et al.
The metrics are
Coverage@20/100, which evaluate whether the Top-20/100 retrieved passages include the answer.
We also evaluate whether ANCE’s better retrieval can propagate to better answer accuracy, by running the state-of-the-art systems’ readers on top of ANCE retrieval.
The readers are RAG-Token (Lewis et al., 2020b) on NQ and DPR Reader on TQA, using their suggested settings.
We also study the effectiveness of ANCE in the ﬁrst stage retrieval of a commercial search engine’s production system.
We change the training of a production-quality DR model to ANCE, and evaluate the ofﬂine gains in various corpus sizes, encoding dimensions, and exact/approximate search.
Baselines: In TREC DL, we include best runs in relevant categories and refer to Craswell et al.
(2020) for more baseline scores.
We implement various DR baselines using the same BERT-Siamese (Eqn. 2), but with different training negative construction: random sampling in batch (Rand Neg), random sampling from BM25 top 100 (BM25 Neg) (Lee et al., 2019;
Gao et al., 2020b) and the 1: combination of BM25 and Random negatives (BM25 + Rand Neg) (Karpukhin et al., 2020; Luan et al., 2020).
We also compare with contrastive learning/Noise Contrastive Estimation, which uses [Table] on Natural Questions (NQ) and Trivial QA (TQA) in the setting from Karpukhin et al. [Table]
[Table] hardest negatives in batch (NCE Neg) (Gutmann & Hyvärinen, 2010; Oord et al., 2018; Chen et al., 2020a).
In OpenQA, we compare with DPR, BM25, and their combinations (Karpukhin et al., 2020).
Implementation Details:
In TREC DL, recent research found MARCO passage training labels cleaner (Yan et al., 2019) and BM25 negatives can help train dense retrieval (Karpukhin et al., 2020;
Luan et al., 2020).
Thus, we include a “BM25 Warm Up” setting (BM25 → ∗ ), where the DR models are ﬁrst trained using MARCO ofﬁcial BM25 Negatives.
ANCE is also warmed up by BM negatives.
All DR models in TREC DL are ﬁne-tuned from RoBERTa base (Liu et al., 2019).
In
OpenQA, we warm up ANCE using the released DPR checkpoints (Karpukhin et al., 2020).
To ﬁt long documents in BERT-Siamese, ANCE uses the two settings from Dai & Callan (2019b),
FirstP which uses the ﬁrst 512 tokens of the document, and MaxP, where the document is split to 512-token passages (maximum 4) and the passage level scores are max-pooled.
The max-pooling operation is natively supported in ANN.
The ANN search uses the Faiss IndexFlatIP Index (Johnson et al., 2019).
We use batch size 8 and gradient accumulation step 2 on 4 GPUs.
For each positive, we uniformly sample one negative from ANN top 200.
We measured ANCE efﬁciency using one 32GB V100 GPU, Intel(R)
Xeon(R)
Platinum 8168 CPU and 650GB of RAM memory.
In asynchronous training, we allocate equal amounts of GPUs to the Trainer and the Inferencer, often four or eight each. The Trainer produces a model checkpoint every 5k or 10k training batches. The Inferencer loads the recent model checkpoint and calculates the embeddings of the corpus in parallel.
Once the embedding calculation ﬁnishes, a new ANN index is built and the Trainer switches to it for negative construction. All their communications are through a shared ﬁle system. On MS MARCO, the ANN negative index is refreshed about every 10K training steps.
Setting.
ANCE+Reader switches the retrieve of the OpenQA systems from DPR to ANCE and keeps their QA components, which is RAG-Token on Natural Questions (NQ) and DPR Reader on Trivia QA (TQA). T5 results are "closed-book".
The others are open-book.
[Table]
[Table] [Figure]  E VALUATION R ESULTS In this section, we ﬁrst evaluate the effectiveness and efﬁciency of ANCE.
Then we empirically study the convergence of ANCE training and the inﬂuence of the asynchronous gap.
More analyses can be found in Appendix, including the overlap of dense and sparse retrieval (A.2), hyperparameter study (A.3), and case study (A.4).
6. E FFECTIVENESS
In web search (Table 1), ANCE signiﬁcantly outperforms all sparse retrieval, including the BERTbased DeepCT (Dai et al., 2019).
Among DR models with different training strategies, ANCE is the only one robustly exceeding sparse methods in document retrieval.
In OpenQA, ANCE outperforms DPR and its fusion with BM25 (DPR+BM25) in retrieval accuracy (Table 2).
It also improves end-to-end QA accuracy, using the same QA components with previous state-of-the-arts but ANCE’s better retrieval (Table 4). ANCE’s effectiveness is even more observed in real production (Table 3).
Among all DR models, ANCE has the smallest gap between its retrieval and reranking accuracy, showing the importance of global negatives in training retrieval models.
ANCE retrieval nearly matches the accuracy of the cascade IR with interaction-based BERT Reranker (Nogueira & Cho, 2019), even though BERT-Siamese does not explicitly capture term-level interactions.
With ANCE, we can learn a representation space that effectively captures the ﬁnesse of search relevance. 6. E FFICIENCY
The efﬁciency of ANCE (FirstP) in TREC DL doc retrieval is shown in Table 5.
In serving , we measure the online latency to retrieve/rank 100 documents per query, in the batch setting.
DR provides a 100x speed up compared to BERT Rerank .
This is a natural beneﬁt of BERT-Siamese, where the document encodings are calculated ofﬂine and separately with the query. Only query encoding and the dot product are online. In comparison, the interaction-based BERT Reranker runs BERTtimes, once per query and each of the 100 candidate documents. Its expensive online operation often
[Figure] [Figure]
requires caching and distillation.
In training , the bulk of computing is to recalculate the encoding of the corpus for ANCE negative construction.
Assuming the same DR model is used to construct negatives from the same corpus, this is inevitable but can be mitigated by asynchronous index refresh.
6. E MPIRICAL A NALYSES ON T RAINING C ONVERGENCE
We ﬁrst show the long tail distribution of search relevance in dense retrieval.
As plotted in Fig.
3, there are a few instances per query with signiﬁcant higher retrieval scores, while the majority form a long tail.
In retrieval/ranking, the key challenge is to distinguish the relevant ones among those highest scored ones; the rest is trivially irrelevant.
We also empirically measure the probability of local in-batch negatives including informative negatives ( D −∗ ), by their overlap with top 100 highest scored negatives.
This probability, either using NCE Neg or Rand Neg, is zero , the same as our theory shows.
In comparison, the overlap between BM25 Neg with top dense retrieved negatives is 15%, while that of ANCE negatives starts at 63% and converges to 100% by design.
Then we empirically validate our theory that local negatives lead to lower loss, bounded gradient norm, non-ideal importance sampling, and thus slow convergence (Eqn. 13).
The training loss and pre-clip gradient norms during DR training are plotted in Fig.
As expected, the uninformative local negatives resulted in near-zero gradient norms, while ANCE global negatives maintain a higher gradient norm.
The gradient norm of the last layer in the BERT-Siamese model during ANCE training (black dotted lines in Fig. 4) is consistently bigger than the other layers, which empirically aligns with the upper bound in Eqn.
Also as our theory suggests, the gradient norms of local negatives are bounded close to zero, while those of ANCE global negatives are bigger by orders of magnitude.
This conﬁrms ANCE better approximates the oracle importance sampling distribution ( p ∗ d − ∝ ||∇ θ t l ( d + , d − ) || 2 ) and improves learning convergence.
6. I MPACT OF A SYNCHRONOUS G
AP
The need for global negatives enforces an asynchronous gap (async-gap) in ANCE training: The negatives are selected using the encodings from an earlier stage of the being optimized DR model.
The async-gap is determined by the target index refreshing rate, which is determined by the allocation of computing resource on the Trainer versus the Inferencer, as well as the learning rate.
This experiment studies the impact of this async-gap in ANCE training. The training curves and testing NDCG of different conﬁgurations are plotted in Fig.
A too large async-gap, either from large learning rate (Fig. 5(a)) or low refreshing rate (Fig. 5(b)), makes the training unstable, perhaps because the refreshed index changes too dramatically, as indicated by the peaks in training loss and dips of testing NDCG.
The async-gap is not signiﬁcant when we allocate an equal amount of GPUs to the index refreshing and to the training (Fig. 5(d)).
Further reducing the gap (Fig. 5(c)) does not improve learning convergence. In many scenarios, using a same amount of extra GPUs for ANCE as a one-time training cost is a good return of investment. The efﬁciency bottleneck in production is often in inference and serving, where ANCE thrives.
R ELATED W ORK
In early research on neural information retrieval (Neu-IR)
(Mitra et al., 2018), a common belief was that the interaction models, those that explicitly handle term level matches, are more effective though more expensive (Guo et al., 2016; Xiong et al., 2017; Nogueira & Cho, 2019).
Many techniques are developed to reduce their cost, for example, distillation (Gao et al., 2020a) and caching (Humeau et al., 2020; Khattab & Zaharia, 2020; MacAvaney et al., 2020).
ANCE shows that a properly trained representation-based BERT-Siamese is in fact as effective as the interaction-based BERT ranker.
This ﬁnding will motivate many new research explorations in Neu-IR.
Deep learning has been used to improve various components of sparse retrieval, for example, term weighting (Dai & Callan, 2019b), query expansion (Zheng et al., 2020), and document expansion (Nogueira et al., 2019).
Dense Retrieval chooses a different path and conducts retrieval purely in the embedding space via ANN search (Lee et al., 2019;
Chang et al., 2020; Karpukhin et al., 2020;
Luan et al., 2020).
This work demonstrates that a simple dense retrieval system can achieve SOTA accuracy, while also behaves dramatically different from classic retrieval.
The recent advancement in dense retrieval may raise a new generation of search systems.
Recent research in contrastive representation learning also shows the beneﬁts of sampling negatives from a larger candidate pool.
In computer vision, He et al.
(2019) decouple the negative sampling pool size with training batch size, by maintaining a negative candidate pool of recent batches and updating their representation with momentum.
This enlarged negative pool signiﬁcantly improves unsupervised visual representation learning (Chen et al., 2020b).
A parallel work (Xiong et al., 2020) improves DPR by sampling negatives from a memory bank (Wu et al., 2018) — in which the representations of negative candidates are frozen so more candidates can be stored.
Instead of a bigger local pool, ANCE goes all the way along this trajectory and constructs negatives globally from the entire corpus, using an asynchronously updated ANN index.
Besides being a real world application itself, dense retrieval is also a core component in many other language systems, for example, to retrieval relevant information for grounded language models (Khandelwal et al., 2019; Guu et al., 2020), extractive/generative QA (Karpukhin et al., 2020; Lewis et al., 2020b), and fact veriﬁcation (Xiong et al., 2020), or to ﬁnd paraphrase pairs for pretraining (Lewis et al., 2020a).
There dense retrieval models are either frozen or optimized indirectly by signals from their end tasks.
ANCE is orthogonal with those lines of research and focuses on the representation learning for dense retrieval.
Its better retrieval accuracy can beneﬁt many language systems.
C ONCLUSION
In this paper, we ﬁrst provide theoretical analyses on the convergence of representation learning in dense retrieval.
We show that under common conditions in text retrieval, the local negatives used in DR training are uninformative, yield low gradient norms, and contribute little to the learning convergence.
We then propose ANCE to eliminate this bottleneck by constructing training negatives globally from the entire corpus.
Our experiments demonstrate the advantage of ANCE in web search,
OpenQA, and the production system of a commercial search engine.
Our studies empirically validate our theory that ANCE negatives have much bigger gradient norms, reduce the stochastic gradient variance, and improve training convergence.
A A PPENDIX A. M ORE E XPERIMENTAL D ETAILS
More Details on TREC DL Benchmarks: There are two tasks in the TREC DL 2019 Track: document retrieval and passage retrieval.
The training and development sets are from MS MARCO, which includes passage level relevance labels for one million Bing queries (Bajaj et al., 2016).
The document corpus was post-constructed by back-ﬁlling the body texts of the passage’s URLs and their labels were inherited from its passages (Craswell et al., 2020).
The testing sets are labeled by NIST accessors on the top 10 ranked results from past Track participants (Craswell et al., 2020).
TREC DL ofﬁcial metrics include NDCG@10 on test and MRR@10 on MARCO Passage Dev.
MARCO Document Dev is noisy and the recall on the DL Track testing is less meaningful due to low label coverage on
DR results.
There is a two-year gap between the construction of the passage training data and the back-ﬁlling of their full document content.
Some original documents were no longer available.
There is also a decent amount of content changes in those documents during the two-year gap, and many no longer contain the passages.
This back-ﬁlling perhaps is the reason why many Track participants found the passage training data is more effective than the inherited document labels.
Note that the TREC testing labels are not inﬂuenced as the annotators were provided the same document contents when judging.
All the TREC DL runs are trained using these training data.
Their inference results on the testing queries of the document and the passage retrieval tasks were evaluated by NIST assessors in the standard TREC-style pooling technique (Voorhees, 2000).
The pooling depth is set to 10, that is, the top 10 ranked results from all participated runs are evaluated, and these evaluated labels are released as the ofﬁcial TREC DL benchmarks for passage and document retrieval tasks.
More Details on OpenQA Experiments: All the DPR related experimental settings, baseline systems, and DPR Reader are based on their open source libarary 2 .
The RAG-Token reader uses their open-source release in huggingface 3 .
The RAG-Seq release in huggingface is not yet stable by the time we did our experiment, thus we choose the RAG-Token in our OpenQA experiment.
RAG only releases the NQ models thus we use DPR reader on TriviaQA. We feed top 20 passages from ANCE to RAG-Token on NQ and top 100 passages to DPR’s BERT Reader, following the guideline in their open-source codes. More Details on Baselines: The most representative sparse retrieval baselines in TREC DL include the standard BM25 (“bm25base” or “bm25base_p”), Best TREC Sparse Retrieval (“bm25tuned_rm3” or “bm25tuned_prf_p”) with tuned query expansion (Lavrenko & Croft, 2017), and Best DeepCT (“dct_tp_bm25e2”, doc only), which uses BERT to estimate the term importance for BM25 (Dai & Callan, 2019a).
These three runs represent the standard sparse retrieval, best classical sparse retrieval, and the recent progress of using BERT to im- prove sparse retrieval.
We also include the standard cascade retrieval-and-reranking systems BERT Reranker (“bm25exp_marcomb” or “p_exp_rm3_bert”), which is the best run using standard BERT on top of query/doc expansion, from the groups with multiple top MARCO runs (Nogueira & Cho, 2019; Nogueira et al., 2019).
BERT-Siamese Conﬁgurations: We follow the network conﬁgurations in Luan et al.
(2020) in all Dense Retrieval methods, which we found provides the most stable results.
More speciﬁcally, we initialize the BERTSiamese model with RoBERTa base (Liu et al., 2019) and add a 768 × 768 projection layer on top of the last layer’s “
[CLS]” token, followed by a layer norm.
We use BERT-Siamese, NLL loss, and dot product to be consistent with recent research.
We have obtained better accuracy with more vectors per document, BCE loss, and cosine similarity, but that is not the focus of this paper.
Implementation Details: The training often takes about 1-2 hours per ANCE epoch, which is whenever new ANCE negative is ready, it immediately replaces existing negatives in training, without waiting.
It converges in about 10 epochs, similar to other DR baselines.
The optimization uses LAMB optimizer, learning rate 5e-6 for document and 1e-6 for passage retrieval, and linear warm-up and decay after 5000 steps.
More detailed hyperparameter settings can be found in our code release.
A. O VERLAP WITH S PARSE R ETRIEVAL IN TREC 2019 DL T RACK
As a nature of TREC-style pooling evaluation, only those ranked in the top 10 by the 2019 TREC participating systems were labeled.
As a result, documents not in the pool and thus not labeled are all considered irrelevant, even though there may be relevant ones among them.
When reusing TREC style relevance labels, it is very important to keep track of the “hole rate” on the evaluated systems, i.e., the fraction of the top K ranked results without TREC labels (not in the pool).
A larger hole rate shows that the evaluated methods are very different
[Table]
[Table]
from those systems that participated in the Track and contributed to the pool
[Table]
thus the evaluation results are not perfect.
Note that the hole rate does not necessarily reﬂect the accuracy of the system, only the difference of it.
In TREC
Deep Learning Track, all the participating systems are based on sparse retrieval.
Dense retrieval methods often differ considerably from sparse retrievals and in general will retrieve many new documents.
This is conﬁrmed in Table 6.
All DR methods have very low overlap with the ofﬁcial BM25 in their top 100 retrieved documents.
At most, only 25% of documents retrieved by DR are also retrieved by BM25.
This makes the hole rate quite high and the recall metric not very informative.
It also suggests that DR methods might beneﬁt more in this year’s TREC
Deep Learning Track
if participants are contributing DR based systems.
The MS MARCO ranking labels were not constructed based on pooling the sparse retrieval results.
They were from Bing (Bajaj et al., 2016), which uses many signals beyond term overlap.
This makes the recall metric in
MS MARCO more robust as it reﬂects how a single model can recover a complex online system.
A. H YPERPARAMETER S TUDIES
We show the results of some hyperparameter conﬁgurations in Table 7.
The cost of training with BERT makes it difﬁcult to conduct a lot hyperparameter exploration.
Often a failed conﬁguration leads to divergence early in training.
We barely explore other conﬁgurations due to the time-consuming nature of working with pretrained language models.
Our DR model architecture is kept consistent with recent parallel work and the learning conﬁgurations in Table 7 are about all the explorations we did.
Most of the hyperparameter choices are decided solely using the training loss curve and otherwise by the loss in the MARCO Dev set.
We found the training loss, validation NDCG, and testing performance align well in our (limited) hyperparameter explorations. A. C ASE S TUDIES In this section, we show Win/Loss case studies between ANCE and BM25. Among the 43 TREC 2019 DL Track evaluation queries in the document task, ANCE outperforms BM25 on 29 queries, loses on 13 queries, and ties on the rest 1 query.
The winning examples are shown in Table 8 and the losing ones are in Table 9. Their corresponding ANCE-learned (FirstP) representations are illustrated by t-SNE in Fig. 6 and Fig. In general, we found ANCE better captures the semantics in the documents and their relevance to the query.
The winning cases show the intrinsic limitations of sparse retrieval.
For example, BM25 exact matches the “most popular food” in the query “what is the most popular food in Switzerland” but using the document is about Mexico.
The term “Switzerland” only appears in the related question section of the web page.
The losing cases in Table 9 are also quite interesting.
Many times we found that it is not that DR fails completely and retrieves documents not related to the query’s information needs at all, which was a big concern when we started research in DR.
The errors ANCE made include retrieving documents that are related just not exactly
[Table]
Swiss cuisine bears witness to many re- gional inﬂuences, ...
[Table]
was historically a country of farmers, so tra- ditional Swiss dishes tend not to be...
One of the most popular traditional Mex- ican deserts is a spongy cake
[Table]
(in the related questions section)
[Table]
is the most popular food dish in Switzerland?.
[Table]
[Table]
visceral, you feel it in your guts.
A visceral feeling is intuitive — there might not be a rational explanation, but you feel that you know what’s best...
Acetylcholine A neurotransmitter liber- ated by many peripheral nervous system neurons and some central nervous sys- tem neurons...
Ranking Position:
TREC Label: 3 (Very Relevant) {+
+}
(Irrelevant)
NDCG@10: 0.
[Figure]
[Figure]
relevant to the query, for example, “yoga pose” for “bow in yoga”. In other cases, ANCE retrieved wrong documents due to the lack of the domain knowledge: the pretrained language model may not know “active margin” is a geographical terminology, not a ﬁnancial one (which we did not know ourselves and took some time to ﬁgure out when conducting this case study).
There are also some cases where the dense retrieved documents make sense to us but were labeled irrelevant.
The t-SNE plots in Fig.
6 and Fig.
7 show many interesting patterns of the learned representation space. The ANCE winning cases often correspond to clear separations of different document groups.
For losing cases the representation space is more mixed, or there is too few relevant documents which may cause the variances in
[Table]
An active continental margin is found on the leading edge of the continent
[Table]
DocNo:
D D
Snippet: so i’ve been doing yoga for a few weeks now and already notice that my ﬂexiablity has increased drastically. ...
That depends on the posture itself ...
Bow Pose is an intermediate yoga back- bend that deeply opens the chest and the front of the body...
Hold for up to 30 seconds ...
Ranking [Table]
[Figure]
TREC Label: 0 (Irrelevant)[-
-]
[Figure]
[Figure]
NDCG@10:
[Figure]
[Figure]
model performances.
There are also many different interesting patterns in the ANCE-learned representation space.
We include the t-SNE plots for all 43 TREC DL Track queries in the supplementary material.
More future analyses of the learned patterns in the representation space may help provide more insights on dense retrieval.