SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2006.03535 · ICLR · 2021

CoCon: A Self-Supervised Approach for Controlled Text Generation

Alvin Chan, Yew-Soon Ong, Bill Pung, Aston Zhang, Jie Fu

arXiv · PDF · Open in the Atlas

Code that ran

5 of 6 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (3 of them constructed an object rather than computing a result; 1 honoured the contract we drafted, 0 violated it and 3 have no contract verdict; 1 failure of our instrument; 1 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/2006.03535.json · badge: /api/ran/2006.03535.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
alvinchangw/COCON_ICLR2021 canonical (classifier label)
classifier basis: classifier_2025
4 ran · 1 no recorded run
copy not recorded community
not in the paper's declared repositories
1 ran · 0 no recorded run
FunctionStatusWhere it lives
CoconAttention Ran
ran on a synthesized input · constructed an object; no result was computed
alvinchangw/COCON_ICLR2021/transformers/modeling_gpt2.py
code served (permissive licence) · get_code("ecda3bf262fb3173")
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, CoconAttention: the run constructed the object and did not call it, so no result was computed. 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
import math

torch.manual_seed(0)

# Stand-in config class with required attributes
class Config:
    def __init__(self):
        self.output_attentions = False
        self.n_head = 2
        self.attn_pdrop = 0.1
        self.resid_pdrop = 0.1

# Create config instance
config = Config()

# Parameters for CoconAttention.__init__
nx = 4  # embedding dimension
n_ctx = 8  # context length
scale = False

ARGS = {
    "nx": nx,
    "n_ctx": n_ctx,
    "config": config,
    "scale": scale,
}
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 CoconAttention — 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 CoconAttention 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
Conv1D Ran
ran on a synthesized input · constructed an object; no result was computed
alvinchangw/COCON_ICLR2021/transformers/modeling_gpt2.py
code served (permissive licence) · get_code("1f5e6090de4f273a")
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, Conv1D: the run constructed the object and did not call it, so no result was computed. 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)

# Conv1D.__init__ takes nf and nx as parameters
# nf: output feature dimension
# nx: input feature dimension

nf = 8  # output features
nx = 5  # input features

ARGS = {
    'nf': nf,
    'nx': nx,
}
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 Conv1D — 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 Conv1D 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
MLP Ran
ran on a synthesized input · constructed an object; no result was computed
alvinchangw/COCON_ICLR2021/transformers/modeling_gpt2.py
code served (permissive licence) · get_code("ae4f6a5f000c8cbd")
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, MLP: the run constructed the object and did not call it, so no result was computed. 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
import math

torch.manual_seed(0)

# Create a minimal config class with required attributes
class Config:
    def __init__(self):
        self.n_embd = 4  # embedding dimension
        self.resid_pdrop = 0.1  # residual dropout probability

config = Config()

# n_state is the intermediate state dimension (different from n_embd for clarity)
n_state = 3

ARGS = {
    "n_state": n_state,
    "config": config,
}
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 MLP — 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 MLP 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
gelu_new Ran
ran, honoured the contract we drafted
this paper's copy was not recorded; identical code first harvested from lonePatient/BERT-SDA
pointer only; the stored copy get_code serves, from lonePatient/BERT-SDA, is pointer only (licence: NONE) · get_code("77601724cad03f95")
How it ran

The body of this sample is withheld: this paper's copy of the code was not recorded (its link names no repository or source path), so no licence was read for it. 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.

prune_conv1d_layer Ran
ran; our contract draft was wrong, not the code
alvinchangw/COCON_ICLR2021/transformers/modeling_gpt2.py
code served (permissive licence) · get_code("c92db0c571d83ad4")
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 Conv1D. 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 Conv1D(nn.Module):
    def __init__(self, nf, nx):
        super().__init__()
        self.nf = nf
        w = torch.empty(nx, nf)
        nn.init.normal_(w, std=0.02)
        self.weight = nn.Parameter(w)
        self.bias = nn.Parameter(torch.zeros(nf))

    def forward(self, x):
        size_out = x.size()[:-1] + (self.nf,)
        x = torch.addmm(self.bias, x.reshape(-1, x.size(-1)), self.weight)
        x = x.view(*size_out)
        return x

# Create a Conv1D layer to prune
# Conv1D takes (nf, nx) where nx is input feature dim, nf is output feature dim
layer = Conv1D(nf=5, nx=4)

# Create an index tensor to select which outputs to keep
# dim=1 means we're selecting along the output dimension
index = torch.tensor([0, 2, 4], dtype=torch.long)

ARGS = {
    "layer": layer,
    "index": index,
    "dim": 1
}
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 Conv1D — a Conv1D output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Conv1D 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
CoconBlock Not yet run
unverified (harvested, no recorded run)
alvinchangw/COCON_ICLR2021/transformers/modeling_gpt2.py
code served (permissive licence) · get_code("5070af0ce59c31c0")
How it ran

no invocation recorded.

Also present in other papers' code

Of 6 samples lifted from this paper's linked repositories, 6 carry a function identity and 0 do not. Of the 6 distinct functions with an identity, 2 are also present in other papers whose code we hold (2 with at least one paper dated earlier, 1 the same month, 2 later) and 4 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
gelu_new
brick of this paper's assembly: helper
23 other papers
7 dated earlier, 1 the same month, 15 later
1810.04805 (2018-10)
BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding
1909.11942 (2019-09)
ALBERT: A Lite BERT for Self-supervised Learning of Language Representations
1911.03631 (2019-11)
Hierarchical Graph Network for Multi-hop Question Answering
and 20 more not named here
prune_conv1d_layer
brick of this paper's assembly: helper
16 other papers
6 dated earlier, 10 later
1906.08237 (2019-06)
XLNet: Generalized Autoregressive Pretraining for Language Understanding
1909.05311 (2019-09)
Graph-Based Reasoning over Heterogeneous External Knowledge for Commonsense Question Answering
1909.11942 (2019-09)
ALBERT: A Lite BERT for Self-supervised Learning of Language Representations
and 13 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

Pretrained Transformer-based language models (LMs) display remarkable natural language generation capabilities. With their immense potential, controlling text generation of such LMs is getting attention. While there are studies that seek to control high-level attributes (such as sentiment and topic) of generated text, there is still a lack of more precise control over its content at the word-and phrase-level. Here, we propose Content-Conditioner (CoCon) to control an LM's output text with a content input, at a fine-grained level. In our self-supervised approach, the CoCon block learns to help the LM complete a partially-observed text sequence by conditioning with content inputs that are withheld from the LM. Through experiments, we show that CoCon can naturally incorporate target content into generated texts and control high-level text attributes in a zero-shot manner. 1

For agents

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

get_harvested_code_for_paper("2006.03535")
get_code_for_paper("2006.03535")
have("2006.03535")

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

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

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

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

Connect an agent — have() is free.