Two-Level Softmax Sampling Done Right: Correcting Bias from Size Imbalance and Dispersion
Walid Bendada, Guillaume Salha-Galvan
NeurIPS 2026
TL;DR. We characterize systematic biases in two-level softmax sampling, caused by cluster size imbalance and intra-cluster dispersion. We propose two corrected sampling methods that provide more faithful softmax approximations with negligible overhead.
Abstract. Sampling from a softmax distribution is a fundamental operation in machine learning, but its linear complexity in the number of items makes exact sampling impractical at scale. Two-level softmax (2LS) sampling is a popular alternative enabling sublinear-time sampling. Assuming items are partitioned into clusters, 2LS first samples a cluster and then an item within it. In this paper, we show that, despite its advantages, 2LS introduces systematic and undesirable sampling biases, which arise from misweighting clusters by ignoring both cluster size imbalance and intra-cluster similarity dispersion. We propose two sampling methods, Size-Corrected 2LS (S-2LS) and Size- and Dispersion-Corrected 2LS (SD-2LS), which correct these biases and provide provably better softmax approximations with negligible to non-existent computational overhead. In-depth experiments on five large-scale datasets validate the improved sampling properties of our methods. We recommend their consistent use in place of standard 2LS in future work.
Are you an author? Claim this paper to see who's reading it, with views and other statistics, and to write about it here.
Claim this paperedit · history
NeurIPS 2026
Accept (poster) · 3 reviews · OpenReview
Updated 25 Nov 2026, 03:49 UTC.
- Decision
- Accept (poster)
Read decision
Meta-review
Good contribution towards softmax sampling, with both theoretical and empirical analyses. Please consider the questions/answers during the reviewing, as they provide information on some minor points that can be improved in the manuscript.
Final justification
There is clear consensus towards acceptance.
- Final justification
- There is clear consensus towards acceptance.
Read meta-review
Meta-review
Good contribution towards softmax sampling, with both theoretical and empirical analyses. Please consider the questions/answers during the reviewing, as they provide information on some minor points that can be improved in the manuscript.
- Rating
- 5/6
- Confidence
- 3/5
- Quality
- 3/4
- Clarity
- 4/4
- Significance
- 3/4
- Originality
- 3/4
- Contribution type
- general
- Ethical concerns
- NO or VERY MINOR ethics concerns only
Read review
Summary
This paper proposes efficient two-stage sampling methods for softmax distributions, where the logits are given by the temperature-scaled inner products between a query vector and a set of candidate vectors. The authors first provide a theoretical analysis of the bias introduced by conventional two-level softmax sampling (Propositions 2). In particular, they show that when the logits within each cluster follow a Gaussian distribution, the bias depends on both the cluster size and the variance of the logits within the cluster (Propositions 3). Motivated by this analysis, the paper proposes two variants: S-2LS Sampling, a low-overhead method that compensates for the bias induced by cluster size, and SD-2LS Sampling, which additionally accounts for the bias arising from within-cluster logit variance. Experiments on both real-world and synthetic datasets demonstrate that conventional two-stage sampling indeed exhibits biases associated with cluster size and within-cluster variance when compared with exact one-stage softmax sampling. The results further show that the proposed methods substantially reduce these biases while preserving the computational advantages of two-stage sampling.
Strengths and weaknesses
Strengths
- While the observation that cluster-size-dependent bias arises and can be corrected is, to some extent, straightforward, the theoretical analysis revealing an additional bias induced by the within-cluster logit variance provides useful insight into the behavior of two-stage sampling. The proposed correction mechanism for this bias is also well-motivated and principled.
- The experimental results support the theoretical analysis, demonstrating that conventional two-stage sampling introduces biases relative to exact one-stage sampling on both synthetic and real-world datasets. The results further show that the proposed methods effectively mitigate these biases in practice.
Weaknesses
- It remains unclear how detrimental the bias introduced by two-stage sampling is in practical downstream applications. While the paper demonstrates that the proposed methods reduce the discrepancy from exact one-stage sampling, the practical impact of this bias—and consequently the benefits of reducing it—is not sufficiently established.
Questions
Comments
- Regarding Eq. (5), is defined as a sample mean. It would be helpful to explicitly discuss its asymptotic behavior as (e.g., whether it converges to the mean of the underlying distribution ).
- In the presentation of SD-2LS, explicitly showing how is derived from would improve the readability of this section.
Limitations
See weaknesses above.
Final justification
The rebuttal satisfactorily addressed my comments. I therefore maintain my recommendation of 5.
Formatting concerns
None
2 comments
Thank you for your responses. The rebuttal addressed my comments, and I will maintain my recommendation of 5.
- Rating
- 4/6
- Confidence
- 4/5
- Quality
- 3/4
- Clarity
- 4/4
- Significance
- 3/4
- Originality
- 3/4
- Contribution type
- general
- Ethical concerns
- NO or VERY MINOR ethics concerns only
Read review
Summary
This paper is logical and easy-to-understand. It analyzes (formally + empirically) the systematic biases introduced by two-level softmax sampling approximation. It proposes two tighter approximations to adjust for cluster size and intra-cluster variability. The experiments effectively highlight the issue with 2LS and demonstrate that proposed techniques improve sampling fidelity while incurring minimal latency overhead.
Strengths and weaknesses
Strengths:
- The paper formally examines a problem that is fairly intuitive, and bases its proposed method on these identified biases.
- The paper is well-written; the progression is logical, and experiments are fairly thorough.
I did not spot any major technical/empirical weaknesses, so I have listed a few things under Questions. My only concern is that while the paper is sound, it might have a fairly limited use case/significance, as top-k/nucleus sampling in most applications is 'good' enough.
Questions
- The paper states that clustering is usually run offline and only once. I feel like this depends on application (e.g., amazon store catalog will change very often). This affects SD-2LS which requires calculating the covariance matrix everytime the cluster membership is updated. The authors can consider addressing this briefly in writing.
- IIUC, the authors mainly compare using K-means, which can result in imbalanced clusters. It would be interesting to see if the bias/fidelity gains are still as prominent with different clustering techniques (e.g., those that consider balancing). Perhaps a small additional experiment would suffice here.
- The authors acknowledged the limitation of their Gaussian assumption on the logits, and identified that with skewed logit distributions, the approximation bounds might not hold. No additional action is required here, as limitations are clearly identified, and this is fairly common assumption.
- Small nit: the mixture distribution assumption probably depends on the clustering algorithm used; for example, I am not sure if K-means would result in smooth mixture distribution.
- The dimensionality of considered is fairly small (around 100), modern embedding models frequently use much larger. The authors can consider performing an additional experiment or addressing this in writing (i.e., how would embedding size affect fidelity/latency).
Limitations
See above.
Final justification
I would like to maintain my rating of 4. The authors have adequately addressed my concerns, and I think this method is a valuable addition to approximate softmax sampling.
Formatting concerns
None, but I would recommend the authors place S4.3 after the experiments or integrate it with the final Conclusions section
2 comments
Rebuttal
We thank the reviewer for the careful and constructive assessment, and for the positive comments regarding the clarity, technical soundness, and thoroughness of the experiments. We address each of their questions, as well as their concern about the real-world significance of our work, below.
Question 1 (Periodic clustering updates):
We agree that the statement that clustering is performed "offline and only once" may be overly restrictive in practice. In some applications, clusters must be refreshed periodically as the catalog evolves. This is the case, for example, for e-commerce platforms such as Amazon, as correctly noted by the reviewer, but also for movie- and music-streaming services that continuously incorporate newly released content into their recommender systems.
Importantly, however, clustering and covariance computations would remain offline preprocessing operations whose cost would be amortized over the very large number of subsequent sampling requests. Consider a platform that samples items online to generate recommendations for millions of users every day. Even if the clusters were recomputed once per day (for example), the resulting partition would then be reused across millions of online sampling operations throughout that day. The cost of this offline periodic partition update is therefore expected to remain small relative to the aggregate cost of repeated sampling at production scale.
For this reason, the paper's claim in this section that "the dominant cost is [...] the inference complexity for a fixed partition" continues to hold in practice even when the partition is refreshed periodically rather than computed only once.
We will revise the paper to clarify this part and remove the overly restrictive "only once" wording.
Question 2 (Balanced clustering):
Given the size and dispersion biases that we identified and for which we proposed inference-time corrections, we agree that an alternative line of work would be to explore clustering methods designed to overcome those biases at training time.
Following the reviewer’s suggestion, we ran an additional experiment on all three real-world datasets with clusters and . Starting from the standard k-means centroids, we limited each cluster to approximately items by alternatively populating clusters one item at a time using a greedy nearest neighbor assignment rule. We then recomputed the centroids and covariance matrices from the final balanced clusters. This resulted in the following evolution of fidelity from k-means to balanced clustering, as measured by (like in the paper, the lower the better):
| Dataset | 2LS | S-2LS | SD-2LS KL |
|---|---|---|---|
| GloVe-100 | 0.061695 → 0.002882 (−95.33%) | 0.002228 → 0.002889 (+29.67%) | 0.000118 → 0.000129 (+9.32%) |
| YAMBDA | 0.031803 → 0.018955 (−40.40%) | 0.010002 → 0.018960 (+89.56%) | 0.000507 → 0.001414 (+178.90%) |
| VK-LSVD | 0.029561 → 0.006661 (−77.47%) | 0.005079 → 0.006662 (+31.17%) | 0.000182 → 0.000241 (+32.42%) |
As expected, balancing substantially improves standard 2LS, making our proposed S-2LS irrelevant. This confirms the reviewer’s intuition that size imbalance can also be addressed through clustering.
However, in this specific experiment, doing so came at the cost of degraded fidelity when compared to our method applied on k-means clustering. Crucially, balancing does not remove the dispersion bias. SD-2LS remains the best method, reducing KL relative to balanced 2LS by 22× on GloVe-100, 13× on YAMBDA, and 28× on VK-LSVD.
Overall, the question of whether a clustering method can be designed to overcome the biases identified in our method is still an open one, and we propose to add it to the future directions discuss in the conclusion of our paper.
Question 3 (Gaussian assumption):
We thank the reviewer for their comment and refer to our detailed response to Reviewer 96dU for precisions on the assumptions made by our method on the distribution of the intra-cluster logits.
Question 4 (Mixture-distribution vs K-means):
We agree that the relationship between the assumed mixture components and the clustering algorithm deserves clarification. In particular, k-means would not generally recover mixture components whose distributions overlap across the whole space. Fortunately, our general formulation does not impose assumptions on the component supports, and as such it remains compatible with interpreting the components of the mixture as distributions with support restricted to disjoint regions of the embedding space, as in the case of a Voronoï tessellation implied by k-means centroids. Admittedly, the explicit assumption of disjoint supports is not discussed in the paper and would make an interesting direction for future work that we will mention in the conclusion of our paper.
Question 5 (Effect of dimensionality):
The main limitation of using our methods on higher dimensional embeddings would come from the covariance correction in SD-2LS, as it requires evaluating a quadratic form for every cluster, leading to an cluster-scoring cost. Therefore, unlike 2LS and S-2LS, whose cluster-scoring costs scale linearly with , SD-2LS becomes increasingly expensive for very high-dimensional embeddings. To make SD-2LS a viable approach for high-dimensional embeddings, a follow-up extension would thus be to introduce a rank hyperparameter and approximate each covariance matrix with a rank- factorization. This would reduce the cluster-scoring cost to and thus give the possibility to control the latency overhead of SD-2LS with a single parameter.
As a consequence, we propose to explicit the dimension scaling limitation in the paper and add a discussion on low-rank covariance approximations as future work.
Regarding fidelity, Proposition 5 indicates that it is entirely determined by the distribution of the logits which is first and foremost dataset dependent, and so we couldn't anticipate a general trend when d increases. One special case to consider though would be if the d dimensions of the embedding space were not or weakly correlated. In this situation, we would expect the inner product to be approximately gaussian as a consequence of the central limit theorem, thus falling under the conditions of Proposition 6.
Formatting:
We thank the reviewer for their suggested reorganization. We will move the practical comparison between S-2LS and SD-2LS after the experimental results.
On the practical significance of this work:
We agree that top-k and nucleus sampling provide convenient approximations in many applications. In particular, they are well suited to settings in which restricting sampling to a relatively small set of high-probability candidates is acceptable.
Our work targets a different regime. Specifically, we consider large-scale systems in which sampling should remain computationally scalable while preserving access to the full candidate space. Unlike top-k and nucleus sampling, which explicitly truncate the distribution and assign zero probability to all candidates outside the retained set, our objective is to support non-truncated sampling over very large item sets. This property is important when exploration, discovery, catalog coverage, or item exposure is part of the application objective.
This regime arises, for example, in large-scale recommender systems, where the candidate space may contain millions of items. It also appears in other domains involving very large discrete action or token spaces. This need is reflected in several recent works, including:
- Subbiah et al., “Efficient Item ID Generation for Large-Scale LLM-Based Recommendation,” arXiv:2509.03746, 2025
- Bendada et al., “Exploring Large Action Sets with Hyperspherical Embeddings using von Mises-Fisher Sampling,” ICML, 2025
- Guo et al., “Improving Autoregressive Image Generation Through Coarse-to-Fine Token Prediction,” CVPR, 2026
The first two works are particularly relevant to recommender systems. They consider settings in which item or action vocabularies contain millions of distinct candidates and in which scalable sampling over the full item space is a concrete practical requirement. In particular, Bendada et al. (ICML 2025) explicitly state that "it is crucial that exploration is not restricted to a specific radius by construction" for the large-scale recommendation problem they consider, and explicitly highlight the practical limitations of truncated sampling schemes. Their work in this paper was evaluated and deployed on a real-world service with millions of users.
We therefore view our method as complementary to top-k and nucleus sampling rather than as a replacement for them. Top-k and nucleus sampling remain appropriate when truncation is acceptable, whereas our method addresses settings in which retaining scalable access to the full candidate space is itself an important requirement.
Thank you to the authors for their detailed and comprehensive rebuttal. Overall, the response and the proposed revisions to the paper clarify my concerns about offline cost amortization, complementarity to top-k/nucleus sampling. The additional experiments on balanced clustering are helpful, demonstrating that while balanced clustering improves standard 2LS, SD-2LS still retain significant advantage in handling dispersion bias.
While empirical results for low-rank approximations would have been a valuable addition, explicitly detailing the scaling limitations and proposing approximations as future work is acceptable. I maintain my score and positive view of this work.
- Rating
- 4/6
- Confidence
- 2/5
- Quality
- 3/4
- Clarity
- 4/4
- Significance
- 3/4
- Originality
- 3/4
- Contribution type
- general
- Ethical concerns
- NO or VERY MINOR ethics concerns only
Read review
Summary
The authors study the problem of two level softmax sampling (2LS) as an approximation for softmax sampling and propose solutions for correcting the sampling distortion occurred under two level sampling. First, the authors present results characterizing the ratio of sampling probabilities between the standard 2LS and softmax sampling, showing that standard 2LS procedures fail to approximate the desired softmax sampling distribution. To reduce the distortion of standard 2LS, the authors propose two variants of 2LS, called S-2LS and SD-2LS. The S-2LS variant aims to reduce the distortion that results from the size of a cluster, while SD-2LS aims to additionally reduce the distortion that results from intra-cluster variability. The authors test their method empirically against existing methods for approximate softmax sampling, and show that their approach reduces distortion from the desired softmax sampling distribution.
Strengths and weaknesses
** Strengths **
- Overall, the paper is written very clearly. As someone not familiar with this field, the authors have clear exposition explaining the need for approximate softmax sampling (avoiding linear-time computations), and provide intuitive solutions for softmax sampling distortion.
- The empirical results demonstrate that while exact asymptotic correction is achieved under a Gaussianity assumption, the method remains effective in practice against (potentially) non-Gaussian distributions relative to uncorrected 2LS.
** Weaknesses **
- While the authors provide exact distortion correction under a Gaussian model (Proposition 6), the justification of this assumption is left rather unclear. It would be helpful to understand why a justification of this nature is typical/atypical, and why we should expect the randomness/shape of the query set to satisfy this assumption.
Questions
- The empirical results validate the theoretical guarantees that SD-2LS reduces sampling distortion, with Proposition 5 guaranteeing asymptotically correct targeting under a Gaussian distribution. What does the distribution of look like in the 5 empirical examples given? Is it roughly Gaussian?
- The paper repeatedly mentions computational costs (as the motivation to 2LS, scaling for each of their methods), yet there is only one latency table (App. C.2.). How does scaling (with respect to varying cluster sizes and dataset sizes) look like?
- It would be helpful to discuss the limiting bias under a non-Gaussian assumption on the normalized dot product . Are there settings where distortion to the softmax distribution is increased for an adversarial distribution of ?
Limitations
Yes.
Final justification
The author's rebuttal has addressed the key questions in the review, and I maintain positive scores for this work.
Formatting concerns
N/A
1 comment
Rebuttal
We thank the reviewer for their positive assessment and thoughtful feedback. We appreciate their recognition of the paper’s clarity and empirical effectiveness, and their comments will help us sharpen the discussion of the Gaussian assumption, non-Gaussian behaviour, and computational scaling.
Question 1 & 3 (Gaussianity of ):
We acknowledge that the scope of the Gaussian assumption should be stated more precisely. While Proposition 6 guarantees asymptotic unbiasedness under Gaussian projected logits, we argue that the main theoretical contribution of the paper is Proposition 5, which describes the general case where no assumption on the distribution of is made and of which Proposition 6 is only a corollary.
The class of distributions that can benefit from SD-2LS can be better understood by rewriting the asymptotic distortion from Proposition 5 as
For each cluster, the denominator can be written as
where is the cumulant of order of the distribution of . Substituting this expression into the distortion ratio cancels the mean and variance terms, leaving a residual distortion proportional to
Gaussianity is therefore only the exact special case in which all cumulants above order two vanish. But more broadly, SD-2LS remains accurate for distributions whose higher-order cumulants are small, or whose combined higher-order contribution is nearly constant across clusters.
From our experiments, the empirical embedding similarity distributions could not be considered to be perfectly Gaussian, however they still belonged to the family of distributions we described above.
Conversely, highly skewed or heavy-tailed projected-logit distributions with large, cluster-dependent higher-order cumulants form the main failure regime. We will add these insights to the discussion of Proposition 5.
Question 2: Computational scaling:
The reviewer asked how latency scales with dataset size and the number of clusters. To address this directly, we added two controlled latency experiments on VK-LSVD (, , 200 queries).
First, we varied the dataset size while keeping fixed and preserving the original cluster structure:
| Number of items | Exact softmax (ms) | 2LS (ms) | S-2LS (ms) | SD-2LS (ms) |
|---|---|---|---|---|
| 490,185 | 46.9 | 0.124 | 0.114 | 0.363 |
| 980,886 | 117.1 | 0.171 | 0.174 | 0.494 |
| 1,962,301 | 84.2 | 0.259 | 0.276 | 0.617 |
| 4,906,510 | 255.5 | 0.547 | 0.548 | 0.868 |
| 9,813,558 | 420.0 | 1.121 | 1.165 | 1.460 |
| 19,627,601 | 432.5 | 1.980 | 2.117 | 2.441 |
Second, we fixed M and varied the number of clusters:
| Clusters | Average items per cluster | 2LS (ms) | S-2LS (ms) | SD-2LS (ms) |
|---|---|---|---|---|
| 64 | 306,681 | 27.3 | 25.6 | 36.8 |
| 128 | 153,341 | 32.8 | 14.6 | 16.4 |
| 256 | 76,670 | 6.5 | 7.1 | 7.1 |
| 512 | 38,335 | 3.1 | 3.3 | 3.5 |
| 1,024 | 19,168 | 2.2 | 2.6 | 3.1 |
| 2,048 | 9,584 | 1.1 | 1.3 | 1.6 |
| 4,096 | 4,792 | 0.7 | 0.9 | 1.7 |
| 8,192 | 2,396 | 0.5 | 0.5 | 2.4 |
Taken together, the two experiments make the dependence visible: increasing at fixed increases the number of items processed in the selected cluster and therefore the latency, whereas increasing at fixed reduces this second-stage cost. For SD-2LS, this decrease eventually competes with the covariance-scoring cost, producing the observed latency minimum around --. Across dataset sizes, KL remains essentially constant, while increasing improves the fidelity of S-2LS and SD-2LS. At the full 19.6M-item scale, all three two-level methods remain below 2.5 ms per query, compared with 432.5 ms for exact softmax. We will include these scaling experiments and the corresponding discussion in the paper.
From OpenReview, CC BY 4.0. Authors as signed there; shown unedited.
Loading the discussion…
Rebuttal
We would like to thank the reviewer for their recommendation to accept the submission, as well as for their insightful comments that will contribute to improve the quality of the paper.
Practical consequences of two-stage sampling biases
We agree that the current paper could better discuss the downstream implications of the sampling-probability biases identified in our analysis, and we will expand this discussion accordingly.
In the concrete example of a large-scale recommender system, sampling may occur millions to billions of times per day. Distortions from the original softmax distribution thus accumulate into substantial imbalances in item exposure, where equally scored items receive systematically different exposure solely because of the auxiliary clustering used by the two stages sampler. We argue that, given model scores are commonly calibrated on some measure of user utility, the perceived value of recommendations can therefore be impacted. Additionally, from a content creator or provider’s perspective, fairness concerns could legitimately be raised as access to potentially interested audience or customers is prevented.
We will add these practical implications to the paper while clearly presenting them as plausible downstream consequences, rather than effects established by our current experiments, and as motivation for future work directly evaluating impact of the established biases on user utility and exposure fairness.
Asymptotic behavior of μk
We thank the reviewer for helping us see the ambiguous notation of μk, which is first introduced as the sample mean and then reused as the mean of the distribution Dk. We will denote the empirical centroid computed from the items in cluster Ck by μk,N=∣Ck∣1∑i∈Ckxi, and retain μk for the population mean of the underlying distribution Dk. Under the assumptions of Proposition 2, the items in Ck are i.i.d. samples from Dk, and ∣Ck∣→∞ when πk>0. The strong law of large numbers therefore gives μk,N→μk almost surely as N→∞. We will use μk,N in all finite-sample definitions and μk in the limiting expression of Eq. (5), and revise Proposition 2 and its proof accordingly.
Presentation of SD-2LS
We agree that the derivation of Eq. (10) can be made clearer. We will explicitly introduce the relation σk2(q)=q⊤Σkq/τ2, where Σk is the covariance matrix of cluster k, before presenting SD-2LS. This makes the transition from the covariance matrix to the scalar variance term used in Eq. (10) immediate and improves the readability of the section.