SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2211.15029 · 2022

DiffusionBERT: Improving Generative Masked Language Models with Diffusion Models

arXiv · PDF · Open in the Atlas

Code that ran

9 of 11 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 8 have no contract verdict; 1 failure of our instrument; 2 no recorded run), measured 2026-11-22; 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/2211.15029.json · badge: /api/ran/2211.15029.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
hzfinfdu/diffusion-bert canonical (classifier label)
classifier basis not recorded on the link
9 ran · 2 no recorded run
FunctionStatusWhere it lives
create_position_ids_from_input_ids Ran
ran; our contract draft was wrong, not the code
hzfinfdu/diffusion-bert/models/modeling_roberta.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from Kowsher/Propulsion, is pointer only (licence: NONE) · get_code("38f46ef4e03fee1c")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (Apache-2.0), but get_code serves the stored copy, first harvested from Kowsher/Propulsion, and GitHub detected no licence in that repository when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

cross_entropy_with_probs Ran
ran on a synthesized input
hzfinfdu/diffusion-bert/losses.py
code served (permissive licence) · get_code("110e847251e7cce1")
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 2, dtype family float, shape (2, 3) 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)

# Create sample tensors
batch_size = 2
sequence_length = 3
num_classes = 4

# probs: [..., length, num_classes] float array
probs = torch.rand(batch_size, sequence_length, num_classes)

# targets: [..., length] int array
targets = torch.randint(0, num_classes, (batch_size, sequence_length))

# epsilon: small noise to add to probs when converting to log space
epsilon = 1e-20

ARGS = {
    "probs": probs,
    "targets": targets,
    "epsilon": epsilon,
}
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 2, dtype family float, shape (2, 3) — shape (2, 3) 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
dist1 Ran
ran on a synthesized input
hzfinfdu/diffusion-bert/compute_metric.py
code served (permissive licence) · get_code("841fce93f14f6675")
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 float64, ndim 0, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim 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 nltk
import numpy as np

# Ensure nltk data is available
try:
    nltk.data.find('tokenizers/punkt')
except LookupError:
    nltk.download('punkt', quiet=True)

# Create sample hypotheses (list of strings)
hypn = [
    "the quick brown fox jumps over the lazy dog",
    "the cat sat on the mat",
    "hello world"
]

ARGS = {
    "hypn": hypn,
    "n": 1
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
nltk, numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type float64, ndim 0, dtype family float — no output shape is stated: observe_signature.py recorded float ndim 0, which disagrees with the fixture run
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
div4 Ran
ran on a synthesized input
hzfinfdu/diffusion-bert/compute_metric.py
code served (permissive licence) · get_code("35a119672af367f4")
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 float, ndim 0, dtype family float, shape () 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 nltk
import torch

# The function takes:
# - hypn: a list/iterable of hypothesis strings
# - n: an integer parameter (default 4) for n-gram size

# Looking at the function body:
# - It iterates over hypn
# - For each hyp in hypn, it calls hyp.split() (so hyp must be a string)
# - It uses nltk.ngrams() to generate n-grams
# - It computes statistics on the n-grams

# Construct sample hypotheses (list of strings)
hypn = [
    "the quick brown fox jumps over the lazy dog",
    "a simple test sentence with some words",
    "another hypothesis to test the function"
]

ARGS = {
    "hypn": hypn,
    "n": 4
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
nltk, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type float, ndim 0, dtype family float, shape () — shape () 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
get_bleu Ran
ran on a synthesized input
hzfinfdu/diffusion-bert/compute_metric.py
code served (permissive licence) · get_code("7b8175dc450ebd39")
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 float, ndim 0, dtype family float, shape () 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.

from nltk.translate.bleu_score import sentence_bleu, SmoothingFunction as SF

smooth_method = SF().method4

def get_bleu(recover, reference):
    return sentence_bleu([recover.split()], reference.split(), smoothing_function=smooth_method)

# Setup: recover and reference should be strings that can be split into tokens
recover = "the quick brown fox jumps over the lazy dog"
reference = "the quick brown fox jumps over a lazy dog"

ARGS = {
    "recover": recover,
    "reference": reference
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
nltk — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type float, ndim 0, dtype family float, shape () — shape () 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
get_timestep_embedding Ran
ran on a synthesized input
hzfinfdu/diffusion-bert/models/modeling_bert_new_timestep.py
code served (permissive licence) · get_code("f93c2d73d355d807")
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 2, dtype family float, shape (2, 4) 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 math

torch.manual_seed(0)

# Construct arguments for get_timestep_embedding
timesteps = torch.tensor([0.5, 1.5], dtype=torch.float32)  # 1-D tensor of N=2 indices
dim = 4  # output dimension
max_period = 10000  # default value

ARGS = {
    "timesteps": timesteps,
    "dim": dim,
    "max_period": max_period,
}
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 2, dtype family float, shape (2, 4) — shape (2, 4) 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
kl_divergence_with_probs Ran
ran on a synthesized input
hzfinfdu/diffusion-bert/losses.py
code served (permissive licence) · get_code("24387783361281e8")
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

torch.manual_seed(0)

# Create two probability distributions with shape [..., dim]
# Using shape (2, 4) where batch size is 2 and dimension is 4
p = torch.tensor([
    [0.1, 0.2, 0.3, 0.4],
    [0.25, 0.25, 0.25, 0.25]
], dtype=torch.float32)

# Normalize to ensure valid probabilities
p = p / p.sum(dim=-1, keepdim=True)

q = torch.tensor([
    [0.2, 0.3, 0.25, 0.25],
    [0.1, 0.1, 0.4, 0.4]
], dtype=torch.float32)

# Normalize to ensure valid probabilities
q = q / q.sum(dim=-1, keepdim=True)

epsilon = 1e-20

ARGS = {
    "p": p,
    "q": q,
    "epsilon": epsilon
}
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
p_forward Ran
ran on a synthesized input
hzfinfdu/diffusion-bert/diffusion_condition.py
code served (permissive licence) · get_code("1dd4ba483b72927b")
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 3, dtype family float, shape (2, 3, 10) 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)

# Build a minimal denoise_fn that supports the required interface
class DenoiseFn(nn.Module):
    def __init__(self):
        super().__init__()
        self.embedding = nn.Embedding(10, 4)
        self.linear = nn.Linear(4, 10)
    
    def forward(self, corrupted_input_ids, timestep):
        # corrupted_input_ids: [batch_size, seq_len]
        # timestep: scalar or tensor
        # returns logits [batch_size, seq_len, vocab_size]
        batch_size = corrupted_input_ids.shape[0]
        seq_len = corrupted_input_ids.shape[1]
        embedded = self.embedding(corrupted_input_ids)  # [batch_size, seq_len, 4]
        logits = self.linear(embedded)  # [batch_size, seq_len, 10]
        return logits

# Build a minimal Diffusion object
class Diffusion:
    def sample_and_compute_posterior_q(
        self, 
        x_0, 
        t, 
        return_logits=False, 
        make_one_hot=False, 
        transition_probs_in_logits=True, 
        transition_probs=None, 
        samples=None, 
        epsilon=1e-20, 
        step_size=1, 
        word_freq_logits=None
    ):
        # x_0: probs or argmax indices depending on make_one_hot
        # returns (qt_probs, something)
        if make_one_hot:
            # x_0 is indices, convert to one-hot
            batch_size, seq_len = x_0.shape
            vocab_size = 10
            one_hot = torch.zeros(batch_size, seq_len, vocab_size)
            one_hot.scatter_(-1, x_0.unsqueeze(-1), 1.0)
            qt_probs = one_hot
        else:
            # x_0 is already probs
            qt_probs = x_0
        
        if return_logits:
            qt_probs = torch.log(qt_probs + epsilon)
        
        return qt_probs, None

denoise_fn = DenoiseFn()
x_t = torch.randint(0, 10, (2, 3))  # [batch_size=2, seq_len=3]
t = torch.tensor(5)
diffusion = Diffusion()

ARGS = {
    'denoise_fn': denoise_fn,
    'x_t': x_t,
    't': t,
    'diffusion': diffusion,
    'predict_x0': True,
    'return_x0': False,
    'return_logits': False,
    'special_case_x0': False,
    'transition_probs': None,
    'transition_probs_in_logits': True,
    'maximum_likelihood': False,
    'epsilon': 1e-20,
    'step_size': 1,
    'word_freq_logits': None,
}
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 3, dtype family float, shape (2, 3, 10) — shape (2, 3, 10) 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
process_fn_in_collate Ran
ran on a synthesized input
hzfinfdu/diffusion-bert/compute_elbo.py
code served (permissive licence) · get_code("59f7bb96a85f250f")
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 2, dtype family float, shape (2, 4) 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)

# The function expects a tensor (wf) and calls .mean() on it
# Create a small tensor with distinct dimensions for probing
wf = torch.randn(2, 4)

ARGS = {
    "wf": wf
}
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 2, dtype family float, shape (2, 4) — shape (2, 4) 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
collate_fn Not yet run
unverified (harvested, no recorded run)
hzfinfdu/diffusion-bert/compute_elbo.py
code served (permissive licence) · get_code("6f15d047a8622d18")
How it ran

no invocation recorded.

load_tf_weights_in_bert Not yet run
unverified (harvested, no recorded run)
hzfinfdu/diffusion-bert/models/modeling_bert.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from hqsiswiliam/lapdog, is pointer only (licence: NONE) · get_code("d009b630f4496e64")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (Apache-2.0), but get_code serves the stored copy, first harvested from hqsiswiliam/lapdog, and GitHub detected no licence in that repository when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. No invocation recorded.

Also present in other papers' code

Of 11 samples lifted from this paper's linked repositories, 11 carry a function identity and 0 do not. Of the 11 distinct functions with an identity, 2 are also present in other papers whose code we hold (2 with at least one paper dated earlier, 0 the same month, 2 later) and 9 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
create_position_ids_from_input_ids 28 other papers
11 dated earlier, 17 later
2107.00910 (2021-07)
Learned Token Pruning for Transformers
2107.14035 (2021-07)
ProtoTransformer: A Meta-Learning Approach to Providing Student Feedback
2201.11732 (2022-01)
IGLUE: A Benchmark for Transfer Learning across Modalities, Tasks, and Languages
and 25 more not named here
load_tf_weights_in_bert 14 other papers
3 dated earlier, 10 later, 1 same year, order not determinable
2112.02505 (2021-12)
Causal Distillation for Language Models
2022.findings-emnlp.24 (2022 (year only))
AssistSR: Task-oriented Video Segment Retrieval for Personal AI Assistant
2206.07699 (2022-06)
Write and Paint: Generative Vision-Language Models are Unified Modal Learners
and 11 more not named here

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-22.

Repositories linked to this paper

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

Abstract

We present DiffusionBERT, a new generative masked language model based on discrete diffusion models. Diffusion models and many pre-trained language models have a shared training objective, i.e., denoising, making it possible to combine the two powerful models and enjoy the best of both worlds. On the one hand, diffusion models offer a promising training strategy that helps improve the generation quality. On the other hand, pre-trained denoising language models (e.g., BERT) can be used as a good initialization that accelerates convergence. We explore training BERT to learn the reverse process of a discrete diffusion process with an absorbing state and elucidate several designs to improve it. First, we propose a new noise schedule for the forward diffusion process that controls the degree of noise added at each step based on the information of each token. Second, we investigate several designs of incorporating the time step into BERT. Experiments on unconditional text generation demonstrate that DiffusionBERT achieves significant improvement over existing diffusion models for text (e.g., D3PM and Diffusion-LM) and previous generative masked language models in terms of perplexity and BLEU score.

For agents

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

get_harvested_code_for_paper("2211.15029")
get_code_for_paper("2211.15029")
have("2211.15029")

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

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

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

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

Connect an agent — have() is free.