SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2505.11245 · ICLR · 2025

Diffusion-NPO: Negative Preference Optimization for Better Preference Aligned Generation of Diffusion Models

Hongsheng Li, Kong, Keqiang Sun, Fu-Yun Wang, Yunhao Shui, Jingtan Piao, Hong Mmlab

arXiv · PDF · Open in the Atlas

Code that ran

2 of 3 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 0 have no contract verdict; 2 failures of our instrument; 1 no recorded run), measured 2026-11-23; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2505.11245.json · badge: /api/ran/2505.11245.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
g-u-n/diffusion-npo community
Papers with Code archive
2 ran · 1 no recorded run
FunctionStatusWhere it lives
_get_variance Ran
ran; our contract draft was wrong, not the code
g-u-n/diffusion-npo/RL-SPO-NPO/spo/custom_diffusers/ddim_with_logprob.py
code served (permissive licence) · get_code("92a985b9cf3cd4ee")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 1, dtype family float, shape (2,) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

torch.manual_seed(0)

class DiffusionModel(nn.Module):
    def __init__(self):
        super().__init__()
        # Create alphas_cumprod as a buffer with shape (1000,) to simulate timestep schedule
        self.register_buffer('alphas_cumprod', torch.linspace(0.9999, 0.0001, 1000))
        # Create final_alpha_cumprod as a scalar
        self.register_buffer('final_alpha_cumprod', torch.tensor(0.0))

model = DiffusionModel()

# Create valid timestep indices (within range [0, 1000))
timestep = torch.tensor([5, 10], dtype=torch.long)  # batch of 2
prev_timestep = torch.tensor([3, 8], dtype=torch.long)  # batch of 2

ARGS = {
    'self': model,
    'timestep': timestep,
    'prev_timestep': prev_timestep
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 1, dtype family float, shape (2,) — shape (2,) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
_left_broadcast Ran
ran; our contract draft was wrong, not the code
g-u-n/diffusion-npo/RL-SPO-NPO/spo/custom_diffusers/ddim_with_logprob.py
code served (permissive licence) · get_code("5923770195ed4c9e")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned Tensor, ndim 4, dtype family float, shape (2, 3, 4, 5) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

# Construct arguments for _left_broadcast(t, shape)
# The function reshapes tensor t and broadcasts it to the target shape
# t.ndim must be <= len(shape)

# Create a small tensor with 2 dimensions
t = torch.randn(2, 3)

# Create a target shape that has more dimensions than t
# t.ndim = 2, so len(shape) must be >= 2
# Let's use shape with 4 dimensions
shape = (2, 3, 4, 5)

ARGS = {
    "t": t,
    "shape": shape,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 4, dtype family float, shape (2, 3, 4, 5) — shape (2, 3, 4, 5) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
ddim_step_with_logprob Not yet run
unverified (harvested, no recorded run)
g-u-n/diffusion-npo/RL-SPO-NPO/spo/custom_diffusers/ddim_with_logprob.py
code served (permissive licence) · get_code("b4fa76cf341de453")
How it ran

no invocation recorded.

Also present in other papers' code

Of 3 samples lifted from this paper's linked repositories, 3 carry a function identity and 0 do not. Of the 3 distinct functions with an identity, 1 are also present in other papers whose code we hold (1 with at least one paper dated earlier, 0 the same month, 0 later) and 2 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

FunctionAlso present inEarliest-datedOthers named
ddim_step_with_logprob
brick of this paper's assembly: entry
1 other paper
1 dated earlier
2406.04314 (2024-06)
Aesthetic Post-Training Diffusion Models from Generic Preferences with Step-by-step Preference Optimization

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-23.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

Diffusion models have made substantial advances in image generation, yet models trained on large, unfiltered datasets often yield outputs misaligned with human preferences. Numerous methods have been proposed to fine-tune pre-trained diffusion models, achieving notable improvements in aligning generated outputs with human preferences. However, we argue that existing preference alignment methods neglect the critical role of handling unconditional/negative-conditional outputs, leading to a diminished capacity to avoid generating undesirable outcomes. This oversight limits the efficacy of classifier-free guidance (CFG), which relies on the contrast between conditional generation and unconditional/negativeconditional generation to optimize output quality. In response, we propose a straightforward but versatile effective approach that involves training a model specifically attuned to negative preferences. This method does not require new training strategies or datasets but rather involves minor modifications to existing techniques. Our approach integrates seamlessly with models such as SD1.5, SDXL, video diffusion models and models that have undergone preference optimization, consistently enhancing their alignment with human preferences. Code is available at https://github.com/G-U-N/Diffusion-NPO.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2505.11245")
get_code_for_paper("2505.11245")
have("2505.11245")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2505.11245.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2505.11245.svg)](https://syntology.ai/paper/2505.11245)

Connect an agent — have() is free.