Listwise Cross-Entropy Loss
- Listwise Cross-Entropy Loss is a ranking objective that computes loss over the whole candidate set, enhancing alignment with metrics such as NDCG.
- It provides theoretical benefits including convex upper bounds on ranking metrics and Fisher consistency, ensuring improved ranking performance.
- Scalable surrogate methods like Sampled Softmax, NCE, and SCE enable efficient use of this loss in large-scale recommendation and retrieval systems.
Listwise Cross-Entropy Loss is a foundational principle and optimization objective in modern learning-to-rank, sequential recommendation, and collaborative filtering. Its distinguishing feature is that the loss is defined as a function of the entire candidate set (or list), in contrast to pairwise or pointwise objectives, thereby directly aligning the optimization process with the structure of ranking metrics such as NDCG. Recent advances have deepened both the theoretical and practical understanding of listwise cross-entropy loss, establishing its superiority in aligning model learning with ranking performance and proposing scalable surrogates suitable for large candidate sets (Xu et al., 2024, Yang et al., 2024, Bruch, 2019).
1. Formal Definition and Variants
In its canonical form for sequential recommendation or learning-to-rank, the listwise cross-entropy loss is defined as the negative log-likelihood of the true next (or relevant) item, normalized over all candidate items . For an input context (e.g., user history), an item , and a parameterized scoring function , the standard listwise cross-entropy loss is: where .
For learning-to-rank with graded labels, the listwise cross-entropy “xe” proposed by Bruch et al. employs gain-normalized label distributions: where
with the relevance and the model score for document 0, and 1 a smoothing hyperparameter (Bruch, 2019). This formulation subsumes earlier listwise losses such as ListNet and ListMLE.
2. Distinctiveness Compared to Pointwise and Pairwise Objectives
Listwise cross-entropy loss jointly normalizes over all candidates in each query, in contrast to the following:
- Pointwise losses (e.g., binary cross-entropy) optimize each context–item pair independently, typically applying a sigmoid to 2. There is no competition among items.
- Pairwise losses (e.g., Bayesian Personalized Ranking) optimize a positive–negative pair at a time, e.g., 3, but do not consider the “whole list” structure (Xu et al., 2024, Yang et al., 2024).
This listwise normalization is essential for aligning the optimization with ranking metrics and for ensuring that training steps are sensitive to the global order induced by the scoring function.
3. Theoretical Guarantees: Metric Surrogacy and Consistency
Formally, minimizing listwise cross-entropy loss provides convex upper bounds on rank-based metrics. Specifically:
- Lower Bound on NDCG: For a predicted rank 4 of the target item, it holds that
5
where for the next-item case, 6 (Xu et al., 2024). This ensures that minimizing the loss tightly controls the quality of ranking as measured by NDCG.
- Fisher Consistency: The xe loss is both a convex function of the scores and Fisher-consistent for NDCG under standard IR data assumptions (graded or click-based labels) (Bruch, 2019). This means that any score vector that minimizes the loss asymptotically maximizes mean NDCG.
- Comparative Surrogacy: ListNet and ListMLE do not bound a ranking metric and are not NDCG-consistent; LambdaMART’s loss is non-convex and heuristically tied to NDCG via "lambda-gradients" (Bruch, 2019).
The tight theoretical connection between listwise cross-entropy and core ranking metrics distinguishes it from previously used losses and underpins its empirical superiority.
4. Scalable Approximations and Surrogate Losses
Computing the full softmax denominator scales as 7 per training example, which is prohibitive for large candidate sets. Several surrogate approaches are established:
- Sampled Softmax (SSM): Sample 8 negatives per positive, compute loss over observed plus negatives: 9
- Noise Contrastive Estimation (NCE): Incorporates a correction term 0 in the negative logits and uses both positive and negative classification sub-tasks. Proper tuning of 1 governs the strength of the approximation (Xu et al., 2024).
- Importance Sampling (IS) and Scaled Cross-Entropy (SCE): IS adjusts softmax weights using the sampling distribution, while SCE introduces a scaling parameter 2 to adjust for the magnitude loss caused by sampling: 3 SCE with 4 can recover tight metric-aligned bounds with minor computational cost (Xu et al., 2024).
- SimCE (“Simplified Sampled Softmax Cross-Entropy”): An upper-bound of SSM, focusing on the hardest negative: 5 When 6, SimCE reduces to the pairwise hinge and upper-bounds BPR (Yang et al., 2024).
These approximations allow practical deployment of listwise loss in large-scale systems, so long as sampling is tuned to preserve ranking sensitivity.
5. Empirical Outcomes and Comparative Analysis
Empirical evaluations consistently demonstrate the superiority of listwise cross-entropy–based training:
- On public next-item recommendation datasets (Beauty, MovieLens-1M, Yelp), state-of-the-art sequential models (e.g., SASRec) trained with full CE substantially outperform the same backbones trained with BCE or BPR, and also surpass LLMs by a notable margin in HR@10 despite being orders of magnitude smaller (Xu et al., 2024).
- SCE achieves nearly the same ranking performance as full CE with 7 as low as 100–500 negatives (5% of item set), reducing training cost by 10–100× while remaining stable across models and datasets.
- In collaborative filtering, SimCE leads to 20–40% gains in Recall@20 for MF backbones and up to 68.7% improvements in Recall@10 on some large datasets. SimCE and SSM converge in 20–40 epochs versus 80–200 for BPR (Yang et al., 2024).
- Across information retrieval benchmarks (Web30K, Yahoo! LTR), the xe loss provides small but statistically significant NDCG@5 and NDCG@10 improvements over LambdaMART and ListNet, achieves faster convergence, and is more robust to irrelevant document augmentation and label noise (Bruch, 2019).
| Loss Function | Consistency with NDCG | Full-List Required | Empirical Ranking Quality |
|---|---|---|---|
| CE/xe (Listwise CE) | Yes | Yes | Superior, reliable, robust |
| SCE, SSM, SimCE | Approximately | No (sample-based) | Equivalent if 8 tuned |
| BPR, BCE (Pair/Point) | No | No | Inferior, slow, thin gradient signals |
6. Implementation Guidance for Large-Scale Systems
- Loss Selection: Use full CE where 9 is manageable (0 tens of thousands). For larger sets, SCE with uniform sampling and 1 provides a robust, scalable surrogate (Xu et al., 2024).
- Sampling Practice: 2–500 negatives suffices for 3k–20k. Sample size 4 is effective.
- Hyperparameters: For SCE, set 5; for NCE, 6 avoids slow early convergence. SimCE recommends margin 7–8.
- Batching and Negatives: Form user–positive pairs in batches, sample negatives per batch; ensure consistency of negative sampling across training and inference phases.
- Sequence and Embeddings: Use sliding-window augmentation for long sequences; embedding size beyond 9–128 offers diminishing returns compared to cost.
- Monitoring: Track both surrogate loss and true ranking metrics (NDCG, RR) to ensure the surrogate bound tightens in training. Monotonic improvement is expected with CE and SCE, while pointwise/pairwise losses may plateau early.
7. Extensions and Related Listwise Objectives
The xe loss is a convex gain-weighted variant tied to NDCG; ListNet and ListMLE generalize the listwise CE to permutation probability models but lack direct metric surrogacy. LambdaMART, despite its empirical dominance, optimizes an implicit, non-convex loss and does not provide convexity or Fisher consistency with NDCG (Bruch, 2019). Surrogate techniques for CE, including sampled softmax, NCE, IS, and SCE, have established frameworks for scalable, theoretically-justified ranking optimization.
A plausible implication is that future ranking systems for recommendation and retrieval will standardize on listwise CE surrogates (SCE, SimCE) for scalable, robust training, given their superior alignment with target metrics and computational feasibility in large-scale applications.