Skip to content
AI.info

Research

Calibrating Generative Models to Distributional Constraints

Overview Research area: Statistical machine learning / generative modeling — specifically distribution-level fine-tuning and calibration of generative models (diffusion models, language models, normal

arXiv
2510.10020
Published
2025-10-11
Authors
Henry D. Smith, Nathaniel L. Diamant, Brian L. Trippe

AI summary

Overview

Research area: Statistical machine learning / generative modeling — specifically distribution-level fine-tuning and calibration of generative models (diffusion models, language models, normalizing flows).

Technical level: Advanced. The paper is built on constrained optimization, Kullback–Leibler divergence, maximum entropy duality, and score-function gradient estimation. The abstract and motivation are accessible, but the method section assumes comfort with variational and information-theoretic machinery.

Scope: The paper introduces two fine-tuning algorithms, CGM-relax and CGM-reward, that steer a pretrained generative model's sampling distribution to satisfy hundreds of simultaneous expectation constraints while staying as close as possible to the original model.

What This Paper Is About

Generative models often produce samples with the wrong statistics — an image model may over-represent one class, a language model may skew gender representation, and a protein design model may emit secondary-structure compositions unlike anything seen in nature. Existing fine-tuning methods (RLHF-style reward tuning, DPO, and similar) shape individual samples but do not directly control properties of the distribution being sampled from. This paper reformulates calibration as a constrained optimization problem — find the distribution closest in KL divergence to the base model that matches a desired vector of expected statistics — and develops two tractable fine-tuning procedures that approximately solve it.

Key Contributions

  1. A constrained-optimization formulation of calibration. The paper defines calibration as an expectation constraint on a statistic vector h(x), and seeks the parametric model p_θ that minimizes D_KL(p_θ || p_base) subject to E[h(x)] = h*. This is a distribution-level objective, in contrast to sample-level reward fine-tuning.

  2. Two surrogate loss functions with unbiased gradient estimators. CGM-relax replaces the hard constraint with a squared constraint-violation penalty plus a KL regularizer, and CGM-reward converts calibration into a reward-fine-tuning problem via the maximum entropy dual. Both are optimized by stochastic gradient descent using importance-sampling and score-function estimators with leave-one-out variance reduction; neither requires h to be differentiable.

  3. A theoretical link between the two losses and the maximum entropy problem. Theorem 2.1 shows the maximum-entropy solution is an exponential tilt of the base model, p_α*(x) ∝ p_base(x) exp{α*ᵀ h(x)}, and the paper shows the minimizer of the relax loss is also such a tilt, with ‖α_λ − α*‖ shrinking at rate O(λ).

  4. A scalability analysis across hundreds of constraints and model sizes up to nine billion parameters. The companion finding is that CGM-relax scales to roughly 10³ simultaneous constraints while CGM-reward's dual estimation problem becomes infeasible beyond roughly 30 constraints, even when the reward parameters are supplied at their oracle values.

Main Findings

  • CGM-relax scales to hundreds of simultaneous constraints; CGM-reward does not. In the Gaussian-mixture simulation, CGM-relax reduced the majority of constraint violation up to k = 10³ dimensions, whereas the empirical maximum entropy problem (Equation 7) was infeasible with high probability for k > 30. CGM-relax still outperformed CGM-reward even when CGM-reward was handed the oracle α*.

  • Rare-event calibration works down to roughly 10⁻³ base probability. Both algorithms cut calibration error by 80–90% when the target mode had base probability 10⁻², and by about 50% at 10⁻³ — despite fewer than one rare sample per batch on average. Performance degraded below that threshold, and the authors attribute this to batch size rather than to the algorithm.

  • The relax loss trades calibration against fidelity through the λ hyperparameter. Small λ favors constraint satisfaction; large λ keeps the model close to p_base. The paper notes that CGM-relax incurs excess KL divergence relative to the maximum entropy solution that grows linearly with constraint dimension.

  • Protein structure models became substantially more diverse after calibration. CGM-relax gave a nearly fivefold improvement in the symmetrized KL distance to the CATH natural-protein secondary-structure distribution for the 15M-parameter Genie2 diffusion model, and roughly twofold for the 1.4B-parameter ESM3-open masked language model. This came with a higher fraction of design failures. CGM-reward required reducing the constraint count from 99 cutoff pairs to 15 to remain feasible, and produced more modest diversity gains but fewer design failures for Genie2.

  • Simply increasing sampling noise is not equivalent. Increasing Genie2's sampling noise from σ = 0.5 to σ = 1 improved diversity but at a much higher failure rate, indicating the gains are not obtainable through a naive sampling adjustment.

  • Practical recommendation: try CGM-reward first. Because CGM-reward has no regularization hyperparameter to tune, the authors suggest starting there under compute constraints and falling back to a full λ grid search with CGM-relax if results are unsatisfactory.

Methodology in Plain English

The core difficulty is that both the objective and the constraint in the calibration problem involve expectations over a model you are still training, which makes them intractable. The authors sidestep this with two different tricks.

CGM-relax throws the hard constraint into the loss as a penalty. Instead of forcing the model's average statistic to equal the target, it adds a term that penalizes the squared distance between them, plus a term that penalizes drifting away from the original model. The relative weight of these two terms is controlled by λ. The squared penalty is chosen specifically because it admits an unbiased Monte Carlo estimate with a small bias-correction term.

CGM-reward exploits a classical result from maximum entropy theory: the distribution that satisfies the calibration constraint while staying closest in KL to the base model has the form of the base model tilted by an exponential factor exp{αᵀ h(x)}. The paper shows how to estimate the tilt parameter α* by solving a concave optimization problem over a finite set of samples drawn from the base model. Once α* is estimated, the calibration problem becomes exactly a reward-fine-tuning problem with reward r(x) = αᵀ h(x), and the authors can reuse standard reward-fine-tuning objectives.

For both losses, gradients are computed using an importance-sampling identity: the expectation over p_θ is rewritten as an expectation over a fixed reference distribution with a density-ratio weight, which lets gradients pass through. In practice the reference is the current model with gradients stopped, and leave-one-out baselines are subtracted to reduce variance. The authors demonstrate this works even for high-dimensional latent spaces like diffusion trajectories and masked language models.

The empirical evaluation unfolds in two tiers. First, a controlled simulation with a diffusion model targeting a Gaussian mixture, where the exact maximum entropy solution is computable and hyperparameter behavior can be studied cleanly. Second, three domain case studies: protein backbone generation (Genie2, ESM3-open), image generation with a normalizing flow calibrated against LLM-produced image captions, and gender-bias reduction in a language model that writes children's stories. Each experiment ran on a single H100 GPU.

Why This Matters

Impact on research. Prior work on distribution-level constraints applied to only one model class (usually autoregressive LMs or diffusion models) and was validated on low-dimensional constraints. This paper provides a single framework with theory that applies to any generative model with tractable likelihood and a computable gradient of the log-density, and pushes validation to hundreds of simultaneous constraints at the billion-parameter scale. It also cleanly separates the two surrogate losses, characterizing when each is appropriate — a distinction the maximum entropy literature had not previously connected to reward fine-tuning.

Real-world applications.

  • Protein design: removing the reliability-versus-diversity trade-off in structure generators, so models can produce both plausible and diverse folds rather than collapsing onto a narrow set of safe structures.
  • Fairness in language generation: reducing systematic skew in how gender, race, religion, or age are represented in generated text without retraining from scratch.
  • Class-balanced image synthesis: correcting imbalanced class proportions in generated image datasets used to augment training data, using an LLM annotator to define the constraint.
  • Synthetic data for regulated domains: enforcing known population statistics on generated tabular or sequential data before it is used for downstream analysis.

Industry relevance. The method operates as a post-hoc fine-tuning step on top of an existing model, runs on a single GPU per experiment, and requires no differentiable constraint function. That makes it cheap to deploy for teams that already have a trained generator and know the statistics they need to match. The explicit fidelity-versus-calibration knob (λ) is directly useful for practitioners who must justify how far a deployed model has drifted from its validated baseline.

Future Directions

  • Scaling CGM-reward's dual estimation. The empirical maximum entropy problem becomes infeasible past roughly 30 constraints. Whether better solvers, stochastic dual methods, or low-rank structure in h can extend this range is unresolved.
  • Improving CGM-relax's excess KL divergence. The relax solution drifts from the maximum entropy optimum at a rate that grows with constraint dimension. Tightening this gap without sacrificing the ability to handle 10³ constraints is a clear target.
  • Rare-event calibration below 10⁻³. The authors suspect larger batch sizes would help, but the scaling behavior of the estimators in the extreme-rare-event regime remains open.
  • Applying CGM to model classes the paper did not test. The framework requires only sampling plus tractable log-density gradients, which excludes some popular families; extending it to those cases, and to constraints that are themselves learned rather than fixed, are natural next steps.

Target Audience

Machine learning researchers working on fine-tuning, alignment, and distribution matching; statisticians interested in maximum entropy methods and constrained stochastic optimization; and applied practitioners in computational biology, synthetic data generation, or fairness-aware NLP who have a trained generative model and a known set of target statistics they need it to respect. Readers without a background in variational inference or information theory should expect the technical sections to require significant effort, though the introduction, simulations, and case studies are readable on their own.

Authors’ abstract

Generative models frequently suffer miscalibration, wherein statistics of the sampling distribution, such as the fraction of generations in a given class, deviate from desired values. We frame calibration as a constrained optimization problem and seek the closest model in Kullback-Leibler divergence satisfying a calibration constraint. To address the intractability of imposing these constraints exactly, we introduce two surrogate objectives for fine-tuning: (1) the relax loss, which replaces the constraint with a miscalibration penalty, and (2) the reward loss, which converts calibration into a reward fine-tuning problem. We demonstrate that these approaches substantially reduce calibration error across hundreds of simultaneous constraints and models with up to nine billion parameters, spanning applications in protein design, image generation, and language modeling.

Read the original paper