Papers
Topics
Authors
Recent
Search
2000 character limit reached

Cached Multiple Negatives Ranking Loss

Updated 12 December 2025
  • The paper introduces a contrastive, solver-agnostic loss that leverages a dynamic solution cache to significantly reduce optimization calls and computational cost.
  • It employs a ranking-based, noise-contrastive estimation framework with multiple negatives and hard-negative variants to maintain a controllable trade-off between fidelity and efficiency.
  • Empirical results on NP-hard tasks demonstrate that the method achieves comparable or superior decision quality with much faster training times compared to standard black-box and relaxation approaches.

The Cached Multiple Negatives Ranking Loss is a contrastive, solver-agnostic surrogate loss function designed for end-to-end learning in predict-and-optimize settings, particularly where the task involves combinatorial optimization over discrete feasible sets. It achieves significant computational savings by decoupling optimization calls from every forward pass, instead maintaining a dynamic solution cache that enables inner approximations of the feasible set. The approach provides a controllable trade-off between estimator fidelity and compute cost through probabilistic cache updates, and is empirically validated on NP-hard problems, where it matches or surpasses the predictive quality of state-of-the-art black-box and relaxation-based methods, while delivering substantial reductions in training time (Mulamba et al., 2020).

1. Formal Definition and Variants

Given a training dataset D={(xi,ci)}i=1nD = \{(x_i, c_i)\}_{i=1}^n, for each instance ii:

  • m(ω,xi)=c^iRdm(\omega, x_i) = \hat{c}_i \in \mathbb{R}^d is the model's predicted cost vector,
  • vi=argminvVf(v,ci)v_i^* = \arg\min_{v \in V} f(v, c_i) is the optimal solution under the true cost cic_i,
  • SiVS_i \subseteq V is a cache of feasible (non-optimal) solutions for instance ii.

Let f(v,c)f(v, c) denote the task-specific objective; for typical problems (e.g., routing, matching, scheduling), ff is often linear, f(v,c)=cvf(v,c)=c^\top v. The Cached Multiple Negatives Ranking Loss comprises two contrastive variants that penalize predicted costs for assigning lower loss to the oracle solution ii0 than to any cached negative ii1:

(a) Multiple-negatives (all-pairs) loss:

ii2

(b) MAP (hard-negative) loss:

ii3

For linear objectives, it is common to operate on the prediction error, ii4, to avoid trivial minimizers. The corresponding variants are:

ii5

ii6

2. Noise-Contrastive and Ranking Interpretation

The loss is rooted in a ranking-driven, noise-contrastive estimation framework. Considering the Gibbs measure

ii7

the oracle solution ii8 is treated as a positive, and ii9 as negatives. Maximizing the unnormalized likelihood ratio across all negatives,

m(ω,xi)=c^iRdm(\omega, x_i) = \hat{c}_i \in \mathbb{R}^d0

recovers, up to a sign, precisely the multiple-negatives loss definition above. The normalization constant m(ω,xi)=c^iRdm(\omega, x_i) = \hat{c}_i \in \mathbb{R}^d1 is omitted in practice, obviating the need to enumerate the full feasible set m(ω,xi)=c^iRdm(\omega, x_i) = \hat{c}_i \in \mathbb{R}^d2.

3. Solver-Agnostic Solution Caching and Inner Approximation

Rather than invoking the combinatorial solver on each training forward pass, this approach maintains, for each instance m(ω,xi)=c^iRdm(\omega, x_i) = \hat{c}_i \in \mathbb{R}^d3, a dynamic cache m(ω,xi)=c^iRdm(\omega, x_i) = \hat{c}_i \in \mathbb{R}^d4 initialized with the oracle solution m(ω,xi)=c^iRdm(\omega, x_i) = \hat{c}_i \in \mathbb{R}^d5. Whenever the solver is evaluated with a new predicted vector m(ω,xi)=c^iRdm(\omega, x_i) = \hat{c}_i \in \mathbb{R}^d6, the resulting solution is added to m(ω,xi)=c^iRdm(\omega, x_i) = \hat{c}_i \in \mathbb{R}^d7 if not already present. Over time, m(ω,xi)=c^iRdm(\omega, x_i) = \hat{c}_i \in \mathbb{R}^d8 accumulates diverse feasible solutions, forming an “inner approximation” to m(ω,xi)=c^iRdm(\omega, x_i) = \hat{c}_i \in \mathbb{R}^d9. Unlike LP relaxations which provide an outer approximation, cache-based methods maintain integrality and leverage previously discovered structure.

Outer Approximation Inner Approximation
Typical method LP relaxation Cached vi=argminvVf(v,ci)v_i^* = \arg\min_{v \in V} f(v, c_i)0
Integrality No Yes
Explores vi=argminvVf(v,ci)v_i^* = \arg\min_{v \in V} f(v, c_i)1 No Yes (via growing vi=argminvVf(v,ci)v_i^* = \arg\min_{v \in V} f(v, c_i)2)

4. Cache Lookup and Training Algorithm

The method probabilistically alternates between cache lookup and full solver invocation for each training instance and epoch, thereby enabling scalable mixed-mode optimization:

SiVS_i \subseteq V0

The hyperparameter vi=argminvVf(v,ci)v_i^* = \arg\min_{v \in V} f(v, c_i)3 controls the frequency of full solves. vi=argminvVf(v,ci)v_i^* = \arg\min_{v \in V} f(v, c_i)4 recovers full-complexity training with maximal cache fidelity, while vi=argminvVf(v,ci)v_i^* = \arg\min_{v \in V} f(v, c_i)5 yields a fast, static approximation. Empirically, vi=argminvVf(v,ci)v_i^* = \arg\min_{v \in V} f(v, c_i)6 suffices to closely match the solution quality of the full-solve regime while greatly reducing computational burden.

5. Implementation Workflow and Hyperparameters

Implementation proceeds as follows:

  • Precompute vi=argminvVf(v,ci)v_i^* = \arg\min_{v \in V} f(v, c_i)7 for each instance, and initialize vi=argminvVf(v,ci)v_i^* = \arg\min_{v \in V} f(v, c_i)8.
  • Select model vi=argminvVf(v,ci)v_i^* = \arg\min_{v \in V} f(v, c_i)9, optimizer (e.g., Adam), learning rate cic_i0, epochs cic_i1.
  • Set cic_i2 to control cache refresh (e.g., 0.05).
  • In each minibatch forward pass, randomly decide solver call vs. cache using cic_i3.
  • Compute one of the contrastive losses cic_i4 or cic_i5 and backpropagate.
  • Validate on held-out data for regret, tuning cic_i6, cic_i7, and batch size.

No generalization bounds are provided, but the loss approximation improves monotonically as cic_i8 increases.

6. Empirical Results and Comparative Performance

Studies on canonical NP-hard tasks demonstrate that cached multiple negatives ranking losses deliver competitive, or even superior, decision regret relative to black-box differentiation (e.g., SPO+, implicit gradients) and QPTL/IPM relaxations, at markedly lower computational cost. For example, on Knapsack-120:

  • Full black-box (no cache): regret ≈ 528, per-epoch time ≈ 4s;
  • Cached cic_i9: regret ≈ 562, per-epoch time ≈ 0.5s (88% faster).

For the largest energy-aware scheduling instance, cached methods match best regret (~18,500) yet reduce epoch time from ~42s to ~1.5s. The caching wrapper is also effective for SPO+ and black-box methods, reducing per-epoch cost by up to an order-of-magnitude with negligible impact on solution quality. This suggests that the caching strategy generalizes as a modular performance improvement for a family of predict-and-optimize workflows.

7. Significance, Limitations, and Extensions

The Cached Multiple Negatives Ranking Loss provides a principled framework for integrating contrastive learning objectives with combinatorial optimization under uncertainty. It does not require relaxation of integrality constraints and is solver-agnostic, with a simple hyperparameter governing the trade-off between cost and fidelity. While no theoretical generalization bounds are presently given, loss approximation is guaranteed to improve as caches grow. A plausible implication is that, for large and complex feasible sets, the approach can scale to regimes where frequent optimization is otherwise infeasible, without loss of predictive or prescriptive quality (Mulamba et al., 2020).

Definition Search Book Streamline Icon: https://streamlinehq.com
References (1)

Topic to Video (Beta)

No one has generated a video about this topic yet.

Whiteboard

No one has generated a whiteboard explanation for this topic yet.

Follow Topic

Get notified by email when new papers are published related to Cached Multiple Negatives Ranking Loss.