Dual-Encoders for Extreme Multi-label Classification

Nilesh Gupta, Fnu Devvrit, Ankit Singh Rawat, Srinadh Bhojanapalli, Prateek Jain, Inderjit S Dhillon

This paper challenges the prevailing wisdom in the Extreme Multi-label Classification (XMC) community. While state-of-the-art (SOTA) models have grown increasingly bloated to handle millions of labels, the authors demonstrate that a lean, standard Dual-Encoder (DE) architecture can actually outperform these giants—provided it is trained with the right loss function.

TL;DR

The authors introduce DEXML, a training framework that allows pure dual-encoder models to achieve state-of-the-art performance on massive multi-label datasets. By replacing standard contrastive losses with a new "Decoupled Softmax" and a differentiable "Soft Top-k" loss, they match and even exceed SOTA performance while using 20x fewer parameters.

The Challenge of Extreme Multi-label Classification

In Extreme Multi-label Classification (XMC), the goal is to tag a query (like a search term) with the most relevant labels from a pool of millions (like products in a massive catalog).

Historically, XMC has been dominated by models that use a "per-class classification head." This means the model maintains a unique set of learnable weights for every single label. As the number of labels grows into the millions, these models become massive, memory-intensive, and difficult to scale efficiently.

In contrast, Dual-Encoders (DE)—which represent both queries and labels as vectors in a shared embedding space—are much smaller and generalize better to new labels. However, DE models have historically performed poorly on XMC benchmarks. The common belief was that DE models lacked the "capacity" to memorize the complex relationships inherent in XMC data. This paper proves that the problem isn't the model's capacity, but rather the loss functions traditionally used to train them.

Rethinking the Loss Function

The authors identify that standard losses like InfoNCE (common in retrieval) and Softmax Cross-Entropy are "coupled." In a multi-label setting, these losses force all positive labels for a single query to compete for probability mass. If one label is "easy" to predict, the loss function effectively penalizes the other "harder" positive labels, stunting the model's learning.

To fix this, they propose three key innovations:

  1. Decoupled Softmax Loss: A simple but highly effective modification to InfoNCE that removes the correlation between positive labels. Each positive label is evaluated against the negatives independently, preventing "easy" positives from suppressing the learning of others.
  2. Soft Top-k Loss: A differentiable version of the top-k operator. This loss is specifically tailored for scenarios where the primary concern is the model's accuracy within a fixed budget (e.g., ensuring the right answer is in the top 5 results).
  3. Memory-Efficient Distributed Training: To handle millions of labels, the team implemented a modified gradient caching technique. This allows them to train with a "full" loss (considering all negatives) on a modest GPU setup by avoiding the storage of massive intermediate activation tensors.

Key Insights and Gradient Stability

One of the most significant findings is the impact of the loss function on gradient stability. Standard softmax produces high-variance, noisy gradients in multi-label settings. As shown below, the proposed Decoupled Softmax provides much more consistent and stable gradient feedback, which is crucial for effectively training deep transformers.

Gradient analysis shows Decoupled Softmax (blue) provides much more stable feedback than standard Softmax (orange).

Furthermore, through synthetic experiments with random text correlations, the authors debunked the "memorization myth." They proved that Dual-Encoders can achieve perfect accuracy on massive datasets, demonstrating that DEs are not inherently limited in their ability to memorize label mappings when trained correctly.

State-of-the-Art Results with a Fraction of the Parameters

The results clearly show that in the realm of XMC, bigger isn't always better. Because DE models use a shared encoder for labels rather than a per-class head, their size doesn't explode as the label set grows.

  • SOTA Performance: On the massive LF-AmazonTitles-1.3M dataset, DEXML achieved a Precision@1 of 58.40%, outperforming the previous SOTA (DEXA) which scored 56.63%.
  • 20x Smaller: Remarkably, DEXML achieved these results with roughly 66 million parameters, while the previous SOTA required over 1.3 billion parameters.
DEXML achieves higher precision than NGAME and DEXA while using significantly fewer training parameters.

Limitations and Future Work

While DEXML presents a massive leap forward for parameter-efficient retrieval, the authors note a few areas for future exploration:

  • Scaling to Billions: While 1.3 million labels is "extreme," real-world web search involves billions of items. Testing the fundamental capacity limits of DEs at the billion-scale is a critical next step.
  • Inference Speed: Dual-encoders rely on external Approximate Nearest Neighbor (ANN) search libraries (like Faiss) for fast inference. Exploring how to integrate built-in hierarchical search structures could further optimize inference times.
  • Negative Mining: The paper emphasizes the benefits of using "all negatives" during training, but this becomes computationally prohibitive at even larger scales. Developing better hard-negative mining strategies that approximate the "all negative" loss remains an open area for research.

Summary updated

BibTeX
@inproceedings{gupta2024dual,
  author = {Nilesh Gupta and Fnu Devvrit and Ankit Singh Rawat and Srinadh Bhojanapalli and Prateek Jain and Inderjit S Dhillon},
  title = {{Dual-Encoders for Extreme Multi-label Classification}},
  booktitle = {International Conference on Learning Representations},
  year = {2024},
  url = {https://openreview.net/forum?id=dNe1T0Ahby},
}
Figure