When a classifier must choose among hundreds of thousands of labels, such as products in a catalog or categories in a document taxonomy, computing the full softmax is expensive. The full softmax is the normalization that divides each label's score by the sum over all labels. Practitioners therefore approximate that sum with a small sample of "negative" labels at each step. This note argues that the approximation has a specific, measurable, and so far unexamined failure on rare labels.
A label's weight vector is pushed away from wrong inputs only in the steps where that label happens to be drawn as a negative. Frequency-based or hashing-based samplers almost never draw rare labels. Rare labels are therefore "starved" of corrective updates. Their scores end up miscalibrated, and they fire on the wrong inputs. We propose to measure this starvation directly, to separate the part of the damage that a cheap after-the-fact correction can repair from the part it cannot, and to test a sampler that guarantees every label a minimum number of negative appearances per epoch.
The stakes are both practical and methodological. In extreme classification, tail labels are the rare events: each covers a vanishing fraction of training examples, and the commercial value often sits there. Reported gains for fast samplers are mostly speedups and aggregate accuracy, which the head labels dominate. Rare-label error is also noisy to measure, so conclusions about it are fragile across seeds and hyperparameters. That makes this a reproducibility problem as well as a modeling one.
Core Claim
Sampled-softmax error on a class $j$ should scale with its negative exposure: the expected number of times $j$ appears in a sampled denominator during training. For a sampler that includes class $j$ with probability $q_j$ per step, with $k$ samples per step over $S$ steps, exposure is roughly $E_j \approx S k q_j$.
Under frequency-proportional sampling, $q_j$ tracks label frequency, so a rare class is starved twice over. It is seldom a target, and it is seldom a negative.
We claim that this starvation produces two distinct errors:
- An offset error. Each rare class's score is shifted by a roughly constant amount. Refitting one bias term per class against the exact softmax, after training, should remove this error.
- A direction error. The rare class's weight vector points the wrong way, because it was never repelled from the inputs it now wrongly fires on. No per-class bias correction can fix this.
The new contribution is this decomposition and a test of which error dominates. If the offset error dominates, the right recommendation is a cheap post-hoc fix, and we will say so. If the direction error dominates, a sampler with an exposure floor is needed. The floor adds a round-robin component that guarantees each class at least $e_{\min}$ negative appearances per epoch, at an extra cost of about $K e_{\min}/S$ classes per step, where $K$ is the number of classes.
How This Relates to Prior Work
Motivating results on sampled softmax. Sampled Estimators For Softmax Must Be Biased proves that no logit-independent sampled estimator of the softmax denominator is unbiased. It does not say where the bias lands; we ask how it is distributed across class frequency. Complementary Sum Sampling for Likelihood Approximation in Large Scale Classification shows that forcing the target class into the sampled sum bounds the gradients. That fixes the target side of the update but leaves the negative side, where starvation occurs, untouched.
The method family we test against. A Tale of Two Efficient and Informative Negative Sampling Distributions uses locality-sensitive hashing to retrieve hard negatives in near-constant time. Locality-sensitive hashing groups similar vectors into the same bucket so near neighbors can be found without a full scan. We suspect this makes starvation worse: a rare class whose weights sit near initialization rarely collides with query vectors. That is a testable prediction the paper did not examine.
One-vs-Each Approximation to Softmax for Scalable Estimation of Probabilities replaces the softmax with a bound built from pairwise comparisons. Rare classes still enter only through sampled pairs, so the same exposure analysis applies to it.
The temperature and hyperparameter lens. Unpacking Softmax: How Temperature Drives Representation Collapse, Compression, and Generalization shows that softmax temperature controls how many feature dimensions a network keeps. On ImageNet-100, the effective dimensionality of its representations (its rank) drops from 99 to 27 without loss of accuracy. That work uses balanced data and exact softmax. We ask whether the dimensions pruned at high temperature are exactly those that rare classes need, and whether sampling amplifies the effect.
The contrastive-learning literature gives the same warning about sensitivity. Contrastive Representation Distillation reports that temperature and negative count must be re-tuned for each dataset. Negatives-Dominant Contrastive Learning for Generalization in Imbalanced Domains up-weights negatives to protect minority classes, but only with 5 to 65 classes. Time-Series Contrastive Learning against False Negatives and Class Imbalance handles imbalance with fewer than six classes. Neither faces a sampled denominator. Our exposure floor is the large-label analogue of "negatives-dominant" weighting, applied by controlling which classes appear rather than how much they are weighted.
Evaluation constraints. Needle in a Haystack: Label-Efficient Evaluation under Extreme Class Imbalance shows that passive evaluation under extreme imbalance yields jagged, untrustworthy precision-recall curves. Its adaptive importance sampling concentrates labeling effort where the model's scores are uncertain, which gives consistent estimates. We use it to put confidence intervals on per-frequency-bin metrics.
CLIMB: Class-imbalanced Learning Benchmark on Tabular Data supplies a model for reproducible imbalance benchmarking: a unified Optuna budget of 100 trials per method. It deliberately excludes deep models and large label spaces, and we extend its protocol to both.
Research Program
Isolating the output layer. The first component removes the confound of representation learning. We take an encoder trained with full softmax on each benchmark, freeze it, and retrain only the output layer. With frozen features, the full-softmax objective over the output weights is convex, so its exact optimum can be computed once, which is expensive but feasible. Every sampler can then be compared against that optimum class by class. For each class we record three quantities:
- its realized negative exposure $E_j$;
- its bias error, meaning the gap between its learned bias and the exact optimum;
- its direction error, meaning the angle between its learned weight vector and the exact optimum.
The prediction is that both errors grow as $E_j$ shrinks. The open question is their relative size at the tail. This experiment also tests whether hashing-based samplers produce lower tail exposure than frequency-based ones.
Adding back representation learning and temperature. The second component trains end to end. We sweep temperature and sample size $k$, and measure the effective rank of the rare classes' penultimate-layer features, following the rank measurements of Unpacking Softmax. We then relate that rank to rare-class accuracy. The aim is to find out whether the sampled regime makes rare-class accuracy disproportionately sensitive to temperature. A result of that kind would explain why tuned results fail to reproduce on the tail.
Reproducibility. The third component is a protocol, which we will release. It bins classes by training frequency and runs every method under the same tuning budget with at least five seeds. It reports per-bin metrics with adaptive-importance-sampling confidence intervals, and it reports variance across seeds and hyperparameters alongside the means.
Baselines
Full softmax. This is the reference point, trained exactly on the same encoder and data. It is feasible at these scales, since A Tale of Two Efficient and Informative Negative Sampling Distributions ran full softmax on a V100 GPU for Amazon-670K. Every sampler should approach it. The paper reports its hashing sampler as 10.3x to 11x faster per epoch than this full softmax on Amazon-670K, and 14x to 15x faster on ODP-105K "while preserving or slightly improving overall accuracy." We found no reported per-class or tail-bin accuracy result on Lacuna for any of these benchmarks. Establishing that is itself one of our measurements.
Uniform and frequency-based sampled softmax. These are the naive "do nothing special" samplers. They are run with the same $k$ and step count as every other method.
Complementary sum sampling. From Complementary Sum Sampling, this is the strongest principled fix for target-side instability. The paper reports a 50-fold per-minibatch compute reduction on Europarl but gives no tail metric.
The two hashing samplers. LSH Label and LSH Embedding, from A Tale of Two Efficient and Informative Negative Sampling Distributions, are the strongest existing speed-accuracy competitors. They are the methods most likely to show starvation.
Cost-sensitive full softmax. This is full softmax with class weights inversely proportional to frequency. It tests whether ordinary reweighting already repairs the tail.
Post-hoc bias recalibration. Each sampled model's per-class biases are refit against the exact softmax on held-out data, with the rest of the model frozen. This is the key ablation: it isolates the offset error.
Exposure floor without recalibration. This is the other key ablation: it isolates the direction error.
Fairness and success criterion. All methods share the same encoder, data splits, wall-clock budget, and a 100-trial tuning budget over temperature, learning rate, and $k$, following CLIMB's protocol. The proposal counts as succeeding if the exposure floor, with or without recalibration, closes a significant part of the tail-bin gap to full softmax. That gap is measured as precision@1 and macro-F1 over the rarest frequency decile. The improvement must exceed the recalibration-only baseline outside the adaptive-importance-sampling confidence intervals. It must also cost less than a 1.5x slowdown relative to the fastest hashing sampler.
Why not just…?
Why not just use cost-sensitive or focal loss on the full softmax? This fixes imbalance but not cost: it still computes all $K$ scores per step. Large scale classification in deep neural network with Label Mapping and Accelerated Training for Massive Classification via Dynamic Class Selection document that this saturates memory at large $K$. We include cost-sensitive full softmax as a baseline. If a sampled method cannot match it on the tail, speedups are being bought with rare-class quality, and the note will say so. Note also that combining class weights with a sampled denominator does nothing for a class that is never sampled.
Why not just recalibrate per-class biases after training? This is the most serious threat, and the design is built around it. If starvation mainly shifts scores by a constant per class, a cheap refit of $K$ biases solves the problem, and a new sampler is unnecessary. The frozen-encoder experiment measures offset error and direction error separately. The recalibration-only ablation measures how much of the gap it closes. If it closes most of it, the finding becomes "recalibrate your tail," which is still a useful and reproducible result.
Why not just resample the data or use a feedback loop that retrains on hard examples? The feedback loop of Handling Extreme Class Imbalance in Technical Logbook Datasets beat static resampling, reaching an F1 of 0.94 against 0.92 on the aviation maintenance dataset. Oversampling rare examples raises a rare class's exposure as a target, not as a negative. Its weight vector is still rarely pushed away from inputs it misclassifies. CLIMB also reports that naive resampling often hurts under extreme imbalance. We will run inverse-frequency data resampling as an extra comparison to confirm that it does not fix the direction error.
Why not just use a tree-structured softmax? Softmax Tree routes each input down a label hierarchy in logarithmic time and speeds up inference, which samplers do not. But a rare class's leaf still receives few updates, and routing errors near the root compound for the tail. We treat it as a complementary architecture rather than a competitor, and include it on one benchmark to check whether its tail behavior differs.
Proposed Experiments
Benchmarks. We use Amazon-670K, Wiki-325K, and ODP-105K, following A Tale of Two Efficient and Informative Negative Sampling Distributions, plus Europarl word prediction with its 47,170-word vocabulary, following Complementary Sum Sampling. All are public, which avoids the private-data trap exemplified by unreplicable claims such as the 91.50% accuracy in Deep Ensemble Learning for the Automatic Detection of Pneumoconiosis.
Decisive check 1: does starvation exist? In the frozen-encoder setting, rare-class weight error should fall monotonically with negative exposure. Hashing samplers should give the rarest decile lower exposure than uniform sampling. If error does not track exposure, the core claim is wrong.
Decisive check 2: offset or direction? We compare how much of the gap post-hoc recalibration closes against how much the exposure floor closes, reporting tail-bin precision@1 with adaptive-importance-sampling confidence intervals. This check determines which recommendation the work makes.
Decisive check 3: temperature and reproducibility. Across the 100-trial sweep, we compare the spread of rare-bin accuracy across temperatures and seeds with the spread of head-bin accuracy. We also relate it to the effective rank of rare-class features. The prediction is that sampled training makes the tail far more temperature-sensitive than the head, and that the exposure floor reduces this spread. A reduced spread would be a direct reproducibility gain, separate from any gain in the mean.
References
- Sampled Estimators For Softmax Must Be Biased
- Complementary Sum Sampling for Likelihood Approximation in Large Scale Classification
- A Tale of Two Efficient and Informative Negative Sampling Distributions
- One-vs-Each Approximation to Softmax for Scalable Estimation of Probabilities
- Unpacking Softmax: How Temperature Drives Representation Collapse, Compression, and Generalization
- Contrastive Representation Distillation
- Negatives-Dominant Contrastive Learning for Generalization in Imbalanced Domains
- Time-Series Contrastive Learning Against False Negatives and Class Imbalance
- Needle in a Haystack: Label-Efficient Evaluation under Extreme Class Imbalance
- CLIMB: Class-imbalanced Learning Benchmark on Tabular Data
- Large Scale Classification in Deep Neural Network with Label Mapping
- Accelerated Training for Massive Classification via Dynamic Class Selection
- Handling Extreme Class Imbalance in Technical Logbook Datasets
- Softmax Tree: An Accurate, Fast Classifier When the Number of Classes Is Large
- Deep Ensemble Learning for the Automatic Detection of Pneumoconiosis in Coal Worker’s Chest X-ray Radiography