Dual encoder models are ubiquitous in modern classification and retrieval. Crucial for training such dual encoders is an accurate estimation of gradients from the partition function of the softmax over the large output space; this requires finding negative targets that contribute most significantly ("hard negatives"). Since dual encoder model parameters change during training, the use of traditional static nearest neighbor indexes can be sub-optimal. These static indexes (1) periodically require expensive re-building of the index, which in turn requires (2) expensive re-encoding of all targets using updated model parameters. This paper addresses both of these challenges. First, we introduce an algorithm that uses a tree structure to approximate the softmax with provable bounds and that dynamically maintains the tree. Second, we approximate the effect of a gradient update on target encodings with an efficient Nystrom low-rank approximation. In our empirical study on datasets with over twenty million targets, our approach cuts error by half in relation to oracle brute-force negative mining. Furthermore, our method surpasses prior state-of-the-art while using 150x less accelerator memory.
翻译:双编码器模型在现代分类和检索中无处不在。训练这样的双编码器的关键是从大型输出空间中的softmax的分区函数中准确估计梯度;这需要找到对贡献最显著的负样本(“难样本”)。由于双编码器模型参数在训练过程中发生变化,使用传统的静态最近邻索引可能是次优的。这些静态索引:(1)定期需要昂贵的索引重构,这反过来又需要(2)使用更新后的模型参数进行昂贵的重新编码。本文解决了这两个挑战。首先,我们介绍了一种使用树结构来逼近softmax的算法,并动态维护树。其次,我们使用高效的Nystrom低秩逼近方法,近似梯度更新对目标编码的影响。在超过2000万个目标的数据集的实证研究中,我们的方法将误差降低了一半,相对于最基本的负样本挖掘。此外,我们的方法在使用150倍更少的加速器内存的情况下超过了之前的最新技术。