SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 1905.12926 · 2019

Controllable Unsupervised Text Attribute Transfer via Editing Entangled Latent Representation

arXiv · PDF · Open in the Atlas

Code that ran

8 of 8 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, 1 violated it and 3 have no contract verdict; 4 failures of our instrument; 0 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/1905.12926.json · badge: /api/ran/1905.12926.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
nrgeup/controllable-text-attribute-transfer canonical (classifier label)
classifier basis: census
8 ran · 0 no recorded run
FunctionStatusWhere it lives
attention Ran
ran; our contract draft was wrong, not the code
nrgeup/controllable-text-attribute-transfer/method/mymodel-amazon/model.py
code served (permissive licence) · get_code("7fe78353a2ca448c")
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
import torch.nn.functional as F
import math

torch.manual_seed(0)

# Batch size 2, sequence length 3, embedding dimension 4
batch_size = 2
seq_len = 3
d_k = 4

# Create query, key, value tensors
# Shape: (batch_size, seq_len, d_k)
query = torch.randn(batch_size, seq_len, d_k)
key = torch.randn(batch_size, seq_len, d_k)
value = torch.randn(batch_size, seq_len, d_k)

# Create mask (optional parameter)
# Shape: (batch_size, seq_len, seq_len)
# 1 means attend, 0 means mask out
mask = torch.ones(batch_size, seq_len, seq_len)

# Create dropout (optional parameter)
# The function calls dropout(p_attn), so we need a module with __call__
dropout_layer = nn.Dropout(p=0.1)

ARGS = {
    "query": query,
    "key": key,
    "value": value,
    "mask": mask,
    "dropout": dropout_layer
}
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
bleu_count Ran
ran; our contract draft was wrong, not the code
nrgeup/controllable-text-attribute-transfer/method/mymodel-amazon/bleu.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from liangzid/alignmentextraction, is pointer only (licence: NONE) · get_code("622878101d35577d")
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 liangzid/alignmentextraction, 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.

calc_bleu Ran
ran on a synthesized input
nrgeup/controllable-text-attribute-transfer/method/mymodel-amazon/data.py
code served (permissive licence) · get_code("4d99b7ed72130407")
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
from nltk.translate.bleu_score import SmoothingFunction

# The function calc_bleu expects:
# - reference: a list of reference translations (each is a list of tokens)
# - hypothesis: a list of tokens for the hypothesis translation

# Create simple tokenized references and hypothesis
reference = [
    ['the', 'cat', 'sat', 'on', 'the', 'mat'],
    ['a', 'cat', 'is', 'sitting', 'on', 'a', 'mat']
]

hypothesis = ['the', 'cat', 'sat', 'on', 'the', 'mat']

ARGS = {
    'reference': reference,
    'hypothesis': hypothesis
}
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
clones Ran
ran; our contract draft was wrong, not the code
nrgeup/controllable-text-attribute-transfer/method/mymodel-amazon/model.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from DSE-MSU/R-transformer, is pointer only (licence: NONE) · get_code("b1bec2c4b1c9b491")
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 DSE-MSU/R-transformer, 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.

corpus_bleu Ran
ran; our contract draft was wrong, not the code
nrgeup/controllable-text-attribute-transfer/method/mymodel-amazon/bleu.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from liangzid/alignmentextraction, is pointer only (licence: NONE) · get_code("11aff40704a6d93e")
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 liangzid/alignmentextraction, 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.

incremental_bleu_count Ran
ran on a synthesized input
nrgeup/controllable-text-attribute-transfer/method/mymodel-amazon/bleu.py
code served (permissive licence) · get_code("49c690ca7546d3bb")
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 copy

def incremental_bleu_count(hypothesis, references, max_n=4):
    ret_len_hyp = []
    ret_len_ref = []
    ret_clip_count = []
    ret_count = []
    for m in range(len(hypothesis)):
        hyp, ref = (hypothesis[m], references[m])
        x = hyp.split()
        y = [r.split() for r in ref]
        x_len = len(x)
        y_len = [len(s) for s in y]
        n_ref = len(ref)
        ref_ngram = dict()
        for i in range(n_ref):
            for n in range(max_n):
                sent_ngram = dict()
                for st in range(0, y_len[i] - n):
                    ngram = '%d' % (n + 1)
                    for k in range(n + 1):
                        j = st + k
                        ngram += ' %s' % y[i][j]
                    if ngram not in sent_ngram:
                        sent_ngram[ngram] = 0
                    sent_ngram[ngram] += 1
                for ngram in sent_ngram.keys():
                    if ngram not in ref_ngram or ref_ngram[ngram] < sent_ngram[ngram]:
                        ref_ngram[ngram] = sent_ngram[ngram]
        y_len = sorted(y_len)
        ret_len_hyp.append([])
        ret_len_ref.append([])
        ret_clip_count.append([])
        ret_count.append([])
        hyp_ngram = dict()
        p_closest = 0
        for i in range(x_len):
            if i == 0:
                ret_clip_count[-1].append([0] * max_n)
                ret_count[-1].append([0] * max_n)
            else:
                ret_clip_count[-1].append(copy.deepcopy(ret_clip_count[-1][-1]))
                ret_count[-1].append(copy.deepcopy(ret_count[-1][-1]))
            j = i + 1
            ret_len_hyp[-1].append(i + 1)
            if j > y_len[p_closest]:
                while j > y_len[p_closest] and p_closest < n_ref - 1:
                    p_closest += 1
            tmp_closest_diff = 9999
            tmp_closest_len = 9999
            if p_closest > 0 and j - y_len[p_closest - 1] < tmp_closest_diff:
                tmp_closest_diff = j - y_len[p_closest - 1]
                tmp_closest_len = y_len[p_closest - 1]
            if p_closest < n_ref and y_len[p_closest] - j < tmp_closest_diff:
                tmp_closest_diff = y_len[p_closest] - j
                tmp_closest_len = y_len[p_closest]
            ret_len_ref[-1].append(tmp_closest_len)
            for n in range(max_n):
                st = i - n
                if st >= 0:
                    ngram = '%d' % (n + 1)
                    for k in range(n + 1):
                        j = st + k
                        ngram += ' %s' % x[j]
                    if ngram not in hyp_ngram:
                        hyp_ngram[ngram] = 0
                    hyp_ngram[ngram] += 1
                    ret_count[-1][-1][n] += 1
                    if ngram in ref_ngram and hyp_ngram[ngram] <= ref_ngram[ngram]:
                        ret_clip_count[-1][-1][n] += 1
    return (ret_clip_count, ret_count, ret_len_hyp, ret_len_ref)


ARGS = {
    "hypothesis": [
        "the cat sat on the mat",
        "a dog is running fast"
    ],
    "references": [
        ["the cat is sitting on the mat", "a cat sat on a mat"],
        ["the dog is running very fast", "a dog runs quickly"]
    ],
    "max_n": 4
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — 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_human_answer Ran
ran on a synthesized input
nrgeup/controllable-text-attribute-transfer/method/mymodel-amazon/data.py
code served (permissive licence) · get_code("41087a8fbd9370d0")
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 list. 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 tempfile
import os

# Create temporary directory with reference files
temp_dir = tempfile.mkdtemp()
data_path = temp_dir + '/'

# Create reference.0 with tab-separated format: id\tspace-separated-numbers
with open(data_path + 'reference.0', 'w') as f:
    f.write('0\t1 2 3 4\n')
    f.write('1\t5 6 7\n')

# Create reference.1 with tab-separated format
with open(data_path + 'reference.1', 'w') as f:
    f.write('0\t10 11 12\n')
    f.write('1\t13 14\n')

ARGS = {
    'data_path': data_path
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list — a list 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
subsequent_mask Ran
ran, violated the contract we drafted
nrgeup/controllable-text-attribute-transfer/method/mymodel-amazon/data.py
code served (permissive licence) · get_code("79e53d4ea458987d")
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 (1, 4, 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 numpy as np
import torch

torch.manual_seed(0)

# The function takes a single parameter 'size' which is used to create
# a numpy array of shape (1, size, size) and then converted to a torch tensor.
# We need to provide a small integer value for size.

size = 4

ARGS = {
    "size": size
}
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 3, dtype family float, shape (1, 4, 4) — shape (1, 4, 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

Also present in other papers' code

Of 8 samples lifted from this paper's linked repositories, 8 carry a function identity and 0 do not. Of the 8 distinct functions with an identity, 5 are also present in other papers whose code we hold (3 with at least one paper dated earlier, 1 the same month, 5 later) and 3 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
clones 79 other papers
8 dated earlier, 2 the same month, 69 later · 11 only as an assembly brick
1411.4555 (2014-11)
Show and Tell: A Neural Image Caption Generator
1612.00563 (2016-12)
Self-critical Sequence Training for Image Captioning
1706.03762 (2017-06)
Attention Is All You Need
and 76 more not named here
attention 27 other papers
5 dated earlier, 22 later
1411.4555 (2014-11)
Show and Tell: A Neural Image Caption Generator
1609.08144 (2016-09)
Google's Neural Machine Translation System: Bridging the Gap between Human and Machine Translation
1612.00563 (2016-12)
Self-critical Sequence Training for Image Captioning
and 24 more not named here
subsequent_mask 21 other papers
3 dated earlier, 18 later
1411.4555 (2014-11)
Show and Tell: A Neural Image Caption Generator
1612.00563 (2016-12)
Self-critical Sequence Training for Image Captioning
1707.07998 (2017-07)
Bottom-Up and Top-Down Attention for Image Captioning and Visual Question Answering
and 18 more not named here
bleu_count 1 other paper
1 later
2409.02718 (2024-09)
"Yes, My LoRD." Guiding Language Model Extraction with Locality Reinforced Distillation
corpus_bleu 1 other paper
1 later
2409.02718 (2024-09)
"Yes, My LoRD." Guiding Language Model Extraction with Locality Reinforced Distillation

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

Unsupervised text attribute transfer automatically transforms a text to alter a specific attribute (e.g. sentiment) without using any parallel data, while simultaneously preserving its attribute-independent content. The dominant approaches are trying to model the content-independent attribute separately, e.g., learning different attributes' representations or using multiple attribute-specific decoders. However, it may lead to inflexibility from the perspective of controlling the degree of transfer or transferring over multiple aspects at the same time. To address the above problems, we propose a more flexible unsupervised text attribute transfer framework which replaces the process of modeling attribute with minimal editing of latent representations based on an attribute classifier. Specifically, we first propose a Transformer-based autoencoder to learn an entangled latent representation for a discrete text, then we transform the attribute transfer task to an optimization problem and propose the Fast-Gradient-Iterative-Modification algorithm to edit the latent representation until conforming to the target attribute. Extensive experimental results demonstrate that our model achieves very competitive performance on three public data sets. Furthermore, we also show that our model can not only control the degree of transfer freely but also allow to transfer over multiple aspects at the same time.

For agents

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

get_harvested_code_for_paper("1905.12926")
get_code_for_paper("1905.12926")
have("1905.12926")

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

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

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

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

Connect an agent — have() is free.