Fully Variational Noise-Contrastive Estimation

Christopher Zach · DOI

Abstract: By using the underlying theory of proper scoring rules, we design a family of noise-contrastive estimation (NCE) methods that are tractable for latent variable models. Both terms in the underlying NCE loss, the one using data samples and the one using noise samples, can be lower-bounded as in variational Bayes, therefore we call this family of losses fully variational noise-contrastive estimation. Variational autoencoders are a particular example in this family and therefore can be also understood as separating real data from synthetic samples using an appropriate classification loss. We further discuss other instances in this family of fully variational NCE objectives and indicate differences in their empirical behavior.

Introduction

Noise-Contrastive Estimation (NCE) is a powerful technique for training unnormalized models, such as energy-based models, by framing density estimation as a classification problem between real data and synthetic noise. However, NCE faces significant challenges when applied to models with latent variables. In such cases, the marginal likelihood is typically intractable. While Variational Bayes (VB) offers a solution via the Evidence Lower Bound (ELBO), standard NCE objectives are not fully compatible with this approach. Specifically, one part of the NCE loss is concave (amenable to ELBO), while the other is convex, making a unified variational treatment difficult. Previous "Variational NCE" attempts often only addressed one side of this intractability.

Methods: Fully Variational NCE

The core contribution of this work is the development of Fully Variational Noise-Contrastive Estimation (FV-NCE). By leveraging the theory of Proper Scoring Rules (PSRs), we identify a family of loss functions that possess a "double ELBO property." A PSR is a loss function where the expected loss is minimized when the predicted probability matches the true probability.

By carefully selecting scoring rules, we ensure that both the data-dependent and noise-dependent terms in the NCE objective are concave. This allows us to apply the ELBO to the entire objective, resulting in a "fully variational" loss that avoids intractable integrals entirely. We derive a two-parameter family of these rules, $(\alpha, \beta)$, which allows for tuning the model's sensitivity to real data versus noise.

Comparison of concave mappings $f_1$ and $f_0$ for various $(\alpha, \beta)$ parameters against the standard logarithmic rule used in NCE.

A key theoretical insight is that the standard Variational Autoencoder (VAE) is a special case of FV-NCE. Specifically, a VAE can be viewed as a variance-reduced version of this framework where $(\alpha, \beta) = (0,0)$. This reinterprets VAEs as classifiers distinguishing data from noise.

Experimental Results

We evaluated FV-NCE using toy experiments and the MNIST dataset. A significant advantage of this framework is the ability to "steer" the model's learning by choosing specific noise distributions ($p_n$). For example, by using a noise distribution concentrated on a specific digit (e.g., "1"), we can train an autoencoder that learns to represent most digits well but fails specifically on the "noise-like" digit.

MNIST reconstruction results. Using a noise distribution $p_n$ based on the digit "1", the FV-NCE model (d) exhibits poor reconstruction for "1"s compared to a standard VAE (c), demonstrating potential for targeted anomaly detection.

Quantitatively, increasing the $\alpha$ parameter forces the model to focus more strictly on the training data. This leads to higher reconstruction errors for samples that resemble the noise distribution, which is highly beneficial for Out-of-Distribution (OOD) detection tasks.

Conclusion and Future Work

FV-NCE provides a robust theoretical bridge between contrastive learning and variational inference. While demonstrated here on simpler models, the framework's ability to handle latent variables in unnormalized models opens several avenues. Future research will focus on scaling these asymmetric losses to large-scale generative tasks and exploring their utility in one-class SVMs and energy-based models.

Summary updated

BibTeX
@inproceedings{zach2023fully,
  author = {Christopher Zach},
  title = {{Fully Variational Noise-Contrastive Estimation}},
  booktitle = {SCIA},
  year = {2023},
  doi = {10.1007/978-3-031-31438-4\_12},
}
Figure