Scores as Actions: a framework of fine-tuning diffusion models by continuous-time reinforcement learning

Hanyang Zhao, Haoxian Chen, Ji Zhang, David D. Yao, Wenpin TangarXiv 2024

Abstract

Reinforcement Learning from Human Feedback (RLHF) has emerged as a primary method for aligning generative models with human intent. While successful in large language models, applying RLHF to diffusion generative models presents unique challenges. This paper provides a rigorous mathematical treatment of this problem by formulating the fine-tuning of diffusion models as an exploratory continuous-time stochastic control problem. By treating score-matching functions as actions, we develop a unified framework that leverages continuous-time reinforcement learning (RL) to improve generation quality. We establish the theoretical foundations for policy optimization and regularization within environments driven by stochastic differential equations (SDEs), offering a more natural and efficient alignment process than traditional discrete-time approaches.

Introduction

Diffusion models, such as Stable Diffusion, have revolutionized the field of generative AI by producing high-fidelity images from textual prompts. However, "steering" these models to adhere to specific human preferences—such as aesthetic quality, safety constraints, or complex multi-objective prompts—remains a significant hurdle.

Existing attempts to align these models often utilize Reinforcement Learning from Human Feedback (RLHF). Most current methods, including Denoising Diffusion Policy Optimization (DDPO) and Diffusion Policy Optimization with KL-regularization (DPOK), treat the diffusion process as a sequence of discrete steps within a standard Markov Decision Process (MDP). While functional, this approach ignores the underlying mathematical reality of diffusion: it is a continuous process governed by Stochastic Differential Equations (SDEs). Forcing a continuous process into a discrete framework can lead to structural information loss, high variance in gradients, and difficulties when applying the same logic to deterministic samplers like DDIM.

The Framework: Scores as Actions

The core innovation of this work is the conceptual shift from discrete steps to continuous-time stochastic control. Instead of viewing the model as making a series of independent decisions at each timestep, we treat the entire score-matching function as a "control" or "action" taken by an RL agent across a continuous manifold.

In this framework, the agent’s goal is to find an optimal control policy (the score function) that maximizes a cumulative reward—typically a scalar value representing human preference—while remaining close to the original pre-trained distribution. This formulation allows the fine-tuning process to respect the continuous dynamics of the denoising path, leading to more stable and mathematically grounded optimization.

Theoretical Contributions

The KL-to-Path Transformation

One of the most significant technical hurdles in RLHF is regularization. To prevent a model from "forgetting" its original knowledge or collapsing into a single high-reward output, researchers typically use a Kullback–Leibler (KL) divergence penalty. In discrete-time models, calculating the KL divergence between two complex generative distributions is computationally expensive and often requires approximations.

Theorem 1 in this paper provides a breakthrough: it proves that the global KL divergence between the fine-tuned model and the pre-trained model can be transformed into a local $L^2$ penalty integrated along the entire denoising path. This "KL-to-Path" transformation makes regularization computationally tractable, as it allows the model to be penalized based on the difference between its "actions" (scores) at every point in time, rather than comparing final probability distributions.

Unified Sampler Support

Because the framework is built on continuous-time theory, it provides a unified approach for both stochastic and deterministic generation.

  • Stochastic Generation: The environment is modeled as an SDE, where the RL agent must account for noise during the denoising process.
  • Deterministic Generation: The framework extends to Ordinary Differential Equations (ODEs), such as those used in DDIM or Rectified Flow.

Theorem 3 specifically proves that even in the absence of stochastic noise, the model can be aligned using a similar $L^2$ path-based objective, ensuring that the framework is versatile across different sampling architectures.

Continuous-Time RL Algorithms

Building on this theoretical foundation, the paper derives continuous-time versions of several standard RL algorithms:

  1. Continuous-time Policy Gradient (CPG): Provides a simplified formula for finite-horizon problems, allowing for direct optimization based on a final "lump-sum" reward.
  2. Continuous-time PPO (Proximal Policy Optimization): Adapts the popular PPO algorithm to the continuous domain to ensure stable updates.
  3. Continuous-time GAE (Generalized Advantage Estimation): Offers a way to reduce variance in gradient estimates by effectively balancing bias and variance along the denoising trajectory.

Discussion and Limitations

While this work establishes a robust theoretical foundation, it is primarily focused on the mathematical framework. The authors note that empirical results—specifically large-scale experiments on text-to-image (T2I) generation—are detailed in a companion paper.

Furthermore, the implementation of continuous-time SDE solvers for RL is inherently more complex than discrete-step versions. The success of this framework also remains dependent on the quality of the Reward Model (RM). If the RM does not accurately reflect human nuances, the "optimal" policy derived through this framework will still fail to achieve true alignment.

Conclusion

By reframing diffusion fine-tuning as a continuous-time stochastic control problem, this work bridges the gap between generative modeling and reinforcement learning theory. The "Scores as Actions" perspective, combined with the KL-to-Path transformation, provides a mathematically rigorous and computationally efficient path forward for aligning complex generative models with human intent.

Summary updated

BibTeX
@misc{zhao2024scores,
  author = {Hanyang Zhao and Haoxian Chen and Ji Zhang and David D. Yao and Wenpin Tang},
  title = {{Scores as Actions: a framework of fine-tuning diffusion models by continuous-time reinforcement learning}},
  year = {2024},
  eprint = {2409.08400},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2409.08400},
}
Figure