Density Ratio Estimation with Conditional Probability Paths

Hanlin Yu, Arto Klami, Aapo Hyvarinen, Anna Korba, Omar Chehab

Abstract

Estimating the ratio between two high-dimensional probability distributions is a fundamental challenge in machine learning, essential for tasks like mutual information estimation and energy-based modeling. Traditional methods often fail when distributions have minimal overlap, a problem known as the "density chasm." While Time Score Matching (TSM) offers a solution by integrating scores along a continuous probability path, it is computationally expensive due to the requirement of double automatic differentiation. We present Conditional Time Score Matching (CTSM), a novel framework that utilizes conditional probability paths to bypass these computational bottlenecks. Our vectorized variant, CTSM-v, introduces a powerful inductive bias that enhances stability in high dimensions. We demonstrate that CTSM-v achieves significant speedups, faster convergence, and superior accuracy compared to existing methods.

Introduction

Density ratio estimation (DRE) is ubiquitous in machine learning, yet it remains notoriously difficult in high-dimensional spaces. Standard approaches like Noise Contrastive Estimation (NCE) struggle when the source and target distributions are significantly different. Recent advancements introduced the concept of connecting distributions via a "probability path" and integrating a "time score." However, the standard Time Score Matching (TSM) objective is computationally intensive, requiring derivatives of the neural network with respect to both time and model parameters. This leads to slow training and potential instability.

Methods

Conditional Time Score Matching (CTSM)

To address the limitations of TSM, we propose CTSM. Inspired by recent breakthroughs in flow matching and diffusion models, CTSM augments the state space with a conditioning variable $z$. By conditioning the probability path on specific data points, the path becomes a tractable distribution (e.g., a Gaussian). We mathematically demonstrate that regressing against this tractable conditional time score is equivalent to learning the intractable marginal time score, effectively eliminating the need for double automatic differentiation.

Vectorized Variant (CTSM-v)

Learning a scalar time score can be challenging for neural networks in complex landscapes. We introduce CTSM-v, which requires the network to output a vector of components that sum to the total time score. This per-dimension decomposition acts as an inductive bias that smoothens the optimization landscape, enabling the model to scale to complex datasets like MNIST.

Experimental Results

Efficiency and Convergence

Our evaluation shows that CTSM and CTSM-v provide massive computational advantages. By avoiding double automatic differentiation, CTSM-v reduces the time per iteration from approximately 15ms (for TSM) to 5ms. Furthermore, in high-dimensional mutual information estimation tasks (up to 320D), CTSM-v converges to the ground truth in significantly fewer iterations than TSM.

Performance comparison of TSM, CTSM, and CTSM-v showing time per iteration, mutual information estimation, and error convergence.

Accuracy and Scaling

On synthetic benchmarks involving high-dimensional Gaussians and Gaussian Mixture Models, CTSM-v consistently outperforms TSM in terms of Mean Squared Error (MSE). As dimensionality increases, the stability of CTSM-v becomes even more apparent, maintaining lower error rates where previous methods begin to diverge.

MSE comparison across varying dimensionalities, demonstrating the superior scaling and accuracy of CTSM-v.

Modeling Complex Distributions

CTSM-v successfully models complex image distributions. While TSM often becomes unstable when modeling MNIST images directly in pixel space, CTSM-v achieves a competitive 1.03 Bits Per Dimension (BPD) and generates high-quality samples, proving its robustness in ambient high-dimensional spaces.

Conclusion

Conditional Time Score Matching represents a significant step forward for density ratio estimation. By leveraging conditional paths and vectorized outputs, we transform a computationally brutal task into an efficient and stable optimization problem. Future work will explore the design of optimal probability paths to further minimize estimation error and expand the framework's applicability to even more diverse machine learning domains.

Summary updated

BibTeX
@inproceedings{yu2025density,
  author = {Hanlin Yu and Arto Klami and Aapo Hyvarinen and Anna Korba and Omar Chehab},
  title = {{Density Ratio Estimation with Conditional Probability Paths}},
  booktitle = {International Conference on Machine Learning},
  year = {2025},
  url = {https://openreview.net/forum?id=Gn2izAiYzZ},
}
Figure