Many discrete prediction problems are naturally written as energy models. An energy model is a scorer that assigns a number to every candidate output, such as a set of labels, a ranking, or a binary image, and turns those scores into probabilities by dividing by a normalizer summed over all candidates. That normalizer, the partition function, has exponentially many terms. A recent way around it, from Joint Learning of Energy-based Models and their Partition Function, trains a second network to predict the log-normalizer and estimates the needed sums from random candidates drawn from a fixed, uniform reference distribution. Its authors concede that this breaks down in sparse output spaces, because uniform draws almost never land where the model puts its mass. Adversarial negative sampling, which trains a generator to propose "hard" candidates, looks like the obvious fix. In discrete spaces such a generator is trained with policy gradients, the log-derivative trick that turns a non-differentiable choice into a reward-weighted update. The trouble is that these minimax games are unstable, and no one has said what reward the generator should optimize when the downstream objective is a normalizer estimate.
The central idea of this proposal is that, in the partition-function setting, the reward does not need to be designed. If the sampled candidates are importance-weighted by the generator's own probability, the training objective stays unbiased for any generator. The generator's only job then becomes reducing the variance of that estimate, and the variance-optimal generator is proportional to the model's own unnormalized density. Minimizing that variance by policy gradient gives a specific reward, the squared importance weight. This reward pushes the generator toward candidates the energy model scores higher than the generator expects, which is a principled form of hard-negative mining. It is neither the adversarial game of IRGAN nor the cooperative likelihood fit of Revisiting Energy Based Models as Policies.
Core Claim
We claim that a structured, tractably normalized proposal policy, trained by REINFORCE to minimize the second moment of the importance-weighted partition-function estimate, makes min-min energy model training work in sparse discrete output spaces where a uniform reference fails. We further claim it does so more stably and with less bias than generators trained on the adversarial reward.
To make this concrete, let $g(x,y)$ be the model's score for output $y$ given input $x$, with energy $-g$. Let $\tau(x)$ be the network predicting $\log Z(x)$. Let $q_\theta(y\mid x)$ be the proposal policy. We generalize the min-min objective of Sander et al. to
$$\mathcal{L}(g,\tau;\theta)=\mathbb{E}_{(x,y)\sim\text{data}}\Big[-g(x,y)+\tau(x)+\mathbb{E}_{y'\sim q_\theta}\big[w(x,y')\big]-1\Big],\qquad w(x,y')=\frac{e^{\,g(x,y')-\tau(x)}}{q_\theta(y'\mid x)}.$$
For any $q_\theta$ with full support, the inner expectation equals $Z(x)e^{-\tau(x)}$. The variational identity $\log z=\min_\lambda (ze^{-\lambda}+\lambda-1)$, the same identity behind the scalar normalizer in Self-normalising the Likelihood, then makes the optimum over $\tau$ equal to $\log Z(x)$. The proposal therefore changes the variance of the gradients, not their expectation. The proposal update follows from differentiating the second moment $\mathbb{E}_{q_\theta}[w^2]$:
$$\nabla_\theta\,\mathbb{E}_{q_\theta}[w^2]=-\,\mathbb{E}_{y'\sim q_\theta}\big[w(x,y')^2\,\nabla_\theta\log q_\theta(y'\mid x)\big].$$
This is REINFORCE with reward $w^2$. The update is computed in log space with a self-critical baseline and per-batch normalization of the weights. To guarantee full support, $q_\theta$ is mixed with the uniform reference at a small fixed weight, the same defensive mixture Adversarial Contrastive Estimation uses for a different reason.
The generator softmax bottleneck that ACE and IRGAN leave open disappears by construction. The policy is never a flat softmax over the output space. For label sets it is a product of per-label Bernoullis or a short autoregressive chain over labels. For permutations it is a Plackett–Luce model. For binary images it is a factorized or autoregressive bit model. All of these have exact log-probabilities at linear cost.
Relation to Prior Work
Several papers motivate the gap. Sander et al. learn $\tau(x)$ against a fixed uniform $q$ and name an informed reference as the missing piece. Training Discrete Energy-Based Models with Energy Discrepancy trains discrete energy models without MCMC using fixed perturbations and reports that these fall off the data manifold. Discriminance Sampling estimates $Z$ by classifying against a fixed or annealed proposal. In all three the contrast distribution is static, and our proposal makes it learned.
Other work supplies the method. IRGAN and ACE show that REINFORCE can train discrete negative samplers. Rationalizing Neural Predictions shows the same estimator training discrete masks against a downstream critic. We reuse their estimator and variance-reduction practice but replace the reward. In ACE the reward is the discriminator's confusion plus an entropy bonus, which amounts to minimizing the reverse KL divergence from proposal to model. That divergence is mode-seeking, so it can rest on a few hard modes. Our $\chi^2$-type reward instead punishes the proposal wherever it under-covers model mass.
Some work constrains the design. Understanding Hard Negatives in NCE proves that negatives drawn from the model's own distribution remove contrastive gradient bias. Our objective has the model distribution as its fixed point, which gives a concrete account of why hardness helps. Revisiting Energy Based Models as Policies and Flow Contrastive Estimation both learn samplers jointly with an energy model, but only in continuous spaces with normalizing flows. R-NCE explicitly rejects adversarial training as unstable. We take that warning seriously, which is why the reward is a variance target with a non-adversarial fixed point. AdvInfoNCE warns that aggressive hardness amplifies false negatives. Because our negatives are importance-weighted rather than plainly pushed down, a confidently sampled unobserved label receives a small weight $w$, which should temper this effect. We test that directly rather than assume it.
Research Program
The work has three parts. The first builds the estimator and checks it where ground truth is available. We use small label spaces of up to about 20 labels, where $\log Z$ is computable exactly, with synthetic sparse multilabel data whose positive sets sit on a low-dimensional subset. This mirrors the manifold problem raised by Schröder et al. Here we measure the bias of $\tau(x)$ against the exact log-sum-exp, the gradient variance of $g$, and the effective sample size of the importance weights, for each proposal type.
The second part scales to the structured tasks of Sander et al., multilabel classification and permutation ranking. It also covers unconditional binary image modelling on static MNIST and Omniglot, where $\tau$ collapses to a single scalar, as in the self-normalised likelihood. There we compare against Energy Discrepancy, the main MCMC-free baseline in discrete image modelling.
The third part is analytic. We characterize how the defensive mixture weight and the policy family bound the importance-weight variance. We also study the joint dynamics when $g$, $\tau$ and $q_\theta$ update at similar rates, since a moving model makes the proposal's target non-stationary.
Baselines
The naive reference point is the original min-min method of Sander et al. with a uniform reference, run with the same energy architecture, data, number of contrast samples per example and tuning budget. The file reports no number for it: no reported result found on Lacuna for F1 or Kendall's τ of the uniform-reference min-min method. We will therefore reproduce it ourselves. Beating it means higher test F1 on the sparse multilabel tasks and higher Kendall's τ on permutations at an equal number of energy evaluations per step. On the synthetic tasks it means lower mean squared error of $\tau$ against the exact $\log Z$.
The strongest existing competitor on the image tasks is Energy Discrepancy with its grid and Bernoulli perturbations from Schröder et al. The file reports only that it is competitive with Gibbs-With-Gradient on static MNIST, with no number: no reported result found on Lacuna for a numeric ED likelihood on static MNIST or Omniglot. We will run it from its described settings with matched energy networks and wall-clock budget, and compare test log-likelihood estimated by annealed importance sampling.
A second strong competitor is a fixed informed proposal. This is the same structured policy family, fitted once by maximum likelihood to the training labels and then frozen. It isolates whether a learned proposal needs to adapt during training at all.
The key ablation keeps everything identical but swaps the $w^2$ reward for the ACE-style reverse-KL reward with entropy bonus, which is the adversarial hard-negative reward. A third variant fits $q_\theta$ to the data by maximum likelihood throughout training, in the style of R-NCE. Our method beats these if it matches or exceeds them in final accuracy while showing lower variance of $\tau$ across seeds and no collapse of the proposal's effective sample size. Every method receives the same hyperparameter search budget and five seeds.
Why not just…?
Why not just keep the uniform reference and draw more samples? In a space with $L$ labels and a handful of positives per example, the probability that a uniform draw lands near the model's mass falls exponentially in $L$. The number of samples needed to control the variance grows accordingly, and Sander et al. themselves flag this regime as a failure case. The synthetic sweep over $L$ will show whether learned proposals bend this curve at a fixed sample budget or merely shift it by a constant factor.
Why not just fit the proposal to the data once, or keep fitting it by maximum likelihood? This is the real threat. Early in training the model's distribution is far from the data, but at convergence the two coincide, so a data-fitted proposal may be nearly variance-optimal for most of training. The frozen and continuously fitted baselines exist to settle this. If either matches the $w^2$ policy, the honest conclusion is that informed but non-adaptive references suffice, and the contribution shrinks to the importance-weighted generalization of the min-min objective. We expect the gap to appear where the model over-weights outputs absent from the data, because a data-fitted proposal never visits those regions. This is exactly where unchecked energy models produce spurious modes.
Why not just sample from the energy model itself with Gibbs or persistent chains? Schröder et al. report that persistent contrastive divergence and Gibbs-With-Gradient mix poorly and trap in modes on discrete Gray-code densities and Ising models. Sander et al. also note that MCMC is impractical on permutations. We nonetheless include a matched-cost Gibbs proposal on the small synthetic tasks, so that this claim is measured in our setting rather than cited.
Why not just use a Gumbel-softmax relaxation instead of REINFORCE? The weight $w$ requires an exact discrete $y'$ and its exact probability $q_\theta(y'\mid x)$, and a relaxed sample has neither. Using relaxed samples would forfeit the unbiasedness that motivates the whole design.
Decisive Checks
Three outcomes would decide the proposal. First, on synthetic tasks with exact $\log Z$, the $w^2$ policy should reduce the error of $\tau$ and the gradient variance of $g$ relative to the uniform, frozen-informed and reverse-KL proposals. The advantage should widen as the label space grows sparser. Second, on the structured benchmarks of Sander et al., the gains in F1 and Kendall's τ should track the measured effective sample size. If accuracy improves without any improvement in weight variance, the mechanism we claim is not the one at work. Third, on synthetic data with known held-out positives that are deliberately unobserved during training, we will measure how much score mass the model assigns to those false negatives under each proposal. This tests whether importance weighting softens the exposure-bias problem that AdvInfoNCE documents for unweighted hard negatives.
References
- Joint Learning of Energy-based Models and their Partition Function
- IRGAN: A Minimax Game for Unifying Generative and Discriminative Information Retrieval Models
- Revisiting Energy Based Models as Policies: Ranking Noise Contrastive Estimation and Interpolating Energy Models
- Learning Energy-Based Models by Self-Normalising the Likelihood
- Adversarial Contrastive Estimation
- Training Discrete EBMs with Energy Discrepancy
- Estimating the Partition Function by Discriminance Sampling.
- Rationalizing Neural Predictions
- Understanding Hard Negatives in Noise Contrastive Estimation
- Flow Contrastive Estimation of Energy-Based Models
- Empowering Collaborative Filtering with Principled Adversarial Contrastive Loss