SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2202.01361 · ICML · 2022

Generative Flow Networks for Discrete Probabilistic Modeling

Yoshua Bengio, Dinghuai Zhang, Aaron Courville, Zhen Liu, Nikolay Malkin, Alexandra Volokhova

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 (1 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 6 have no contract verdict; 3 failures 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/2202.01361.json · badge: /api/ran/2202.01361.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
zdhnarsil/eb_gfn canonical (classifier label)
classifier basis not recorded on the link
6 ran · 2 no recorded run
gfnorg/eb_gfn community
Papers with Code archive
3 ran · 0 no recorded run
FunctionStatusWhere it lives
GFlowNet_Randf_TB Ran
ran on a synthesized input · constructed an object; no result was computed
gfnorg/eb_gfn/gflownet.py
code served (permissive licence) · get_code("a9eee1bd24b1e137")
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 an instance of its own class, GFlowNet_Randf_TB: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. The code mentions cuda, and the harness aliases cuda to the CPU for every sample; whether this run needed that is not recorded. If your copy returns the same type 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
import torch.nn.functional as F

torch.manual_seed(0)

# Create a minimal args class with all required attributes
class Args:
    def __init__(self):
        self.hid = 8
        self.hid_layers = 2
        self.leaky = True
        self.gfn_bn = False
        self.temp = 1.0
        self.rand_coef = 0.1
        self.init_zero = True
        self.clip = 1.0
        self.l1loss = False
        self.tau = 0.99
        self.train_steps = 100
        self.opt = 'adam'
        self.glr = 0.001
        self.zlr = 0.001
        self.gfn_weight_decay = 0.0

# Create a minimal EBM model
class SimpleEBM(nn.Module):
    def __init__(self, xdim):
        super().__init__()
        self.linear = nn.Linear(xdim, 1)
    
    def forward(self, x):
        return self.linear(x)

# Create test data
xdim = 4
batch_size = 2
device = 'cpu'

# Create EBM model
ebm_model = SimpleEBM(xdim)
ebm_model.to(device)

# Create test data batch
data = torch.randn(batch_size, xdim).to(device)

# Create args
args = Args()

ARGS = {
    'xdim': xdim,
    'args': args,
    'device': device,
    'net': None
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch, tqdm — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type GFlowNet_Randf_TB — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a GFlowNet_Randf_TB output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
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
estimate_ll Ran
ran on a synthesized input
zdhnarsil/eb_gfn/synthetic/synthetic_utils.py
code served (permissive licence) · get_code("77c8c9154ca9862d")
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 torch
import numpy as np
import torch.nn as nn

torch.manual_seed(0)

class SimpleScoreFunc(nn.Module):
    def __init__(self, input_dim):
        super().__init__()
        self.linear = nn.Linear(input_dim, 1)
    
    def forward(self, x):
        return self.linear(x).squeeze(-1)

score_func = SimpleScoreFunc(input_dim=4)

samples = torch.randn(2, 4)

n_partition = 8

rand_samples = torch.randint(2, (8, 4)).float()

ARGS = {
    "score_func": score_func,
    "samples": samples,
    "n_partition": n_partition,
    "rand_samples": rand_samples,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, 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_ebm_samples Ran
ran on a synthesized input
zdhnarsil/eb_gfn/synthetic/synthetic_utils.py
code served (permissive licence) · get_code("fb6f740cc2299d77")
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 tuple. The image it ran in was not recorded. If your copy returns the same type 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 numpy as np

torch.manual_seed(0)

# Build a small score function that takes samples and returns scores
class ScoreFunc(torch.nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = torch.nn.Linear(4, 1)
    
    def forward(self, x):
        return self.linear(x.float())

# Build a gibbs sampler that has a step method
class GibbsSampler:
    def step(self, samples, score_func):
        # Just return the samples with a small flip to avoid infinite loops
        # The function doesn't use the return value except to assign it back
        return samples.clone()

# Create inverse binary map (maps binary strings to themselves)
inv_bm = {}
for i in range(8):
    binary_str = format(i, '03b')
    inv_bm[binary_str] = binary_str

# Ensure we have all needed strings for discrete_dim=4
for i in range(4):
    binary_str = format(i, '02b')
    inv_bm[binary_str] = binary_str

ARGS = {
    'score_func': ScoreFunc(),
    'size': 2,
    'inv_bm': inv_bm,
    'int_scale': 100,
    'discrete_dim': 4,
    'device': 'cpu',
    'gibbs_sampler': GibbsSampler(),
    'gibbs_steps': 2
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple — a tuple output has no array shape of its own; none is stated
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_true_samples Ran
ran on a synthesized input
zdhnarsil/eb_gfn/synthetic/synthetic_utils.py
code served (permissive licence) · get_code("395de5d1a0676567")
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, 16) 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 numpy as np

torch.manual_seed(0)

class MockDB:
    def gen_batch(self, size):
        # Return a batch of 2D samples (x, y coordinates)
        return np.random.randn(size, 2).astype(np.float32)
    
    def gen_batch_with_seed(self, size, seed):
        np.random.seed(seed)
        return np.random.randn(size, 2).astype(np.float32)

# Create a simple binary mapping - maps binary strings to themselves
bm = {}
for i in range(256):
    binary_str = bin(i)[2:].zfill(8)
    bm[binary_str] = binary_str

db = MockDB()
size = 2
int_scale = 10
discrete_dim = 16

ARGS = {
    "db": db,
    "size": size,
    "bm": bm,
    "int_salce": int_scale,
    "discrete_dim": discrete_dim,
    "seed": None
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, 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, 16) — shape (2, 16) 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
inf_train_gen Ran
ran on a synthesized input
zdhnarsil/eb_gfn/synthetic/synthetic_data.py
code served (permissive licence) · get_code("94ec778ec432087a")
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 ndarray, ndim 2, dtype family float, shape (200, 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 numpy as np
import sklearn.datasets

ARGS = {
    'data': 'swissroll',
    'rng': np.random.RandomState(42),
    'batch_size': 200
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, sklearn — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ndarray, ndim 2, dtype family float, shape (200, 2) — shape (200, 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
make_mlp Ran
ran; our contract draft was wrong, not the code
gfnorg/eb_gfn/gflownet.py
code served (permissive licence) · get_code("748e67c13d4d482f")
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 Sequential. The image it ran in was not recorded. If your copy returns the same type 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)

ARGS = {
    "l": [4, 8, 6, 2],
    "act": nn.LeakyReLU(),
    "tail": [],
    "with_bn": False
}
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 Sequential — a Sequential output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Sequential output the recorded ndim 1 and dtype family float describe that coercion, not the output, and are not stated
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
mlp_ebm Ran
ran; our contract draft was wrong, not the code
zdhnarsil/eb_gfn/network.py
pointer only (licence: MIT); the stored copy get_code serves, from patrickpynadath1/automatic_cyclical_sampling, is pointer only (licence: NONE) · get_code("646a9f9fd82940a8")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (MIT), but get_code serves the stored copy, first harvested from patrickpynadath1/automatic_cyclical_sampling, 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.

tb_mle_learnedpb_loss Ran
ran on a synthesized input
zdhnarsil/eb_gfn/gflownet.py
code served (permissive licence) · get_code("17e1040599b7fde6")
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 tuple. The image it ran in was not recorded. If your copy returns the same type 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 SimpleGFN:
    def __init__(self):
        self.xdim = 4
        self.device = 'cpu'
        self.init_zero = True
        self.exp_temp = 1.0
        self.rand_coef = 0.1
        self.logZ = 0.5
        self.l1loss = False
        self.model = SimpleModel()
    
class SimpleModel(nn.Module):
    def __init__(self):
        super().__init__()
        # Output: 2*xdim (add_logits) + xdim (del_logits) = 3*xdim total
        # For xdim=4: 12 outputs
        self.linear = nn.Linear(4, 12)
    
    def forward(self, x):
        return self.linear(x)

class SimpleEBM(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 1)
    
    def forward(self, x):
        return self.linear(x)

gfn = SimpleGFN()
ebm_model = SimpleEBM()

# Create sample data batch
data = torch.randn(2, 4)
data[data.abs() < 0.5] = 1.0  # Make some non-zero values for init_zero case
data[data.abs() < 0.5] = 0.0  # Ensure some zeros

ARGS = {
    'ebm_model': ebm_model,
    'gfn': gfn,
    'batch_size': 2,
    'back_ratio': 0.3,
    'data': data
}
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 tuple — a tuple output has no array shape of its own; none is stated
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
tb_mle_randf_loss Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
gfnorg/eb_gfn/gflownet.py
code served (permissive licence) · get_code("15b88275b738f13f")
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 tuple. The image it ran in was not recorded. If your copy returns the same type 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 SimpleGFN(nn.Module):
    def __init__(self, xdim, device='cpu'):
        super().__init__()
        self.xdim = xdim
        self.device = device
        self.init_zero = True
        self.rand_coef = 0.1
        self.l1loss = False
        self.logZ = torch.tensor(1.0)
        
        # GFN model outputs logits: 2*xdim for add values + extra for padding
        self.model = nn.Linear(xdim, 2 * xdim + 4)
    
    def forward(self, x):
        return self.model(x)

class SimpleEBM(nn.Module):
    def __init__(self, xdim, device='cpu'):
        super().__init__()
        self.xdim = xdim
        self.device = device
        self.fc = nn.Linear(xdim, 1)
    
    def forward(self, x):
        return self.fc(x).squeeze(-1)

# Create instances
xdim = 4
batch_size = 2
device = 'cpu'

gfn = SimpleGFN(xdim, device=device)
ebm_model = SimpleEBM(xdim, device=device)

# Create data for back_ratio > 0
data = torch.zeros((batch_size, xdim))

ARGS = {
    'ebm_model': ebm_model,
    'gfn': gfn,
    'batch_size': batch_size,
    'back_ratio': 0.5,
    'data': data,
}
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 tuple — a tuple output has no array shape of its own; none is stated
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
load_dataset Not yet run
unverified (harvested, no recorded run)
zdhnarsil/eb_gfn/utils_data.py
code served (permissive licence) · get_code("5b4889200346ea70")
How it ran

no invocation recorded.

load_dynamic_mnist Not yet run
unverified (harvested, no recorded run)
zdhnarsil/eb_gfn/utils_data.py
code served (permissive licence) · get_code("e3e34d78cb795ec1")
How it ran

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 (0 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
make_mlp
brick of this paper's assembly: helper
2 other papers
2 later
2310.00386 (2023-10)
Order-Preserving GFlowNets
2310.02710 (2023-10)
Local Search GFlowNets
mlp_ebm 2 other papers
2 later
2209.08183 (2022-09)
Optimal Scaling for Locally Balanced Proposals in Discrete Spaces
2402.17699 (2024-02)
Gradient-based Discrete Sampling with Automatic Cyclical Scheduling

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 energy-based generative flow networks (EB-GFN), a novel probabilistic modeling algorithm for high-dimensional discrete data. Building upon the theory of generative flow networks (GFlowNets; Bengio et al., 2021b), we model the generation process by a stochastic data construction policy and thus amortize expensive MCMC exploration into a fixed number of actions sampled from a GFlowNet. We show how GFlowNets can approximately perform large-block Gibbs sampling to mix between modes. We propose a framework to jointly train a GFlowNet with an energy function, so that the GFlowNet learns to sample from the energy distribution, while the energy learns with an approximate MLE objective with negative samples from the GFlowNet. We demonstrate EB-GFN's effectiveness on various probabilistic modeling tasks. Code is publicly available at github.com/zdhNarsil/EB GFN.

For agents

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

get_harvested_code_for_paper("2202.01361")
get_code_for_paper("2202.01361")
have("2202.01361")

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

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

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

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

Connect an agent — have() is free.