Directly Fine-Tuning Diffusion Models on Differentiable Rewards
Authors: Kevin Clark
Paul Vicol
Kevin Swersky
David J. Fleet
Venue: ICLR 2024 poster (2024)
Keywords: diffusion models
preference-based learning
Primary area: generative models
TL;DR: We present methods that efficiently fine-tune diffusion models on reward functions by backpropagating through the reward.

Abstract: We present Direct Reward Fine-Tuning (DRaFT), a simple and effective method for fine-tuning diffusion models to maximize differentiable reward functions, such as scores from human preference models. We first show that it is possible to backpropagate the reward function gradient through the full sampling procedure, and that doing so achieves strong performance on a variety of rewards, outperforming reinforcement learning-based approaches. We then propose more efficient variants of DRaFT: DRaFT-K, which truncates backpropagation to only the last K steps of sampling, and DRaFT-LV, which obtains lower-variance gradient estimates for the case when K=1. We show that our methods work well for a variety of reward functions and can be used to substantially improve the aesthetic quality of images generated by Stable Diffusion 1.4. Finally, we draw connections between our approach and prior work, providing a unifying perspective on the design space of gradient-based fine-tuning algorithms.

Published as a conference paper at ICLR 2024
DIRECTLY FINE-TUNING DIFFUSION MODELS ON DIF- FERENTIABLE REWARDS
Kevin Clark", Paul Vicol", Kevin Swersky, David J. Fleet Google DeepMind "Equal contribution (kevelan ark, paulvicol col, kswersky, davidfleet) @google..cm
ABSTRACT
We present Direct Reward Fine-Tuning (DRaFT), simple and effective method for fine-tuning diffusion models to maximize differentiable reward functions, such scores from human preference models. We first show that it is possible to back- propagate the reward function gradient through the full sampling procedure, and that doing achieves strong performance reinforcement bearning-basee approaches. We then propose more efficient variants of DRaFT: DRaFT-K, which truncates backpropagation to only the last K steps of sampling, and DRaFT-LV, which obtains lower-variance gradient estimates for the case when K 1. We show that our methods work well for variety of reward functions and can be used to substantially improve the aesthetic quality of images generated by Stable Diffusion 1.4. Finally, we draw connections between our approach and prior work, providing unifying perspective on the design space of gradient-basse fine-tuning algorithms.
variety of rewards, outperforming
INTRODUCTION
Diffusion models (Sohl-Dickstein et al., 2015; Song & Ermon, 2019; Ho et al., 2020; Song et al., 2021b; Kingma et al., 2021) have revolutionized generative modeling for continuous data, achieving impressive results across modalities including images, videos, and audio. However, for many use cases, modeling the training data distribution exactly (e.g. diverse images from the web) does not align with the model's 's desired behavior (e.g. generating aesthetically pleasing images). To overcome this mismatch, text-to-image diffusion models commonly employ methods like classifier guidance (Ho & Salimans, 2021) to improve image-text alignment, and are fine-tuned on curated datasets such as LAION Aesthetics (Schuhmann & Beaumont, 2022) to improve image quality.
Within the language modeling community, aligning model behavior with human preferences is widely accomplished through fine-tuning with reinforcement learning (RL), such as with RL from human feedback (RLHF; Ziegler et al. 2019; Stiennon al. 2020; Ouyang et al. 2022; Bai et al. 2022a). Inspired by RLHF, supervised and reinforcement learning methods have been developed to train
shanning droutffor of powingg of
Rully and etop antique cools moaddy Wostmation
Highty dctaveed phottggaphh with diotes
photo of single Ausht lighing.
Impressionas oointing
lysting golden
wosking
hypermedern
Stable Diffsioo 1.4
After Brwaad Fine-Tuning Tuning
Figure 1: DRaFT fine-tuning for human preference reward models yields more detailed and stylized images than baseline Stable Diffusion. See Figure 37 in Appendix for more samples.

---

Published as a conference paper at ICLR 2024
diffusion models on human preference models or other rewards (Lee al., 2023; Wu et al., 2023b; Dong et al., 2023; Black et al., 2023; Fan et al., 2023). While showing some success at improving text alignment or image aesthetics on narrow domains, these approaches are sample inefficient and have not been scaled up to the level of generally improving generation style across diverse prompts.
We propose simple and efficient approach for gradient- based reward fine-tuning based on differ- entiating through the diffusion sampling process. We first introduce Direct Reward Fine-Tuning (DRaFT), a conceptually straightforward method that backpropagates the reward through the full sampling chain. To keep memory and compute costs low, we use gradient checkpointing (Chen et al., 2016) and optimize LoRA weights (Hu et al., 2022) rather than the full set of model parameters. Then, we introduce modifications to DRaFT that further improve its efficiency and performance. First, we propose DRaFT-K, variant that backpropagates through only the last K steps of sampling to compute the gradient. We show empirically that full backpropagation can result in exploding gradients, and that using the truncated gradient performs substantially better given the same number of training steps. Then, we further improve efficiency by introducing DRaFT-LV, a variant of DRaFT-1 that computes lower-variance gradient estimates by averaging over multiple noise samples.
We apply DRaFT to Stable Diffusion 1.4 (Rombach et al., 2022) and evaluate it variety of reward functions and prompt sets. As our methods leverage gradients, they are substantially more efficient than RL-based fine-tuning basclines, for example maximizing scores from the LAION Aesthetics Classifier (Schuhmann & Beaumont, 2022) > 200x faster than the RI. algorithms from Black et al. (2023). DRaFT-LV is particularly efficient, learning roughly 2x faster than ReFL (Xu al., 2023), previous gradient-basel based fine-tuning method. We scale up DRaFT to train on hundreds of thousands of prompts and show that it improves Stable Diffusion on human preference rewards such as PickScore (Kirstain et al., 2023) and Human Preference Score v2 (Wu et al., 2023a). We further show that we can interpolate between the pre-trainet trained and fine-tuned models by scaling the LoRA weights, and we can combine the effects of multiple rewards by linearly combining fine-tuned LoRA weights. Finally, we showcase how DRaFT can be applied to diverse reward functions including image compressibility and incompressibility, object detection and removal, and generating adversarial examples.
RELATED WORK
We provide an extended discussion of related work in Appendix D.
Learning human preferences. Human preference learning trains models on judgements of which behaviors people prefer, rather than on human demonstrations directly (Knox & Stone, 2009; Akrour et al,, 2011). This training is commonly done by learning a reward model reflecting human preferences and then learning& policy that maximizes the reward (Christiano et al., 2017; Ibarz et al., 2018). We apply DRaFT to optimize scores from existing preference models, such as PickScore (Kirstain et al., 2023) and Human Preference Score v2 (Wu et al., 2023a), which are trained on human judgements between pairs of images generated by diffusion models for the same prompt.
Guidance (Song et al., 2021b; Dhariwal & Nichol, 2021) steers sampling towards images that satisfy a desired objective by adding an auxiliary term to the score function. Various pre-trained models can be used provide guidance signals, including classifiers, facial recognition models, and object detectors (Bansal et al., 2023). Noisy examples obtained during sampling may be ouitt--disttibuttin for the guidance model. Two approaches to mitigate this are: (1) training the guidance model on noisy data (Dhariwal & Nichol, 2021) and (2) applying a guidance model to predicted clean images from one-step denoising (Li et al., 2022). However, (1) precludes the use of off-the-shelf pre- trained guidance functions and (2) applies guidance to out-of-distributio blurry images for high noise levels. DRaFT avoids these issues by only applying the reward function to the final generated image.
Backpropagation through diffuusion sampling. Watson et al. (2022) differentiate through sam- pling to learn sampler hyperparameters (rather than model parameters) in order to reduce inference cost while maintaining perceptual image quality. Fan Lee (2023) also propose an approach to speed up sampling: they consider doing this by backpropagating through diffusion sampling, but focus on an RL-based approach due to memory and exploding/vanishing gradient concerns. Both Fan & Lee (2023) and Watson et al. (2022) aim to improve sampling speed, rather than optimize arbitrary differentiable rewards, which is our focus. Like DRaFT, Direct Optimization of Diffusion Latents (DOODL; Wallace et al. 2023) backpropagates through sampling to optimize differentiable rewards; however DOODL optimizes the initial noise sample Xy rather than the model parameters. While this does not require training phase, it is much slower inference time because the optimization
2

---

Published as a conference paper at ICLR 2024
must be redone for each prompt and metric. Outside of image generation, Wang et al. (2023a) train diffusion model policies for reinforcement learning by backpropagating through sampling.
Reward Fine-Tuning with Supervised Learning. Lee al. (2023) and Wu et al. (2023b) use supervised approaches to fine-tune diffusion models on rewards. These methods generate images with the pre-trained model and then fine-tune on the images while weighting examples according to the reward function discarding low-reward examples. Unlike DRaFT or RL methods, the model is not trained online on examples generated by the current policy. However, Dong et al. (2023) use an online version of this approach where examples are re- re-generated over multiple rounds of training, which can be viewed as a simple kind of reinforcement learning.
Reward Fine-Tuning with Reinforcement Learning. Fan & Lee (2023) interpret the denoising process as a multi-step decision-making task and use policy gradient algorithms to fine-tune diffusion samplers. Building on it, Black et al. (2023) and Fan al. (2023) use policy gradient algorithms to fine-tune diffusion models for arbitrary black-box objectives. Rather than optimizing model parameters, Hao et al. (2022) apply RL to improve the input prompts. RL approaches are flexible because they do not require differentiable rewards. However, in practice many reward functions are differentiable, or can be implemented or approximated a differentiable way. and thus analytic gradients are often available. In such cases, using reinforcement learning discards useful information.
Reward Feedback Learning (ReFL). ReFL (Xu et al., 2023) uses reward function gradients to fine-tune diffusion model. evaluates the reward on the one-step predicted clean image, r r(x,, c) from randomly-chosen step L along the denoising trajectory rather than on the final image, as DRaFT does. While ReFI. performs similarly to DRaFT-1, DRaFT-LV is substantially more efficient, training approximately 2 faster. We further discuss how ReFL relates to DRaFT in Section 4.
BACKGROUND ON DIFFUSION MODELS
Diffusion Models. Diffusion models are latent variable models based on the principle of iterative denoising: samples are generated starting from pure noise XT ~ N(O, via a sequence of applica- tions of a learned denoising function Eş that gradually removes noise over ' timesteps. Diffusion models often learn the denoiser éş by minimizing the following re-weighted variational lower bound of the marginal likelihood (Ho et al., 2020):
Simple 0) = EE~U Ptt. [||e En (a:Xo + oze, () [P]]
(1)
where o, /1- of is an increasing noise schedule.' Here, Co is trained prediet the noise added to the clean datapoint Xo. For image data, eg is typically parameterized by a UNet (Ronneberger
al., 2015). We use conditional diffusion models, which include context such as text prompt passed to the denoising function (x c, For inference (i.e., sampling), one draws noise sample Xy, and then iteratively uses Eg to estimate the noise and compute the next latent sample Xt-1-
Classifier-Free Guidance. Classifier-free guidance (CFG) uses a linear combination of the condi- tional and unconditional score estimates, denoising according to (1 (1+w(t))c(x,, c, c,t)- 2, t) where ve(l) is the guidance weight and 2 indicates an empty conditioning signal. requires that is replaced with Ø part of the time during training so that the unconditional score function is learned.
4 METHOD
We propose simple approach for finettuning diffusion models for differentiable reward functions. Our goal to fine-tune the parameters O of a pre-trained diffusion model such that images generated by the sampling process maximize differentiable reward function r:
J(0) X.. [r(sample(0. O, c, x))
where sample(0, (,, c. ) denotes the sampling process from time = T + with context c.
DRaFT. First, we consider solving Eq. 2 by computing V Vor(sample(( c, x,xr), c) and using gradi- ent ascent. Computing this gradient requires backpropagation through multiple diffusion model calls in the sampling chain, similar to backpropagation through time in recurrett neural network. We use two approaches to reduce the memory cost of DRaFT: 1) low-rank adaptation (LoRA) (Hu et al., 2022); and 2) gradient checkpointing (Chen et al., 2016).
We use VDM notation (Kingma et al., 2021), where ot corresponds yoe in the Ho et al. (2020) notation.
3

---

Published as a conference paper at ICLR 2024
OLORA
DRaFT-LV
Prompt
Reward
"majestic lion'
J(BLORA) - r((x))
XT
X0
Aesthetic Score
Sample(O0t OLoRA C, xT)
PickScore
Compressibility
DRaFT
Object Detection
DRaFT-K
Figure DRaFT backpropagates reward gradients through the sampling process into LoRA weights. DRaFT-K truncates the backward pass, differentiating through only the last steps of sampling. DRaFT-LV improves the efficiency of DRaFT-1 by generating multiple examples in the last step to reduce variance.
LoRA. Rather than fine-tuning the full set of model parameters, Low-Rank Adaptation (LoRA) (Hu et al., 2022) freezes the weights the pre-trained model, and injects new low-rank weight matrices alongside the original model weights, whose contributions outputs. Mathematically, for a layer with base parameters Wo whose forward pass yields the LoRA adapted layer is h Wox BAx, where BA is low-rank matrix. LoRA dramatically reduces the number of parameters that need to be optimized, which reduces the memory requirements of fine-tuning. Another benefit is that, because the information learned by the fine-tuned model is contained within the LoRA parameters, we can conveniently combine fine-tuned models by taking linear combinations the LoRA parameters (Figure 5, right) and interpolate between the original and fine-tuned model by re-scaling the LoRA parameters (Figure 7).
summed produce the adapted model Wox,
Gradient Checkpointing. Gradient check- pointing (Gruslys et al., 2016; Chen et al., 2016) reduces the memory cost of storing activations for use during backprop at the cost of increased compute, by storing only subset of activations in memory and re- re-computing the others the fly. Specifically, we only store the input latent for each denoising step, and re-materialize the UNet activations during backprop. Implementing checkpointing in JAX (Bradbury et al., 2018) is as simple as adding @ @jax. checkpoint to the body of the sampling loop.
Algorithm 1 DRaFT (with DDIM sampling)
Inputs: pre-trained diffusion model weights 0, reward r. prompt dataset Pe while not converged do
randint(1,
if ReFL. if DRaFT if DRaFT-K
T
Arrnnaaee
K
1
if DRaFT-LV
C~ Pc. XT ~ (O. for l T ..... do
if mmmeate then
X stop_ stop_grad(x))
DRaFT-K. While gradient checkpointing makes it possible to backpropagate through the full sampling chain, we found that opti- mization speed and overall performance can be substantially improved by truncating backprop through only the last K sampling steps. We call the resulting approach DRaFT-K, illustrated Truncating backprop reduces the compute needed per step by decreasing the number of backward passes through the UNet. Surprisingly, it also improves training efficiency per-step, which we investigate further in Section 5.2. For small K (e.g., K 1), the memory cost of unrolling is small, and we do not need gradient checkpointing.
X1 = (x+ (x,, c, f))/a;
if lannnatt and ReFI. then
Xy R Xo
break
X1-1 = - 0x
9 V Vor(xo, c)
in Figure
DRaFT-LV then
for i I...., do
é ~ 10.
X1 01 arstop__get stoop_grad(x_ toc
K = [x] o 1))/a1
g g + (x).
- - n
return 0
DRaFT-LV. Empirically, we found that simply setting K = (i.e., only differentiating through the last sampling step) results in the best reward vs. compute tradeoff. Here, we propose a method for improving the efficiency of DRaFT-1 further by reducing the variance of the gradient estimate. We call this low-variance estimator DRaFT-LV. The key idea is to use the forward diffusion process to produce additional examples to train on without re-generating new images. Specifically, we noise the generated image times, and use the summed
4

---

Published as a conference paper at ICLR 2024
reward gradient over these examples. Although DRaFT-LV adds additional forward and backward passes through the UNet and reward model, in practice this is fairly little overhead compared to the T UNet calls already needed for sampling. We found that using DRaFT-1 while adding around 10% compute overhead for our reward functions.
2 is around 2x more efficient than
General Reward Fine-Tuning Algorithm. Algorithm 1 presents unified framework encompass- ing several gradient-based approaches for diffusion fine-tuning. In particular, it includes as special cases DRaFT, DRaFT-K, DRaFT-LVV, and ReFL (Xu et al., 2023), which differ in how the gradient computed. DRaFT-K inserts a stop-gradient operation X, stop_gradl xx) at sampling iteration K, to ensure that the gradient is only computed through the last steps (as the gradient does not flow through stop_grade stop gradient and breaks out of the sampling loop early, returning a one-step predicted clean image. Additionally, it does so random timestep towards the end of sampling (we use 50-step sampling). In this unifying framework, ReFL with m = 1 is equivalent to DRaFT-1. Lastly, DRaFT-LV averages the last-step gradient over multiple examples with different noises reduce variance. Note that in practice we use Adam and LoRA, not shown in the algorithm for simplicity.
vanilla DRaFT can be obtained by setting K T. ReFL inserts
20 for
5 EXPERIMENTS
In this section, we show that DRaFT can be applied to a wide range of reward functions, and that it substantially outperforms prior reward fine-tuning methods. We used Stable Diffusion 1.4 as the base diffusion model. As it is latent diffusion model (Rombach et al., 2022), applying DRaFT involves backpropagating through both the sampling process that produces the final latent representation and the decoder used to obtain the image. DRaFT is applicable to any differentiable sampler; in experiments, we used DDIM (Song et al., 2021 a), but we found that ancestral sampling performs similarly. We used 50 sampling steps, so DRaFT-50 corresponds to backpropagating through the full sampling chain (i.e., vanilla DRaFT). We used classifier- free guidance weight 7.5, Experimental details, hyperparameters, and additional results are provided in Appendices A and B.
5.1 FINE-TUNING FOR AESTHETIC QUALITY
Rewardnss. fine-turing
Reward-7
Rewardm9
Reward-11 (collapsed)
10-
Assthettc Score
DRaFT-LY DRWFT-50
ReFiL
DDPG
Prempt engireering
Stuble Diffesion
1000
2:000
3000
4000
Sc00
Reward Queries
Figure 3: Left: Sample efficiency of methods when maximizing scores from the LAION Aesthetic Classifier. DDPO (Black et al., 2023) results were obtained from correspondence with the authors, as the results in the original paper use a huggy implementation; DDPO achieves a reward of 7.4 after 50k reward queries. Right: Qualitative comparison of generations as training progresses.
First, we compared fine-tuning methods to improve aesthetic quality scores given by the LAION aesthetic predictor, which is trained to rate images of 45 prompts from Black et al. (2023), where each prompt is the name a common animal. We compared against the DDPO (Black et al., 2023) RL method, ReFL (Xu et al., 2023), and prompt engineering baseline (see Appendix A.3 for more details). Results are shown in Figure 3. Because does make of gradients, reinforcement learning is much less sample-efficient than DRaFT. Interestingly, truncating DRaFT to a single backwards step substantially improves sample efficiency; we analyze this phenomenon further Section 5.2. Thanks to its lower-variance gradient estimate, DRaFT-LV further improves training efficiency. We observed that the methods initially produced improved images, but eventually collapsed producing very similar high-reward images.
scale of through 10. We used the simple set
5

---

Published as a conference paper at ICLR 2024
0.35
Human Preference Score v2
0.345
0:113
0.30
5333
2,22
0.312
0.3
0.332
0.25
VOGAN CLI
3,20
0222
Deept DeepFloyd loyd XL
6227
SDXL Baree 0.9
0.23
0.222
0272
SD 1.4 Best/16
ReFi L+ Guidance
DRaFT-1 PickSc
DR T- Pick a
DRa- T-LV PickScar
DALL-E
5.0.0
DOODL
DRaF TT-0
DRaFT:33
DRaFT-30
DRaFT-3
DRaFT:3
DRaFT-LM
DRaF T-IV
ReFL
SD
Figure 4: Comparison the HPSv2 rewards achieved by variety baselines (denoted by gray bars), ReFL, K, and DRaFT-LV on the HPDv2 test set. All baselines except for DOODL and best of 16 are taken from Wu et al. (2023a). Unless indicated otherwise, models are Stable Diffusion 1.4 fine-tuned for 10K steps.
Reward Hacking. In Figure (Right), observe instance of reward hacking, where the fine- tuned model loses diversity and collapses to generate a certain high-reward image. Reward hacking points to deficiencies in existing rewards; efficiently finding gaps between the desired behavior and the behavior implicitly captured by the reward a crucial step in fixing the reward. Improved techniques for fine-tuning, such DRaFT, aid the development of new rewards. We discuss reward hacking further in Appendix B.8.
5.2 FINE-TUNING ON HUMAN PREFERENCES
Next, we applied DRaFT to two reward functions trained on human preference data: Human Preference Score v2 (HPSv2; Wu et al. 2023a) and PickScore (Beaumont et al., 2022).
Qualitative comparison reward functions. First, we trained DRaFT models using the aesthetic, PickScore, and HPSv2 rewards the same set of 45 animal prompts. As the reward models behave differently for photographs and paintings, we trained two versions of each model. Qualitatively, we found that the different reward functions led quite different generated images (see Figure Left). HPSv2 generally encourages more colorful but less photorealistic generations.
Prompt:
Prompt: cointin deer
Prompt potnting deer
fune-tinnng
Aesthetic reward
fine
Aesthetic revard
Aesthetic
Aesthetic Pickscore
HPS52 reward
Pickscore reward
HPSv2 reward
PickScore reward
HPSw2 PickScore
All
Figure 5: Left: Comparison of generations (using the same random seed) from DRaFT models fine-tuned using the LAION Aesthetic Classifier, Human Preference Score v2, and PickScore reward functions. Right: Outputs of DRaFT models combined by mixing the LoRA weights for different reward functions.
a partingg of anold man
a parming of racoon washing dishes
painting of tree
painting a ciy skylie a painting of spaceship
abstract modern painting
Figure 6: A DRaFT model trained on a simple prompt set of 45 animals generalizes well to other image subjects while preserving the learned style (Human Preference Score v2 reward).
models to several baselines on the Human Preference Score v2 benchmark (Wu al., 2023a). We used DRaFT to
Human Preference Score Comparison. Next, we compared

---

Published as a conference paper at ICLR 2024
fine-tune for HPSv2, using the Human Preference Dataset v2 (HPDv2) traning set prompts. In Figure 4, we report the mean performance over the four test set categories; Table in Appendix B.2 provides detailed breakdown of results by category. We compared DRaFT to selected set of baselines from Wu et al. (2023a), as well as to DOODL (Wallace et al., 2023) and ReFl. (Xu et al., 2023). As ReFL. does not use guidance during training. we also experimented with adding guidance it. Interestingly, the model with guidance performs similarly; possibly fine-tuning compensates for the lack of guidance similarly how guided diffusion models can be distilled into unguided ones (Meng et al., 2023). DRaFT-1 slightly outperforms ReFL, while being simpler to implement. DRaFT-LV achieves the best reward value, learning approximately 2 faster than DRaFT-1 (see the "DRaFT-LV, 5k steps" bar). Figure 4 also provides an ablation comparing DRaFT-K for K {1, 5, 10, 30, 50). We found that using smaller K was beneficial, both in terms of training time and final performance.
Evaluating Generalization. Next, we investigated several types of generalization: 1) prompr generalization, where we fine-tuned for HPSv2 on one prompt dataset (Pick-a- a-Pic) and evaluated performance on another prompt dataset (HPDv2)-thee Pic" bars Figure 4; and 2) reward generalization, where we fine-tuned using a different reward (PickScore) than we used for evaluation bars. DRaFT-1 and DRaFT-LV transfer well across prompt sets and fairly well across reward functions. We also show qualitative prompt generalization results in Figure 6: we found that model fine-tuned using only 45 animal prompts learns a style that generalizes well to other prompts.
results are shown by the "DRaFT, Pick-a-
these results are shown by the "DRaFT, PickScore"
Large-Scale Multi-Rewand Model. We pushed the scale of DRaFT-LV further by performing a 2x longer training run on the larger HPDv2 dataset, optimizing for a weighted combination of rewards, PickScore = 10, HPSv2 = 2, Aesthetic 0.05." Images generated by the model are shown in Figure 1. Overall, the fine-tuned model produces more detailed and stylized images than baseline Stable Diffusion. In some cases, fine- -uninun improves the model's image-text alignment as well as aesthetics, because the PickScore and HPSv2 rewards measure the similarity between the prompt and image embeddings. For example, the fine-tuned model almost always generates images faithful the prompt "a raccoon washing dishes," while baseline Stable Diffusion does so less than half the time. However, we also found that the model sometimes overgeneralizes the reward function, generating detailed images even when the prompt calls for a simpler style (see Figure B. in Appendix B).
a= 0.0
a=
0=8
a= 0.9
a=
1.0
$=1.0
Human Preference Score v2
HPSv2
0.755
PickScore
F
Combined
==00
0.5
PickScore
Figure 7: Interpolating LoRA parameters. Left: Generations from DRaFT models with different scalar multipliers applied to the LoRA weights. Scaling LoRA parameters yields semantic interpolations between the pre rre-trained and fine-tuned models. Right: Combining LoRA parameters that have been tine-tune independently for two different rewards PickScore and HPSv2 allows for fine mne-grained control over style without additional training. For fixed noise sample, we show images generated using a + 3PUPS-
Scaling and Mixing LoRA Weights. It is possible to control the strength of the fine-tuning simply by scaling the LoRA parameters: multiplying them by scalar a moves the adapted parameters closer to the original, pre-trained model. Figure 7 (Left) shows that this method smoothly interpolates between the pre- pre-trained and DRaFT models. The LoRA scale could become useful hyperparameter for controlling generations from DRaFT models similarly to how guidance strength is currently used.
TThe gradients of the different rewards have substantially different norms, leading to the wide range of coefficients. The particular values were chosen hased sample quality after experimenting with few settings.
7

---

Published as a conference paper at ICLR 2024
While we experimented with KL regulariztaion and early stopping alternative ways of reducing reward overfitting (see Figure 29 in Appendix B.8), we found LoRA scaling to work best.
We also probed the compositional properties of LoRA weights adapted for different rewards. One can combine the effects of multiple reward functions by interpolating the LoRA weights of the respective DRaFT models (Figure 5, Right). In Figure 7 (Right), linear combinations of LoRA parameters trained separately for the PickScore and HPSv2 rewards, using scaling coefficients a and B. The resulting images mix the semantics of HPSv2 and PickScore, and are simultaneously more saturated and detailed than the pre-trained model outputs. While it would also be possible instead directly sum the score functions of the models (similar Liu et al. 2022), this would increase generation time proportionally to the number of combined models.
show images generated using
Understanding the Impact of K. Interestingly, we found that trun- cated backpropagation improves sample efficiency as well as compute efficiency. Our analysis suggests that gradients explode as K increases, which may lead to optimization difficulties for large K (see Figure 8). We found that gradient clipping somewhat alleviates this issue (see Figure 28 in Appendix B.7), but does not fully close the gap. In Figure 9, we show an ablation over K for aesthetic fine-tuning: performance degrades as K increases for K > 10. In Figure 10, we show that although DRaFT-1 only computes gradients through the final generation step, it generalizes across time and affects the whole sampling chain. We compare samples generated with different LoRA start iterations M, where we applied the A-ad-ptd diffusion parameters for the last M steps of the sampling chain, while in the first T - M steps we used the pre-trained Stable Diffusion parameters without LoRA adaptation. We observe that adaptation does not happen only at the end of sampling (also see Figure 26 in App. B.7). We also investigated the opposite scenario, where the LoRA-adapted parameters are used in the first M steps, after which LoRA "turned off" and we use only the original pre-trained parameters for the remaining T M steps (see Figure 27 App. B.7), which shows that it is also important to apply the LoRA parameters early in sampling.
Gradient Norm
10
10
10-1
10 40 50 K
Figure 8: Gradient norms
DRaFT-K Aesthetic Ablation
50
30
10
2
K=1
Aesthetic Score
10
K=2
K=5
K=10
K=20
K=30
K=40
K=50
0 200 400 600 800 10001200
Fine-Tuning Iteration
Figure 9: Ablation over K for aesthetic reward fine- tuning.
Figure 10: Images generated with differ- ent LoRA start steps M E {50, 30, 10, 2}.
5.3 OTHER REWARD FUNCTIONS
Compressibility and Incompressibility. Inspired by Black et al. (2023), we also fine-tuned diffusion model to generate casily-compressible images. While the JPEG compression and decompression al- gorithms available in common libraries are not differentiable by default, they can be implemented in a differentiable man- ner using deep learning libraries like Py- Torch (Paszke et al., 2019) or JAX (Brad- bury et al., 2018). Given a prompt c, we pass the output of the diffusion model, X₂ = sample(0, c, x7) through differen- tiable compression and decompression al-
Incompress. Compress.
Figure 11: Top: Images generated by diffusion model
fine-tuned for JPEG compressibility, with reward r(xp) ||xo- - d(c(xa))ll where xa sample(O, c, xx). Bottom: Using the negation of the compressibility loss yiclds images that are difficult to compress.
8

---

Published as a conference paper at ICLR 2024
gorithms to obtain d(c(Xx)). and minimize the Euclidean distance between the original and recon- structed images. This encourages the diffusion model to produce simple images. The results using DRaFT to fine-tune for JPEG compressibility are shown in Figure 11 (Top): these images have simple, uniform-color hackgrounds and low-frequency foregrounds. In addition, negating the compressibility loss yields incompressible images, shown in Figure 11 (Bottom), that have complex, high-frequency foregrounds and backgrounds. Additional details are provided in Appendix B.3.
Object Removal: Farmer's Market People
Object Addition: Fruit Bowl + Strawberries
Before
Fine-Tuning
After
Fine-Tuning
Fine-tuning for object removal addition using the OWL-ViT object detector. Left: The prompt the diffusion model is farmer ma rake and the queries for OWI.-ViT are {a person, people] Refore fine-tuning, most the generated images contain people in the hackground; after finetuning, all images contain only vegetables. Right: Adding strawherries to a fruit bowl.
Figure 12:
Object Detection and Removal. Here, explore the use of a pre-trainne mre-triine object detection model to bias a diffusion model's generations to include or exclude a certain object class. We use OWL- ViT (Minderer al., 2022), an open-world localization model that takes arbitrary text queries and returns bounding boxes with scores for the corresponding objects the image. We pass images generated by the diffusion model through a pre-trained OWL-ViT model, together with a set of queries Q that we wish to exclude from the generated images (see Figure 22 in Appendix B.6 for details). As the reward, we use the sum of scores for the localized objects corresponding to all queries q E Q, as well as the areas of their bounding boxes. In Figure 12 (Left), we show the results of fine-tuning to minimize detection of people. Similarly, we can maximize the sum of scores for localized objects to encourage generations to include a certain class: in Figure 12 (Right), we use the prompt "a bowl of fruit" and queries Q = (strawberry).
Adversarial Examples. Our framework also provides an avenue to study the inductive biases of both diffusion models and pre-trained classifiers: we can fine-tune a diffu- sion model such that images generated based on prompt for a class y (e.g., "mouse") are classified as a different class y/ (e.g., "cat") by a ResNet-50 pretrained on Ima- geNet. As the fine-tune mne-tuning reward, we use the negative cross-entropy to the target class. From the qualitative sults shown in Figure 13, we observe that this classifier is texture-biased (Geirhos al., 2019), the images gener- ated by the fine-tuned model incorporate cat-like textures while keeping the animal shapes mostly unchanged.
Fine-Tuning Progress
CONCLUSION
Figure 13: Diffusion adversarial examples for prompts bear, dog, mouse with tar- get class cat.
We introduced efficient framework for fine-tuning dif- fusion models on differentiable rewards by leveraging reward gradients. Our first method, Direct Reward Fine-Tuning (DRaFT), backpropagates through the full sampling procedure, and achieves strong performance on a variety of reward functions. We then propose DRaFT-K and DRaFT-LV, variants which improve efficiency via truncated backpropa- gation through time. In addition, we draw connections between our approach and prior work such as ReFL (Xu et al., 2023), to provide a unifying perspective on the design space of gradient-based reward fine-tuning algorithms. We show that various methods can be obtained as special cases of more general algorithm, depending on the whether and where- stop curp_grrdieet operations are included. We hope that our work will inspire the development of improved techniques for reward fine-tuning; just as RLHF has become crucial for deploying large language models, we believe that reward tne-tuning may become key step for improving image generation models.

---

Published as a conference paper at ICLR 2024
ACKNOWLEDGEMENTS
We thank Daniel Watson, Jason Baldridge, Hartwig Adam, Robert Geirhos, and the anonymous reviewers for their thoughtful comments and suggestions. We thank Xiaosi Wu for help with the HPSv2 dataset, Jiazheng Xu for answering our questions about ReFL, and Kevin Black for answering our questions about DDPO and re-running their aesthetic reward experiments.
REFERENCES
Riad Akrour, Mare Schoenauer, and Michele Sebag. Preference- based policy learning. In Machine Learning and Knowledge Discovery in Databases: European Conference, pp. 12-27, 2011.
Amanda Askell, Yuntao Bai, Anna Chen, Dawn Drain, Deep Ganguli, Tom Henighan, Andy Jones, Nicholas Joseph, Ben Mann, Nova DasSarma, al. A general language assistant as laboratory for alignment. arXiv preprint
2021.
Yuntao Bai, Andy Jones, Kamal Ndousse, Amanda Askell, Anna Chen, Nova DasSarma, Dawn Drain, Stanislav Fort, Deep Ganguli, Tom Henighan, et al. Training helpful and harmless assistant with reinforcement learning from human feedback. arXiv preprint arXiv:2204. 05862, 2022a.
Yuntao Bai, Saurav Kadavath, Sandipan Kundu, Amanda Askell, Jackson Kernion, Andy Jones, Anna Chen, Anna Goldie, Azalia Mirhoseini, Cameron McKinnon, et al. Constitutional AI: Harmlessness from Al feedback. arXiv preprint arXiv:2212.08077 2022b.
Arpit Bansal, Hong-Min Chu, Avi Schwarzschild, Soumyadip Sengupta, Micah Goldblum, Jonas Geiping, and Tom Goldstein. Universal guidance for diffusion models. In Conference Computer Vision and Pattern Recognition, pp. 843 832, 2023.
Romain Beaumont, Ross Wightman, Phil Wang, Boris Dayma, Mitchell Wortsman, Blinkdl, Cristoph Schuhmann, Jenia Jitsev, Schmidt Ludwig, Mehdi Cherti, and Emad Mostaque. Large scale OpenCLIP: L/14, H/14 and G/14 trained on LAION-2B. laion.ai, 2022.
Kevin Black, Michael Janner, Yilun Du, Ilya Kostrikov, and Sergey Levine. Training diffusion models with reinforcement learning. arXiv preprint arXiv:2305. 13301, 2023.
James Bradbury, Roy Frostig, Peter Hawkins, Matthew James Johnson, Chris Leary, Dougal Maclaurin, George Necula, Adam Paszke, Jake VanderPlas, Skye Wanderman-Milne. and Qiao Zhang. JAX: composable transformations of Python+NumPy programs, 2018. URL
http:// / /ttp:///gtthh com/ coom//oole/////ooooooooooooo jax.
Tianqi Chen, Bing Xu, Chiyuan Zhang, and Carlos Guestrin. Training deep nets with sublinear memory cost. arXiv preprint 11Xiv:1604.06174, 2016.
Xi Chen, Xiao Wang, Soravit Changpinyo, AJ Piergiovanni, Piotr Padlewski, Daniel Salz, Sebastian Goodman, Adam Grycner, Basil Mustafa, Lucas Beyer, et al. PaLi: A jointly-scaled multilingual language-image model. In International Conference on Learning Representations, 2023.
Xinlei Chen, Hao Fang, Tsung-Y Yi Lin, Ramakrishna Vedantam, Saurabh Gupta, Piotr Dollár, and C Lawrence Zimick. Microsoft COCO captions: Data collection and evaluation server. arXiv 2015.
preprint a0X4v:1504.000
Paul F Christiano, Jan Leike, Tom Brown, Miljan Martic, Shane Legg, and Dario Amodei. Deep reinforcement learning from human preferences. Advances in Neural Information Processing Systems, 30, 2017.
Prafulla Dhariwal and Alexander Nichol. Diffusion models beat GANs image synthesis. Advances in Neural Information Processing Systems, 34:8780-8794, 2021.
Hanze Dong, Wei Xiong, Deepanshu Goyal, Rui Pan, Shizhe Diao, Jipeng Zhang, Kashun Shum, and Tong Zhang. RAFT: Reward ranked finetuning for generative foundation model alignment. arXiv preprint arXiv:2304.0677 304776777 2023.
10

---

Published as a conference paper at ICLR 2024
Ying Fan and Kangwook Lee. Optimizing DDPM Sampling with Shortcut Fine- Fine-Tuning. In Interna- tional Conference on Machine Learning (ICML), 2023.
Ying Fan, Olivia Watkins, Yuqing Du, Hao Liu, Moonkyung Ryu, Craig Boutilier, Pieter Abbeel, Mohammad Ghavamzadeh, Kangwook Lee, and Kimin Lee. DPOK: Reinforcement learning for fine-tuning text-to-image diffusion models. In Advances in Neural Information Processing Systems, 2023.
Robert Geirhos, Patricia Rubisch, Claudio Michaelis, Matthias Bethge, Felix A Wichmann, and Wieland Brendel. ImageNet-trainedd CNNs biased towards texture; increasing shape bias improves accuracy and robustness. In International Conference on Learning Representations, 2019.
Amelia Glaese, Nat McAleese, Maja Trębacz, John Aslanides, Vlad Firoiu, Timo Ewalds, Maribeth Rauh, Laura Weidinger, Martin Chadwick, Phoebe Thacker, et al. Improving aligmment of dialogue agents via targeted human judgements. arXiv preprint arXiv:2209. 14375, 2022.
Audrunas Gruslys. Rémi Munos, Ivo Danihelka, Mare Lanctot, and Alex Graves. Memory-efficien backpropagation through time, Advances in Neural Information Processing Systems, 29, 2016.
Jiatao Gu, Alex Trevithick, Kai-En Lin, Joshua M Susskind, Christian Theobalt, Lingjie Liu, and Ravi Ramamoorthi. NerfDiff: Single-image view synthesis with NeRF-guided distillation from 3d-aware diffusion. In International Conference on Machine Learning, pp. 1 1808-11824 2023.
Yaru Hao, Zewen Chi, Li Dong, and Furu Wei. Optimizing prompts for text-to-image generation.
arXiv preprint arXiv:2212.096111 2022.
Jonathan Ho and Tim Salimans. Classifier-free free diffusion guidance. NewrIPS Workshop on Deep
Generative Models and Downstream Applications, 2021.
Jonathan Ho, Ajay Jain, and Pieter Abbeel. Denoising diffusion probabilistic models. Advances in Neural Information Processing Systems, 33:6840-6855 2020.
Jonathan Ho, William Chan, Chitwan Saharia, Jay Whang. Ruiqi Gao, Alexey Gritsenko, Diederik Kingma, Ben Poole, Mohammad Norouzi, David J Fleet, et al. Imagen video: High definition video generation with diffusion models. arXiv preprint arXiv:2210.02303. 2022.
Edward J Hu, Yelong Shen, Phillip Wallis, Zeyuan Allen-Zhu, Yuanzhi Li, Shean Wang, Lu Wang, and Weizhu Chen. LoRA: Low-rank adaptation of large language models. In International Conference on Learning Representations, 2022.
Borja Ibarz, Jan Leike, Tobias Pohlen, Geoffrey Irving. Shane Legg, and Dario Amodei. Reward learning from human preferences and demonstrations Atari. Advances in Neural Information Processing Systems, 31, 2018.
Diederik Kingma, Tim Salimans, Ben Poole, and Jonathan Ho. Variational diffusion models, Advances in Neural Information Processing Systems, 14:21696-217001 2021.
Yuval Kirstain, Adam Polyak, Uriel Singer, Shahbuland Matiana, Joe Penna, and Omer Levy. Pick-a-pic: An open dataset of user preferences for text-to-image generation. arXiv preprint 0rXii:2305501569, 2023.
W Bradley Knox and Peter Stone. Interactively shaping agents via human reinforcement: The tamer framework. In Proceedings of the fifth international Conference on Knowledge capture, pp. 9-16, 2009.
Kimin Lee, Hao Liu, Moonkyung Ryu, Olivia Watkins, Yuqing Du, Craig Boutilier, Pieter Abbeel, Mohammad Ghavamzadeh, and Shixiang Shane Gu. Aligning text-to-image models using human feedback. arXiv preprint arXiv:2302.1211 12192, 2023.
Wei Li, Xue Xu, Xinyan Xiao, Jiachen Liu, Hu Yang, Guohao Li, Zhanpeng Wang, Zhifan Feng, Qiaoqiao She, Yajuan Lyu, et al. UPainting: Unified text-to-image diffusion generation with cross-modal guidance. arxiv preprint arXiv:2210. 16031, 2022.

---

Published as a conference paper at ICLR 2024
Timothy P Lillicrap. Jonathan J Hunt, Alexander Pritzel, Nicolas Heess, Tom Erez, Yuval Tassa, David Silver. and Daan Wierstra. Continuous control with deep reinforcement learning. In International Conference Learning Representations, 2016.
Haohe Liu, Zehua Chen, Yi Yuan, Xinhao Mei, Xubo Liu, Danilo Mandic, Wenwu Wang, and Mark D Plumbley. AudioLDM: Text-to-audio generation with latent diffusion models. In Proceedings of Machine Learning Research, 2023.
Nan Liu, Shuang Li, Yilun Du, Antonio Torralba, and Joshua B Tenenbaum. Compositional visual generation with composable diffusion models. In European Conference on Computer Vision, pp. 423 439, 2022.
Iyy Loshchilov and Frank Hutter. Decoupled weight decay regularization. In International Confer- ence on Learning Reprexentations, 2019.
Chenlin Meng, Robin Rombach, Ruiqi Gao, Diederik Kingma, Stefano Ermon, Jonathan Ho, and Tim Salimans. On distillation of guided diffusion models. In Conference on Computer Vision and Pattern Recognition, pp. 14297-14306, 2023.
Matthias Minderer, Alexey Gritsenko, Austin Stone, Maxim Neumann, Dirk Weissenborn, Alexey Dosovitskiy, Aravindh Mahendran, Anurag Arna,, Mostafa Dehghani, Zhuoran Shen, et al. Simple open-vocabulary object detection. In European Conference on Computer Vision, pp. 728-755, 2022.
Alex Nichol, Prafulla Dhariwal, Aditya Ramesh, Pranav Shyam, Pamela Mishkin, Bob McGrew, Ilya Sutskever, and Mark Chen. Glide: Towards photorealistic image generation and editing with text-guided diffusion models. arXiv preprint arXiv:21 / /2. 10741, 2021.
Long Ouyang, Jeffrey Wu, Xu Jiang, Diogo Almeida, Carroll Wainwright, Pamela Mishkin, Chong Zhang, Sandhini Agarwal, Katarina Slama, Alex Ray, al. Training language models to follow instructions with human feedback. Advances in Neural Information Processing Systems, 35: 27730 277444,7774, 2022.
Adam Paszke, Sam Gross, Francisco Massa, Adam Lerer, James Bradbury, Gregory Chanan, Trevor Killeen, Zeming Lin, Natalia Gimelshein, Luca Antiga, et al. Pytorch: An imperative style, perffrmmreee deep learning library. Advances in Neural Information Processing Systems, 32, 2019.
Ben Poole. Ajay Jain, Jonathan T Barron, and Ben Mildenhall. Dreamfusion: Text-to-3d using 2d diffusion. International Conference on Learning Representations, 2023.
Alec Radford, Jong Wook Kim, Chris Hallacy, Aditya Ramesh, Gabriel Goh, Sandhini Agarwal, Girish Sastry, Amanda Askell, Pamela Mishkin, Jack Clark, et al. Learning transferable visual models from natural language supervision. International Conference on Machine Learning, pp. 8748 876888773,222 2021.
Aditya Ramesh, Mikhail Pavlov, Gabriel Goh, Scott Gray, Chelsea Voss, Alec Radford, Mark Chen, and Ilya Sutskever. Zero-shot text-to-image generation. International Conference on Machine Learning, pp. 8821-8831, 2021.
Aditya Ramesh, Prafulla Dhariwal, Alex Nichol, Casey Chu, and Mark Chen. Hierarchical text- conditional image generation with CLIP latents, arXiv preprint 2201:22044. 2022.
Robin Rombach, Andreas Blattmann, Dominik Lorenz, Patrick Esser, and Björn Ommer. High- resolution image synthesis with latent diffusion models. In Proceedings of the IEEE/CVF Confer- ence on Computer Vision and Pattern Recognition, pp. 10684-10695, 2022.
Olaf Ronneberger, Philipp Fischer, and Thomas Brox. U-Net: Convolutional networks for biomed- ical image segmentation. In Medical Image Computing and Computer-Assiste Intervention International Conference, pp. 234-241, 2015.
12

---

Published as a conference paper at ICLR 2024
Chitwan Saharia, William Chan, Saurabh Saxena, Lala Li, Jay Whang, Emily Denton, Seyed Kamyar Seyed Ghasemipour, Burcu Karagol Ayan, S Sara Mahdavi, Rapha Gontijo Lopes, et al. Photorealistic text-to-image diffusion models with deep language understanding. Advances in Neural Information Processing Systems, 2022.
Christoph Schuhmann and Romain Beaumont. LAION-aestheii laion.ai, 2022.
David Silver, Guy Lever, Nicolas Heess, Thomas Degris, Daan Wierstra, and Martin Riedmiller. Deterministic policy gradient algorithms. In International Conference on Machine Learning, pp. 387-395, 2014.
Uriel Singer, Adam Polyak, Thomas Hayes, Xi Yin, Jie An, Songyang Zhang, Qiyuan Hu, Harry Yang, Oron Ashual, Oran Gafni, et al. Make-a-video: Text-to-video generation without text-video data. In International Conference Learning Representations, 2023.
Jaseha Sohl-Dickstein, Eric Weiss, Niru Maheswaranathan, and Surya Ganguli. Deep unsupervised learning using nonequilibrium thermodynamies. In International Conference Machine Learning. pp. 2256-2265, 2015.
Jiaming Song. Chenlin Meng, and Stefano Ermon. Denoising diffusion implicit models. In Interna- tional Conference on Learning Representations, 2021a.
Yang Song and Stefano Ermon. Generative modeling by estimating gradients of the data distribution. Advances in Neural Information Processing Systems, 32, 2019.
Yang Song, Jascha Sohl- Sohl-Dickstein, Diederik Kingma, Abhishek Kumar, Stefano Ermon, and Ben Poole. Score-based generative modeling through stochastic differential equations. In International Conference on Learning Representations, 2021b.
Nisan Stiennon, Long Ouyang, Jeffrey Wu, Daniel Ziegler, Ryan Lowe, Chelsea Voss, Alec Radford, Dario Amodei, and Paul Christiano. Learning to summarize with human feedback. Advances in Neural Information Processing Systems, 33:3008-300 10088,011222000 2020.
Bram Wallace, Akash Gokul, Stefano Ermon, and Nikhil Naik. End-to-end diffusion latent optimiza- tion improves classifier guidance. arXiv preprint arXiv:2303.1370: 2023.
Zhendong Wang, Jonathan Hunt, and Mingyuan Zhou. Diffusion policies as an expressive policy class for offline reinforcement learning. In International Conference on Learning Representations, 2023a.
Zijie J Wang, Evan Montoya, David Munechika, Haoyang Yang, Benjamin Hoover, and Duen Horng Chau. Diffusiondb: A large-scale prompt gallery dataset for text-to-image generative models. In Association for Computational Linguistics, 2023b.
Daniel Watson, William Chan, Jonathan Ho, and Mohammad Norouzi. Learning fast samplers for diffusion models by differentiating through sample quality. In International Conference Learning Representaatinns, 2022.
Ronald J Williams. Simple statistical gradient-following algorithms for connectionist reinforcement learning. Machine Learning, 8:229-256, 1992.
Mitchell Wortsman, Gabriel Ilharco, Jong Wook Kim, Mike Li, Simon Kornblith, Rebecca Roelofs, Raphael Gontijo Lopes, Hannaneh Hajishirzi, Ali Farhadi, Hongseok Namkoong, et al. Robust fine-tuning of zero-shot models. In Proceedings of the IEEE/CVF Conference Computer Vision and Pattern Recognition, pp. 7959-7971, 2022.
Jeff Wu, Long Ouyang, Daniel M Ziegler, Nisan Stiennon, Ryan Lowe, Jan Leike, and Paul Christiano. Recursively summarizing books with human feedback. arXiv preprint wxXiv:2109.10860 2021.
Xiaoshi Wu, Yiming Hao, Keqiang Sun, Yixiong Chen, Feng Zhu, Rui Zhao, and Hongsheng Li. Human preference score v2: A solid benchmark for evaluating human preferences of text-to-image synthesis. arXiv preprint (XXiv23066.09341 2023a.
13

---

Published as a conference paper at ICLR 2024
Xiaoshi Wu, Keqiang Sun, Feng Zhu, Rui Zhao, and Hongsheng Li. Better aligning text-to-image models with human preference. arXiv preprint arXiv:2303 14420, 2023b.
Jiazheng Xu, Xiao Liu, Yuchen Wu, Yuxuan Tong, Qinkai Li, Ming Ding, Jie Tang, and Yuxiao Dong. Imagereward: Learning and evaluating human preferences for text-to-image generation. arXiv preprint arXiv:2304.05977, 2023.
Xiaohui Zeng. Arash Vahdat, Francis Williams, Zan Gojeic, Or Litany, Sanja Fidler, and Karsten Kreis. LION: Latent point diffusion models for shape generation. In Advances in Neural Information Processing Systems (NeurIPS), 2022.
Richard Zhang, Phillip Isola, Alexei A Efros, Eli Shechtman, and Oliver Wang. The unreasonable effectiveness of deep features as perceptual metric. In Conference on Computer Vision and Pattern Recognition, 2018
Daniel M Ziegler. Nisan Stiennon, Jeffree Wu, Tom B Brown, Alec Radford. Dario Amodei, Paul Christiano, and Geoffrey Irving. Fine-tuning language models from human preferences. arXiv preprint orXiv: (XX::9999.08593, 2019.
14

---

Published as a conference paper at ICLR 2024
APPENDIX
This appendix is structured follows:
In Appendix A, provide more details of our experimental setup, including hyperparame- ters and baselines.
In Appendix B, we provide additional results and analysis.
In Appendix C, we discuss other methods we explored that did not achieve as strong results as DRaFT-LV: single-reward version of DRaFT-LV and applying Deterministic Policy Gradient.
In Appendix D, we provide an extended discussion of related work.
In Appendix E, provide uncurated samples from models fine-tuned for various re- ward functions, including HPSv2, PickScore, and a combined reward weighting HPSv2, PickScore, and Aesthetic score.
A EXPERIMENTAL SETUP
A.1 ADDITIONAL EXPERIMENTAL DETAILS AND HYPERPARAMETERS
Here we expand on training details and provide hyperparameters. We used the same hyperparameters for ReFL and our DRaFT variants.
Optimization. We use the AdamW optimizer (Loshchilov & Hutter, 2019) with 81 = 0.9, 82 0.999, and a weight decay of 0. As we use LoRA, the weight decay regularizes fine-tuning by pushing parameters towards the pre-trained weights. For the longer training runs (10k steps human preference reward functions), we use a square root learning rate decay, scaling the learning rate by min (10 step 0.5 1). Weight decay and learning rate decay slightly improve results, but not critical to the method. During training, we convert the pre-trained Stable Diffusion parameters to 6 reduce the memory footprint, but float32 for the LoRA parameters being trained.
LoRA. We apply LoRA to the feedforward layers as well as the cross-attention layers in the UNet, which found to produce slightly better results. We apply LoRA only to the UNet parameters, not to the CLIP text encoder or VAE decoder mapping latents to images, as these did not improve results in initial experiments.
Sampling. We use 50 steps of DDIM sampling (where no noise is added during sampling beyond the initial sampled noise). We found the results using ancestral/DDPM sampling to be similar. We employ classifier-free guidance with a guidance weight of 7.5 both at train-time and test-time.
We apply DRaFT in two settings: large-scale (human preference reward func- tions using the HPSv2 or PickScore prompt sets) and small-scale (the other experiments). Hyper- parameters are listed in Table Small-scale training runs take around 1.5 hours 4 TPUv4s. Large-scale training runs take around 8 hours on 16 TPUv4s.
Hyperparameters.
Hyperparameter
Small-Scale Experiments
Large-scale Experiments
Learning rate
4c-4
2e-4
Batch size
4
16
Train steps
2k
10k
LoRA inner dimension
8
32
Weight decay
0.1
0.1
DDIM steps
50
50
Guidance weight
7.5
7.5
DRaFT-LV inner loops n
2
2
ReFL max timestop m
20
20
Table 1: Training hyperparameters.
15

---

Published as a conference paper at ICLR 2024
A.2 REWARD FUNCTION DETAILS
The LAION aesthetic predictor is trained to rate images on scale of through 10. The predictor consists of a feedforward neural network on top CLIP (Radford et al., 2021) image encoder pre-trained on variety of human-labeled sources.
Human Preference Score v2 (HPSv2; Wu et al. 2023a) is trained on prompts from DiffusionDB (Wang et al., 2023b) and COCO Captions (Chen et al., 2015). Images are generated from each using a wide range of generative models. Human annotators then rate which of two images is preferred for prompt. The reward model is OpenCLIP-H (Beaumont al., 2022) fine-tuned the preference judgements. Unlike the aesthetic reward, HPSv2 takes into account the prompt as well as the image.
PickScore (Kinstain al., 2023) also OpenCLIP-II CI-H fine-tuned on preference data. However, the data is collected a more organic way through a web app. where users can generate and then rate pairs of images generated from different diffusion models with different sampler hyperparameters.
A.3 BASELINES
Denoising Diffusion Policy Optimization (DDPO; Black et al. 2023) essentially applies the RE- INFORCE policy gradient algorithm (Williams, 1992) diffusion model generation. The method trains the model to increase the likelihoods of actions (i.e. sampling steps) that produce high-reward samples. DDPO employs additional tricks such importance weight clipping, reward normalization, and classifier guidance- aware training to improve results. We show results from DDPO-IS. which extends DDPO to use an importance sampling estimator for learning on examples generated from stale policy, enabling multiple optimization updates per reward query. Empirically, DDPO was found outperform previous supervised approaches like reward weighted regression (Lee et al., 2023). Rather than using the results in Figure 4 of the original paper, obtained results from direct correspondence with the authors, as their original aesthetic reward implementation had bug." 3
Prompt Engineering. Users often improve the aesthetic quality of generated images through prompt engineering. We perform semi-automated prompt search with access to the reward func- tion, trying out various prompts and selecting the one with the best aesthetic score. The best- scoring prompt found A stunning beautiful oil painting of (:), cinematic lighting, golden hour light.
Re-ranking (Best of 16). This simple baseline generates 16 images for each caption with the pre-trained Stable Diffusion model and selects the one with the highest reward.
Direct Optimization of Diffusion Latents (DOODL). DOODL. (Wallace et al., 2023) backprop- agates through diffusion sampling to update the initial noise XT so that the resulting generation produces high reward. Rather than using an invertible diffusion algorithm to reduce memory costs as in Wallace et al. (2023), we simply use gradient checkpointing as with DRaFT. We optimize x7 with Adam (which worked slightly better for us than momentum only) over 20 steps, which makes generation approximately 60x slower than standard sampling. Following Wallace al. (2023), we renormalize the latent every step after the Adam update.
B ADDITIONAL EXPERIMENTAL RESULTS
B. OVER-GENERALIZATION
Here we show examples of overgeneralization, where fine-tuning on preferences trains the model to generate detailed images, even when the prompt asks for simple drawing.
Pop ort pointing of Albert Finstein.
Minimalkr drawing of on engle
Stick fiure drawing of person playing soccer.
Stable Diffusion 1.4
DRaFT
Stable Difkusion 1.4
DRaFT
Stable Drffusin 1.4
DRaFT
See hreppe //gi hub, oon /depoooe///oeeeeeeeeeeee http:///ppppppppppooeeeeeo pytorch//yoooo hwwooh////eaaee 1aanes/333 sceecorment -13
16

---

Published as a conference paper at ICLR 2024
B.2 FULL QUANTITATIVE RESULTS
In Table 2, provide quantitative results comparing DRaFT to several baselines on the Human Preference Score v2 benchmark from Wu et al. (2023a).
Model
Animation
Concept Art
Painting
Photo
Averaged
GLIDE 1.4
0.2334
0.2308
0.2327
0.2450
0.2355
VQGAN + CLIP
0.2644
0.2653
0.2647
0.2612
0.2639
DALL-E2
0.2734
0.2654
0.2668
0.2724
0.2695
SD 2.0
0.2748
0.2689
0.2686
0.2746
0.2717
DeepFloyd-XI.
0.2764
0.2683
0.2686
0.2775
0.2727
SDXL Base 0,9
0.2842
0.2763
0.2760
0.2729
0.2773
Dreamlike Photoreal 2.0
0.2824
0.2760
0,2759
0,2799
0,2786
Stable Diftusion (SD 1.4)
0.2726
0.2661
0,2666
0.2727
0,2695
ReFL
0.3446
0.3442
0.3447
0.3374
0.3427
DRaFT-50
0.3078
0.3021
0.3019
0.3013
0.3033
DRaFT-30
0.3148
0.3112
0.3109
0.3096
0.3116
DRaFT-10
0.3456
0.3447
0.3452
0.3369
0.3431
DRaFT-5
0.3521
0.3520
0.3526
0.3431
0.3500
DRaFT-1
0.3494
0.3488
0.3485
0.3400
0.3467
DRaFT-1, PickScore
0.2907
0.2848
0.2861
0.2882
0.2875
DRaFT-1, Pick-a-Pic
0.3399
0.3358
0.3385
0.3188
0.3332
DRaFT-LV
0.3551
0.3552
0.3560
0.3480
0.3536
DRaFT-LV, PickScore
0.2880
0.2833
0,2846
0.2923
0,2870
DRaFT-LV, Pick-a-Pic
0.3409
0.3371
0.3408
0.3210
0.3349
Table 2: Following Wu et al. (2023a), we used the HPDv2 training set to fine-tune our models, and we evaluated performance on four benehmark datasets: Animation, Concept Art, Paintings, and Photos. We report the average achieved for each benchmark, well the aggregated performance across all datasets. The results above the separator are from Wu (2023a); the results below were obtained from our implementations and experiments.
B.3 COMPRESSIBILITY AND INCOMPRESSIBILITY DETAILS
Figure 14 illustrates the setup we used to fine-tune for JPEG compressibility and incompressibility. Given prompt
take the image generated by the diffusion model, X sample(O, xT) and pass it through JPEG compression and decompression functions, denoted by e eadd d, respectively. As the reward, use the negative Euclidean distance between the original sample X6 and its reconstruction r(xp) - ~ d(c(x,)) While the JPEG implementations found in common libraries are not directly differentiable, the JPEG algorithm can be re-implemented in a differentiable way using autodiff frameworks; we re- ee-imllemented JPEG compression and decompression in JAX (Bradbury et al., 2018). Figures and show additional samples generated by diffusion models fine-tuned for compressibility and incompressibility. respectively, and Figure 17 shows the results of overoptimization for incompressibility. In our experiments, we used a fixed compression ratio of 4x.
Differentiable JPEG Compression & Decompression
Diffusion
X
d(c(Xn))
Prompt
'a cal"
sample
C
r(xo) X - d(c(xo)))1
Figure 14: Fine-tuning for JPEG compressibility, using differentiable JPEG compression and dccompression algorithms.
17

---

Published as a conference paper at ICLR 2024
Crab
Lion
Frog
Kangaroo
Figure 15: Images generated by a diffusion model fine-tuned for JPEG compressibility.
Crab
Lion
Gecko
Kangaroo
Figure 16: Images generated diffusion model fine-tuned using the negation of the JPEG compressibility ward, which yields images are difficult to compress. We observe high frequency foreground and background information.
Ocelot
Snake
Gecko
Moose
Crab
Lion
Octopus
Kangaroo
Figure 17: Over-optimization for JPEG incompressibility can lead to images with strong high-frequency texture and a loss of semantic information. Interestingly, here the octopus is generated with more than eight arms,
B.4 ADVERSARIAL EXAMPLE DETAILS
The setup for our diffusion adversarial example experiments is illustrated Figure 18. We used ResNet-50 model pre-trained on ImageNet-I1 lk to classify images generated by Stable Diffusson;; as the reward for fine-tuning, we used the negative cross-entropy to a fixed target class.
(Fixed) Pre- Treiera ImageNet Classifier
Diffusion
X0
Logits
Prompt
Cross-Entropy Target: "cat"
"mouse"
sample
Figure 18: Generating "diffusion adversarial examples" that are conditioned text prompt (e.g., "mouse") but must classified pre-trained ImageNet classifier different class (e.g., "cat").
18

---

Published as a conference paper at ICLR 2024
B.5 LORA SCALING AND INTERPOLATION
Here, we provide additional results for scaling and interpolating LoRA parameters. Figures 19 and 20 show the effect of scaling LoRA parameters to control the strength reward adaptation for the Human Preference Score v2 and PickScore rewards, respectively, and Figure 21 shows additional interpolations using linear combinations of LoRA weights trained separately for each of these rewards.
a 0.0
==7.7
a= 0.8
a= 0.9
a=9.95
a= 1.0
A modem hotel bathroom double sinks and deep bath
portralt Calch, character from the Critical Role series.
depiited titied "the tinal circle seradisee
couch in sitting ream with coffee table with open taptop
Figure 19: Scaling LoRA parameters (here adapted for Human Preference Score v2 (Wu et al., 2023a)) yiclds semantic interpolations between the original Stable Diffusion model and the fine-tuned model.
α 0.0
a d= 0.7
x= 0.8
a = 0.9
a= 0.95
Q= = 1.0
A modem hotel bathroem
double sinks and deep bath
A portrait of Caleb, character from the Critical Role
Image depicted is titled "the final circle of paradise."
A man sits on couch in sitting reom with coffee table with open laptop it.
Figure 20: Scaling LoRA parameters (here adapted for PickScore (Kirstain al., 2023)) yields semantic interpolations between the original Stable Diffusion model and the fine-tuned model.
19

---

Published as a conference paper at ICLR 2024
8=100
p 1=10
Human Preference Score v2
Human Preference Score v2
g
P 003 P F-072
B =
p=0.5
B=0.0
==0.0
0.75
0.0
0.75
1.0
PickScore
PickScore
Figure 21: Additional results using linear combinations of LoRA parameters adapted for different rewards. each subplot, we show images generated using LoRA parameters affiaSoore + LOKA for coefficients a, B E {0.0, 0.5, 0.75, 1.0). We found that interpolating between LoRA weights can yicld smooth transitions between different styles.
B.6 OBJECT DETECTION
Diffusion
X
Object Scores Bounding Boxes Detector
Prompt
Objective
"farmer market"
sample
OWL VIT
Sum of Scores
Bouncling Box Areas)
Queries
"person"
Figure 22: Fine-tuning for object detection using a pre-trained OWL-ViT model (Minderer et al., 2022).
Our setup for object detection is illustrated in Figure 22. We feed the generated images into a pre-trained Open- World Localization Vision Transformer (OWL-ViT) (Min- derer et al., 2022) model, along with a list of text queries that wish to localize in the image. OWL-ViT outputs bounding boxes and scores for the localized objects; we experimented with reward functions based the of scores, as well as based on the areas of the bounding boxes, and found that both worked well. Figure 23 shows the fine-tuning progress for the diffusion prompt "a bowl of fruit" with OWL-ViT query "strawberries."
Fine- Fine-Tuning Progress
B.7 UNDERSTANDING THE IMPACT OF K
We investigated the impact K on the behavior mod- els fine-tuned with DRaFT-K via ablations designed to answer the following questions: 1) Does adaptation occur only in the last K steps (e.g., does the initial segment of the sampling chain behave similarly to the original pre-trate pre-trained model, with sudden jump occurring at the end)? and 2) Is it necessary apply the LoRA parameters throughout the full sampling chain? What is the impact of applying the LoRA parameters to only the initial or final portions the trajectory?
Figure 23:
Maximizing the object detector score for the query "strawherry" yields fruit bowls that contain progressively more straw- berries the course of fine-tuning.
20

---

Published as a conference paper at ICLR 2024
LoRA Start Step
LoRA End Step
t=
t=
t=3 t=2 1=1
t=
t=
t=4
t=
t=2
t= 0
Pre-Trained Parameters Only
LoRA-Adapted Parameters
LoRA-Adapted Parameters
Pre-Trained Parameters Only
Figure 24:
Illustration of sampling with different LoRA start steps and end steps.
To answer these questions, we applied the LoRA-adapted dif- fusion parameters for the last steps of the sampling chain, while in the first T - M steps used the pre-trained Stable Diffusion parameters without LoRA adaptation (see Figure 24). Figure 26 compares samples generated with different LoRA
90
60
Angle
start iterations M; interestingly, although the LoRA param- fine-tuned using truncated backpropagation through only the last steps sampling, adaptation does not happen only in the last K steps; rather, the LoRA parameters need to be applied for at least 10-20 steps to yield substantial changes in the generated images. Similarly, we also investigated the opposite scenario, where the LoRA-adapted parameters are only applied in the first M steps of the sampling chain, after which LoRA is "turned off" and we use only the original pre- trained parameters for the remaining T .M steps. The generated images for range of end LoRA steps M {2, 5, 10, 20, 30, 40, 50} are shown in Figure 27. These results further demonstrate the importance of applying LoRA parameters in the early part the sampling chain.
30
10
20
30
40
50
K
Figure 25: Angles between
DRaFT-1 gradient and DRaFT-K gra- dients for K E (1....,0)]
In Figure 25, show the angle between the DRaFT-1 gradient and DRaFT-K gradients for various K: the gradients become nearly orthogonal for K 30.
Generated Images
Start: 2
30
40
50
Figure 26: Images generated with different LoRA start steps. Here, the first T M steps of the diffusion sampling chain use pre-trained diffusion model parameters, while the last M steps use LoRA-adapted parameters. The LoRA start step M increases from top to bottom, M E (2, 5, 10, 20, 30, 40, 50). We observe that, although the LoRA parameters are trained via truncated backpropagation through the last few steps of sampling, they affect the entire sampling chain the images improve qualitatively when the LoRA-adapted parameters are used for many steps (c.g., g..... M 10).
21

---

Published as a conference paper at ICLR 2024
Generated Images
End: 2
5
10
20
50
Figure 27: Images generated with different LoRÅ end steps. Here, the first M steps of the diffusion sampling chain use the LoRA-adapted diffusion parameters, while the last T steps use the un-adapted pre- trained model parameters. The LoRA end step M increases from top to bottom, M E (2, 5, 10, 20, 30, 40, 50}. Interestingly, we observe that it is beneficial to apply the LoRA parameters carly in sampling.
Gradient Clipping. We used gradient clipping throughout our experiments. In Figure 28, we show ablation over the gradient clipping norm hyperparameter, which we denote We compared the reward values achieved over the course of fine-tuning for PickScore on the HPD-v2 prompt dataset, with gradient clipping norms {0.001, 0.01, 0.1, 1.0, 10.0. 100.0, 1000.0}. We found that, when using DRaFT-50, smaller gradient clipping norms (c 0.001) improved optimization substantially, while large clipping norms (c 1000) impeded training. This further supports the observation that backpropagating through long diffusion sampling chains can lead to exploding gradients. We performed similar ablation for DRaFT-1, and found that the fine-tuning performance was nearly identical for all gradient clipping coefficients (c 0.001 to 1000.0).
Gradient Clipping Ablation
K=
0.25
K=1
PickScore
0.24
c=0.001
c=0.01
0.23
c=0.1
0.22
c=1.0
c=10.0
0.21
c=100.0
1000 2000 3000 4000 5000
c=1000.0
Fine-Tuning Iteration
Figure 28: Ablation over the gradient clipping norm using DRaFT-K. K, fine-tuning to maximize PickScore on the HPD-v2 prompt datasct. DRaFT-50 experiments shown in red, and DRaFT-1 experiments shown in green. both cases, darker colors denote smaller gradient clipping norms.
22

---

Published as a conference paper at ICLR 2024
B.8 "OVER-OPTIMIZ OPTIMIZATION" AND REWARD HACKING
Improving Reoss- Generalization. DRaFT can cause models to overfit to the reward func- tion, leading high-reward but subjectively lower-quality images. Here, explore regularization methods to reduce reward overfitting.
As an approximate quantitative measure for over-optimization, we trained models on one reward function (HPSv2) and evaluated their generalization to another reward (PickScore). We considered three strategies to mitigate reward overfitting:
LoRA Scaling: multiplying the LoRA weights by constant < (see Section 5.2), which interpolates between the pre-trained model and fine-tune munet model, similarly to Wortsman et al. (2022).
Early stopping: evaluating various checkpoints across the training run instead of only the last one; early ones will achieve lower train reward but hopefully generalize better.
similarly to Fan et al. (2023), we add a loss term to the model that penalizes the KL divergence between the pre-trained and fine-tuned model distributions. This amounts to a squared error term between the pre-trained and tine-tuned predicted c. We trained several separate models, each with different weight on the KI. loss, which is disadvantage over the previous methods that can be applied single training run.
KL Regularization:
All models used DRaFT-LV with the large-scale hyperparameters (see Table 1). The results shown in Figure 29. Both early stopping and KL regularization are commonly used to reduce reward overfitting large language model preference tuning, but we found LoRA scaling to be more effective than the other approaches.
Generalization of HPSv2 DRaFT Models to PickScore
LoRA Scaling
KL Regularization
0.222
Early Stopping
0.220
PickScore
0.218
0.216
0.214
0.212
0.210
0.27
0.28
0.29
0.30
0.31
0.32
0.33
0.34
0.35
HPSv2
Figure 29: Generalization from HPSv2 PickScore for various regularization methods used prevent reward overfitting.
Attempts to Increase Diversity. A common result of reward hacking is collapse to single, high-reward image. Here, we describe two of our attempts to address this lack of diversity. First, we tried adding dropout to the reward function (in this case, the aesthetic classifier); however, we found that even large dropout rates such as 0.95 led to diversity collapse, as shown in Figure (Left). Next, we tried adding term to the reward that measures the dissimilarity between images generated in the same minibatch- this encourages the model to generate different images for different prompts and noise samples. Ideally, would take the mean dissimilarity over all pairs of examples in minibatch, yielding (z) combinations where B is the minibatch size. However, for computational tractability, we used a simpler approach, where we formed pairs by reversing the elements minibatch and computing elementwise dissimilarities, giving B/2 pairs. We tried two measures of dissimilarity: 1) the Euclidean distance, and 2) the Learned Perceptual Image Patch Similarity (LPIPS) (Zhang al., 2018). Neither satisfactory increase diversity: in Figure 30 (Right),
23

---

(1²) Published as a conference paper at ICLR 2024
show images generated using large weight on the LPIPS diversity term, which increased inner-batch diversity at the expense of the aesthetic score.
Original Image
Reward 6
Reward 9.5
Original Image
Iteration 160
lleration 440
Figure 30: Reward hacking still occurs when we use large dropout rate in the Aesthetic classifier (Left).
Incorporating reward term encourage diversity can lead to overly stylized images (Right).
B.9 ROTATIONAL ANTI- ONTI-CORRELATION REWARD
We also explored fine-tuning for symmetry anti-symmetry properties. Here, we optimize for rotational mnti-correlatin. which encourages the diffusion model to generate images that are dissimilar to their rotations at (90, 180, 270) de- grees. Given image and rotation operator Rot(x, 90%), |x
we formulate the objective
Rot(x, || 180%)| x Rot(x, 270
The results are shown in Figure 31: this objective leads to in- teresting Black-and-whire stylized images.
Figure 31: Rotational anti-correlation
B.10 CLIP REWARD
We briefly explored using r(Xo, c) LLIP-Similarity(x0 e) as reward improve image-text alignment. We found that optimization was succesful in that CLIP scores improved, but that image quality degraded after many steps of training (see Figure 32).
038
step
Step 200
500
1000
1300
2000
2000
3000
1200
1500
200p 3000
Tainiig Step
Figure 32: Qualitative examples (left) and training curve (right) for fine-tuning on CLIP reward using DRaFT for the prompt "a raccoon washing dishes".
Both HPSv2 and ImageReward are fine-tuned CLIP models, and for HPSv2 the annotators were specifically instructed to consider alignment the prompt in their preference judgements. Therefore,
24

---

Published as a conference paper at ICLR 2024
they already capture some aspects of image alignment, and qualitatively did observe alignment to increase in some cases when using these rewards (e.g. in the "a raccoon washing dishes" example in think improving text alignment using powerful image captioning model
Figure 1). However, such as PaL. (Chen et al., 2023) as the reward would be an interesting future direction.
B.11 FINE-TUNING FOR SAFETY
The datasets on which large diffusion models are trained often contain NSFW content, which poses challenges for the deployment of safe models. Safety measures be implemented at various stages of the text-to-image pipeline: 1) at the text prompt level (e.g., refusing NSFW words); 2) during the generative process (e.g., encouraging the model to output safe images); and 3) post-hoc elimination of NSFW images that have been generated. These approaches are complementary, and in practice we imagine that all three would be used concert. Here, focus on stage (2), by fine-tuning diffusion models using feedback from pre- treitrained NSFW classifier. This approach is particularly useful for ambiguous prompts that may lead either SFW or NSFW generations; for example, the prompt "swimsuit" can refer to images of people wearing swimsuits, or to just the article of clothing itself (the latter being more safe-for-work). We found that, before fine-tuning, the model mostly generated images of people wearing swimsuits, while after fine-tuning, the model instead generated images of lay-flat swimsuits.
B.12 LEARNING SAMPLER HYPERPARAMETERS
As DRaFT (without truncated backprop through time) com- putes gradients through the denoising process end-to-end, we can use DRaFT to optimize sampler hyperparameters as well as model weights.
Learning sampler hyperparameters is similar in spirit to Wat- son et al. (2022), except we obtain gradients from reward model rather than using kernel inception distance. We explored learning two inputs to the sampler- the guidance weights and negative prompt
pooedddinnsalthhuuss it would be possible to extend this method to other hyperparameters such as the time schedule. In particular, investigated:
Figure 33: Guidance schedule learned by DRaFT
Guidance weights: We learn separate guidance weight w(t) for each step of DDIM sampling. The learned schedule can be applied to samplers with different number of steps through linearly interpolating the schedule to stretch compress it. We use 50x larger learning rate for training guidance than the LoRA parameters because guidance weights have large magnitude. An example learned guidance schedule is shown in Figure 33.
Negative prompt: We learn prempt-dependent text embeddings passed into the uncondi- tional UNet used for classifier free guidance. In particular, we parameterize the embedding MLP(Multt-HHos Maalti-Heaeed-Saal Self-Attention(e)) where is the text embeddings produced by the diffusion model's 's text encoder.
However, in practice, we found that this did not improve results much at large scale.
C METHOD EXTENSIONS
Here we briefly discuss two gradient-based reward fine-tuning methods we explored, but which we found did not achieve strong results compared to DRaFT-1 and DRaFT-LVV.
C. REWARD DRAFT-LV
A downside of DRaFT-LV is that requires computing the reward function gradient an additional n times. While this is relatively little overhead for the reward functions we used compared to the cost of image sampling, larger reward models could make this costly. We therefore experimented
25

---

Published as a conference paper at ICLR 2024
0.34
NFSV2 Reward
0.32
DRaFT-1
0.28
DRaFT
DPG
2000
8000
10000
Training Stop
Figure 34: Training efficiency of reward fine-tuning methods the HPSv2 reward.
with version of DRaFT-LV that only computes the reward gradient with respect to the input pixels Vxr(Xo, c) once. Then it updates the gradient in the inner loop as g g + Vxr(xo, VoXo. Unfortunately, we found this method to be unstable and ultimately not learn effectively, possibly because it relics on the assumption that Vxr(xo, c) = Vxr(Ko, c), which may not be true in practice.
C.2 DETERMINISTIC POLICY GRADIENT
Previous approaches applying RL reward learning do not make use of sampling gradients. Here we discuss how Deterministic Policy Gradient (DPG; Silver et al. 2014; Lillicrap et al. 2016) offers a way of employing reward gradients within the RL framework.
Similarly to Black et al. (2023), we can view DDIM sampling as applying a deterministic policy to a deterministic Markov decision process:
A state s, consists of the current latent, timestep, and prompt (x1, c).
The initial state Sp draws X (0,, I), Pc. and sets = T.
The policy is the learned denoiser: a, (5( = c c, t)
The transition function performs DDIM sampling step:
f (s,, az) = - (x, o,a,) + 0 a,, f 1,
The reward R(s,, ar) is rxxo. c) if t and 0 if otherwise.
DPG trains critic (st a,) and learns 0 with the gradient update VaQa(S,, a VopoO() over sampled trajectories. The critic is trained to minimize the squared error between its prediction and the final return (in our case r(xo, c)).
Many of our rewards make use of neural networks with pre-trained parameters Ç. which we denote by writing rę. We suggest applying LoRA & parameterize the critic; we denote the LoRA-adapted parameters as adapt(E. Φ). We then apply the critic by (1) executing the action a, on st, (2) 1-step denoising the result to get predicted clean image, and (3) applying the adapted reward model TadaptiE d) to the result. The reason for step (2) is to make the training of & more efficient: we believe easier adapt the reward model parameters to produce good expected return estimates for one-step-denoised inputs than it is for noisy inputs. Formally, we use the critic:
QΦ (s,, a.) T Talapt(g #) ((f(s, a,) - of at), c, 1))//a,c) c)
(3)
When computing gradients through Q, we do not backpropagate through step (2) into 0, prevent it from interfering with the policy training.
Results.
The training efficiency of DPG compared with other methods is shown in Figure 34 (using the same experimental settings as in Figure 4). DPG outperforms vanilla DRaFT, but not our more- efficient variants. One challenge is that Q produces poor return estimates for large timesteps, which
26

---

Published as a conference paper at ICLR 2024
could perhaps be alleviated with ReFL-style version that skips or rarely samples high timesteps for training the policy. There are many variants of DPG to explore, so we think that improving the performance of DPG for reward fine-tuning could be an interesting direction for future research; DPG is appealing because like vanilla DRaFT (but unlike ReFL and our DRaFT variants), it optimizes the full sampling process in unbiased way.
D EXTENDED RELATED WORK
Diffusion Models. Denoising diffusion probabilistic models (DDPMs; Sohl-Dickstein al. 2015; Song & Ermon 2019; Song et al. 2021b; Ho et al. 2020) are a class of generative models that have become the de-facto standard for most continuous data modalities, including images (Ramesh et al., 2021), videos (Ho et al., 2022; Singer et al., 2023), audio (Liu et al., 2023), and 3D models (Zeng et al., 2022; Poole et al., 2023; Gu et al., 2023). Text-to-image diffusion models, which generate images conditioned as GLIDE (Nichol et al., 2021), 1), DALLE-2 (Ramesh et al., 2022), Imagen (Saharia et al., 2022; Ho et al., 2022), and Latent Diffusion (Rombach al., 2022). In this paper we focus fine-tuning text-to-image models, but DRaFT is general and could be applied to other diffusion models or fine-tuning tasks, and to different domains such as audio or video.
text prompts, have become prominent tools with the advent of models such
Learning human preferences. Human preference learning trains models on judgements of which behaviors people prefer, rather than on human demonstrations directly (Knox & Stone, 2009; Akrour 2011). This training is commonly done by learning a reward model reflecting human preferences and then learning a policy that maximizes the reward (Christiano et al., 2017; Ibarz et al., 2018). Preference learning methods such as reinforcement learning from human feedback (RLHF) have become widely used for fine-tuning large language models so they improve at summarization (Stiennon al., 2020; Wu et al., 2021), instruction following (Ouyang et al., 2022), or general dialogue (Askell et al., 2021; Bai et al., 2022a; Glaese et al., 2022; Bai et al., 2022b). We apply DRaFT to optimize scores from existing preference models, such as PickScore (Kirstain al., 2023) and Human Preference Score v2 (Wu et al., 2023a), which are trained on human judgements between pairs of images generated by diffusion models for the same prompt.
Guidanee. Guidance steers the sampling process towards images that satisfy a desired objective by adding an auxiliary term to the score function. The canonical example is classifier guidance (Song al., 2021b; Dhariwal& & Nichol, 2021), which can turn an unconditional diffusion model into class- conditional model by biasing the denoising process using gradients from pre-trained classifier. Many other pre-trained models can also be used to provide guidance signals, including segmentation models, facial recognition models, and object detectors (Bansal et al., 2023). However, care must be taken when computing the guidance signal; naïvely, noisy examples obtained during the iterative refinement process may be -iittiiiiitiitooonnn for the guidance model, leading to inaccurate gradients. Two approaches for mitigating this are (1) training a guidance model from scratch on noisy data (Dhariwal & Nichol, 2021) and (2) applying a pre-trained guidance model (which has seen only non-noisy data) to the one-step-denoieed images obtained by removing the predicted noise at time (Li et al., 2022). However, both approaches have downsides: (1) precludes the use of off-the-shelff pre-trained guidance functions and (2) means the guidance is applied to out-of out-of- -ff--dditttibuttion blurry images for high noise levels. DRaFT avoids these issues by backpropagating through sampling so the reward function is only applied to the fully denoised image.
Backpropagation through diffusion sampling. Similarly to our method, Watson et al. (2022) backpropagate through sampling using the reparameterization trick and gradient checkpointing. They learn parametric few-step samplers that aim to reduce the inference cost while maintaining perceptual image quality, using differentiable image quality score. Fan & Lee (2023) also propose an approach to speed up sampling: they consider doing this using gradients by backpropagating through diffusion sampling, but due to memory and aaploding/vanishing approach. Both Fan & Lee (2023) and Watson et al. (2022) aim to improve sampling speed, rather than optimize arbitrary differentiable rewards, which is our focus. Like DRaFT, Direct Optimization of Diffusion Latents (DOODL; Wallace et al. 2023) uses backpropagation through sampling to improve image generation with respect to differentiable objectives. Rather than optimizing model parameters, DOODL optimizes the initial noise sample xy. Although DOODL does not require training phase, it is much slower at inference time because the optimization must be redone for each prompt and metric. In contrast, after finetuning with DRaFT, sampling has the same cost standard
gradient concerns, they focus on an RL-based
27

---

Published as a conference paper at ICLR 2024
diffusion model. Furthermore, the latent optimization methods do not support the compositionality and interpolation properties that we can achieve with different sets of LoRA parameters tuned for different objectives.
Outside of image generation, Wang et al. (2023a) train diffusion model policies for reinforcement learning by backpropagating the Q-value function through sampling.
Reward fine-tuning with supervised learning, Lee et al. (2023) and Wu et al. (2023b) use super- vised approaches to fine-tune diffusion models on rewards, These methods generate images with the pre-trained model and then fine-tune the images while weighting examples according to the reward function or discarding low-reward examples. Unlike DRaFT or RL methods, the model is not trained online examples generated by the current policy. However, Dong et al. (2023) use online version of this approach where examples are re- re-generated over multiple rounds of training, which can be viewed simple kind of reinforcement learning.
Reward fine-tuning with reinforcement learning. Fan & Lee (2023) interpret the denoising process as a multi-step decision-making task and use policy gradient algorithms to fine-tune diffusion samplers. Building on it, Black et al. (2023) and Fan et al. (2023) use policy gradient algorithms to fine-tune diffusion models for arbitrary black-box objectives. Rather than optimizing model parameters, Hao et al. (2022) apply RL to improve the input prompts. RL approaches are flexible because they do not require differentiable rewards. However, in practice many reward functions differentiable, can be re-implemented differentiable way, and thus analytic gradients often available. In such cases, using reinforcement learning discards useful information, leading to inefficient optimization.
ReFL. Reward Feedback Learning (ReFL; Xu et al. 2023) evaluates the reward the one-step predicted clean image, r(Xg, c) from a randomly-chosen step t along the denoising trajectory, and backpropagates through the one-step prediction w.r.t. the diffusion model parameters. DRaFT-K is conceptually simpler than ReFL, as it only differentiates through the last few steps (e.g.. K = 1) of sampling, where K is deterministic; in (Xu et al., 2023), the authors randomly choose an iteration between min and max step of the sampling chain (which incurs more hyperparameters) from which to predict the clean image. Also, because DRaFT runs the full sampling chain, our reward functions are always evaluated on final generations. In contrast, ReFL. applies the rewards to one-step denoised latents in the sampling trajectory, similar to the use of one-step denoising in guidance. Furthermore, DRaFT-LV is substantially more efficient than ReFL, speeding up training by approximately 2 by reducing the variance of the single-denoising-stey gradient estimates.
28

---

Published as a conference paper at ICLR 2024
E UNCURATED SAMPLES
Here, we show uncurated samples from models fine-tuned with DRaFT for different reward functions: Human Preference Score v2 (Figure 35), PickScore (Figure 36), and a combined reward (Figure 37). The first two are overfit to the reward functions, which decreases diversity and photorealism. In the third, we mitigate overfitting through LoRA scaling.
Figure 35: Uncurated samples from Stable Diffusion fine-tuned using DRaFT--1 for the HPSv2 reward (Wu et al., 2023a).
Figure 36: Uncurated samples from Stable Diffusion fine-tuned using DRaFT-1 for the PickScore reward (Kirstain al., 2023).
29

---

Published as a conference paper at ICLR 2024
can athous dustabeen
bowkeel
NGUAL
AONGE
IAIZO
ONE
RLADMREEDI GIP
RANDIDAN
OAZPAD
saleri paidi Emig anres.
Ade par
TTX
hareeen the oreir
WIt
be Fowm oalr msectigros deerrpplle Poogid
grand mighted
BUTA
Figure 37: Uncurated samples from pre- treitrained Stable Diffusion 1.4 compared with DRaFT fine-tuned Stable
Diffusion. We DRaFT-LVV combined reward of PickScore 10, HPSv2 = 2, Aesthetic 0.05. After training, LoRA weights are scaled down by a factor 0.75 to reduce reward overfitting. Prompts are from HPSv2 benchmark.
30


Reviews:
[{"review_id": "wY87E98Acu", "reviewer": "Reviewer_LgKe", "summary": "The paper presents DRaFT for optimizing diffusion models using differentiable reward functions. While the direct fine-tuning idea has been around, the memory issue has been a bottleneck to scale this idea to a large-scale diffusion model. DRaFT uses LoRA/grad checkpointing to solve this problem. The authors propose show that DRaFT can successfully finetune image generative models, better than a reinforcement learning-based approach.", "questions": "- Could you elaborate on the relationship between your work and that of [1], especially regarding the idea of directly fine-tuning diffusion models on differentiable rewards?\n- Can DRaFT work with other PEFT methods such as Adapters, Normalization training, and IA3?\n- The paper does not report the performance of DPOK. Could you clarify how your approach compares to this method?", "limitations": "", "rating": 3, "confidence": 5, "soundness": 3, "presentation": 3, "contribution": 2, "strengths": "The paper presents an original approach to fine-tuning diffusion models using differentiable reward functions. The proposed method, DRaFT, and its variants, DRaFT-K and DRaFT-LV, demonstrate strong performance across a variety of reward functions, outperforming one reinforcement learning-based method. The paper is generally well-written and clear, and the experimental results are promising. The significance of the work lies in its potential to enhance the aesthetic quality of images generated by diffusion models, a valuable contribution to the field of generative models.", "weaknesses": "The paper lacks a thorough discussion of related work. \n1) “Black et al. (2023) and Fan et al. (2023) interpret the denoising process as a multi-step decision-making task, and use policy gradient algorithms to fine-tune diffusion models for arbitrary black-box objectives.” => This interpretation is originally from [1]. \n2) the idea of directly fine-tuning diffusion models on differentiable rewards is also studied in [1], but the authors do not seem to be aware of it. (See Sec 3.3)\n\nAlso, I wonder if other PEFT methods such as Adapters, Normalization training, and IA3 could be used instead of LoRA.\n\n(very minor) The use of the \"stop_grad\" function in the pseudocode is not properly explained, which could lead to confusion for readers unfamiliar with this function.\n\n[1] Reinforcement learning for faster DDPM sampling", "quality": null, "clarity": null, "significance": null, "originality": null, "strengths_and_weaknesses": "", "was_revised": false, "final_justification": "", "rebuttal": "", "claims_and_evidence": "", "methods_and_evaluation_criteria": "", "theoretical_claims": "", "experimental_designs_or_analyses": "", "relation_to_broader_scientific_literature": "", "essential_references_not_discussed": "", "other_strengths_and_weaknesses": "", "other_comments_or_suggestions": "", "questions_for_authors": "", "summary_of_paper": "", "summary_of_recommendation": "", "technical_quality": "", "clarity_of_presentation": "", "potential_impact": "", "robotics_focus": "", "quality_of_limitations": "", "questions_for_rebuttal": "", "reasons_to_accept": "", "reasons_to_reject": "", "questions_to_authors": "", "extra_scores": {}}, {"review_id": "kravdR17RK", "reviewer": "Reviewer_pZzS", "summary": "This paper is another addition to a line of work which fine-tunes diffusion models on reward functions to generate samples with desirable properties. The closest work is ReFL, which backpropagates gradients through a differentiable reward function for a single-step denoising operation. The proposed method, DRaFT, calculates gradients for the entire diffusion sampling chain, which is facilitated by using two existing techniques: low-rank adaption (LoRA) and gradient checkpointing. Different variations of DRaFT are proposed to improve efficiency, reduce memory footprint and reduce variance of the gradient estimates. Experiments use Stable Diffusion 1.4 as the backbone and consider several reward functions such as the LAION aesthetic score, Human Preference Score v2 and PickScore.", "questions": "None", "limitations": "", "rating": 8, "confidence": 4, "soundness": 3, "presentation": 3, "contribution": 3, "strengths": "This is primarily an empirical contribution. While the novelty on the algorithmic side is somewhat limited, this paper applies the idea to large pre-trained models and demonstrates effective performance on generation of realistic images. In terms of significance, this work is an improvement over existing stable diffusion models, with the benefit that using different reward functions enables fine-tuning for different types of characteristics in the generated samples. \n\nThe experiments are comprehensive and compare DRaFT against relevant baselines. The results showcasing interpolation between pre-trained and fine-tuned weights, as well as between LoRA weights for different reward functions are interesting and insightful. The various ablation studies and considering specific problems such as compression, object detection and adversarial examples demonstrate the wide applicability of this method.", "weaknesses": "The relatively minor weakness is related to the organization of the paper to improve clarity. Figure 2 can be moved in Section 4 to match the text with the corresponding model diagram. Section 5.2 discusses the results of many different experiments and while they are organized by paragraphs, splitting them into sub-sections with informative titles, or perhaps a description of the contents of Section 5 (similar to the one for the Appendix) can help navigate this section more easily.", "quality": null, "clarity": null, "significance": null, "originality": null, "strengths_and_weaknesses": "", "was_revised": false, "final_justification": "", "rebuttal": "", "claims_and_evidence": "", "methods_and_evaluation_criteria": "", "theoretical_claims": "", "experimental_designs_or_analyses": "", "relation_to_broader_scientific_literature": "", "essential_references_not_discussed": "", "other_strengths_and_weaknesses": "", "other_comments_or_suggestions": "", "questions_for_authors": "", "summary_of_paper": "", "summary_of_recommendation": "", "technical_quality": "", "clarity_of_presentation": "", "potential_impact": "", "robotics_focus": "", "quality_of_limitations": "", "questions_for_rebuttal": "", "reasons_to_accept": "", "reasons_to_reject": "", "questions_to_authors": "", "extra_scores": {}}, {"review_id": "1l05mgYMoM", "reviewer": "Reviewer_m5FM", "summary": "The paper introduces \"Direct Reward Fine-Tuning (DRaFT)\", as an efficient framework for fine-tuning diffusion models on differentiable rewards. As opposed to previous work, they develop tools to differentiate through the entire diffusion process and use the resulting gradients for fine-tuning. However, they find that the truncated versions of their method which only differentiate through the last time step (similar to previous work such as ReFL(Xu. et al 2023)) works the best. They introduce a variant of this method which computes a lower variance last step gradient by averaging across multiple noise samples. They show that this variant outperforms all baselines and show various interesting use cases of their method.", "questions": "I have a broader philosophical question about the approach. I find the broader approach taken by the paper (and previous work) a little perplexing. For example, the paper at various points shows the perils of over-optimizing a specific objective due to effects like reward hacking. An obvious solution I would assume to a problem like this would be, using a dataset of (prompt, image) pairs with the image as x_0 in an algorithm like DRaFT-LV instead of sampling it using the diffusion process? or perhaps augmenting this as an auxiliary objective along with the regular DRaFT-LV objective? This seems 1) faster and 2) less susceptible to issues like reward hacking etc, as the model stays grounded to remain close to the real image distribution. I would be curious if the authors have experimented with similar methods?\n- Other Minor comments:\n    1) As a general comment, it would be helpful if all the generated images shown in the paper also mention the prompt used. There are \ncertain figures where I couldn’t spot the prompt used to generate the image. Eg. Fig 7.\n    2) Further, in Fig 7, left, it would help if the paper used the same prompt for all 3 examples to contrast how the interpolations vary across the models.", "limitations": "", "rating": 8, "confidence": 4, "soundness": 4, "presentation": 4, "contribution": 3, "strengths": "1. I think the biggest strength of this paper lies in the exhaustive ablations and use cases the authors show. \n   - I particularly liked the experimentation with interpolating and scaling different LORA parameters and the corresponding effects.\n   - I also appreciated the comparisons of the different reward functions and the qualitative differences between the model fine-tuned with them. \n   - I also found some of the applications of this method very interesting, such as the object removal/inclusion example in section 5.3\n   - Lastly, I also liked the reward hacking examples presented in the paper.\n2) The paper is also very well written and was a pleasure to read.\n3) The related work description was thorough and I enjoyed (and learnt from) reading the descriptions and comparisons.", "weaknesses": "The main methodological contributions of the paper seem to be the usage of LoRA and gradient checkpointing techniques to allow differentiating through the full diffusion chain. However, the paper shows that differentiating through the diffusion chain leads to exploding gradients without providing sufficient analysis of it beyond Fig 8 or any attempts to mitigate the issues. Instead most of the benefits in the results are attributed to DRaFT-LV which is (methodologically) a very minor improvement over ReFL. Although the usage of LoRA for fine-tuning even in this single step setting provides interesting possibilities (which the authors exploit rather well in the experiments), I feel the paper would have benefited from additional analysis and fixes for the full DRaFT setting as well.", "quality": null, "clarity": null, "significance": null, "originality": null, "strengths_and_weaknesses": "", "was_revised": false, "final_justification": "", "rebuttal": "", "claims_and_evidence": "", "methods_and_evaluation_criteria": "", "theoretical_claims": "", "experimental_designs_or_analyses": "", "relation_to_broader_scientific_literature": "", "essential_references_not_discussed": "", "other_strengths_and_weaknesses": "", "other_comments_or_suggestions": "", "questions_for_authors": "", "summary_of_paper": "", "summary_of_recommendation": "", "technical_quality": "", "clarity_of_presentation": "", "potential_impact": "", "robotics_focus": "", "quality_of_limitations": "", "questions_for_rebuttal": "", "reasons_to_accept": "", "reasons_to_reject": "", "questions_to_authors": "", "extra_scores": {}}, {"review_id": "nlfccki5Vh", "reviewer": "Reviewer_tWnQ", "summary": "The paper propose Direct Reward Fine-Tuning (DRaFT) for finetuning diffusion models to maximize a differentiable reward functions. Several techniques are applied to circumvent large memory consumption and gradient exploding problem when they perform BPTT for diffusion models: gradient checkpointing, LoRA, ignoring early gradients. A variance-reduced alternative for DRaFT-1 is proposed. The authors provide solid evaluation on a vast set of differentiable rewards, with impressive qualitative results.", "questions": "This is a bit minor, but why do you choose Stable-Diffusion v1.4 instead of SD v1.5 or a higher version?", "limitations": "", "rating": 5, "confidence": 4, "soundness": 4, "presentation": 4, "contribution": 2, "strengths": "Optimizing a diffusion model with direct backprop through a differentiable reward has several technical difficulties and the authors managed to solve them.\n\n(1) increased memory consumption. The authors solve the problem by combining two existing methods gradient checkpointing and LoRA. \n\n(2) gradient exploding/vanishing problem for BPTT. The authors solve the problem by DRaFT-K, i.e., ignore gradients from earlier steps. \n\nThe base model is Stable-Diffusion v1.4. The authors include a vast range of differentiable rewards: (1) aesthetic classifier, (2) trained reward models from HPSv2, PickScore \n(3) JPEG compressibility (4) Object Detector (5) ImageNet classifier. The experiments are solid and the qualitative results look impressive. \n\nSeveral interesting observation: \n\n\n1. compared to ReLF: it seems that DRaFT-1 (the same as ReFL with $m=1$) works better than ReLF with a random $m$. \n\n2. Manipulating LoRA weights have predictable influence on the outputs.", "weaknesses": "The main concern is the significance of the contribution: \n\n1. DRaFT-1 works the best but the improvement over ReFL is a bit marginal (Figs 3 and 4).  Furthermore, DRaFT-1 is the same as ReFL with $m$ fixed to 1. Increasing $K$ does not improve the performance. \n\n2. As DRaFT-1 (and LV version) already works well, in this case, we might not need gradient checkpointing and LoRA, right? How does finetuning the full parameter influence the result?", "quality": null, "clarity": null, "significance": null, "originality": null, "strengths_and_weaknesses": "", "was_revised": false, "final_justification": "", "rebuttal": "", "claims_and_evidence": "", "methods_and_evaluation_criteria": "", "theoretical_claims": "", "experimental_designs_or_analyses": "", "relation_to_broader_scientific_literature": "", "essential_references_not_discussed": "", "other_strengths_and_weaknesses": "", "other_comments_or_suggestions": "", "questions_for_authors": "", "summary_of_paper": "", "summary_of_recommendation": "", "technical_quality": "", "clarity_of_presentation": "", "potential_impact": "", "robotics_focus": "", "quality_of_limitations": "", "questions_for_rebuttal": "", "reasons_to_accept": "", "reasons_to_reject": "", "questions_to_authors": "", "extra_scores": {}}]

Author rebuttal:

Decision: Accept (poster)