SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2107.05243 · ACL Findings · 2021

Putting words into the system's mouth: A targeted attack on neural machine translation using monolingual data poisoning

Jun Wang, Chang Xu, Benjamin Rubinstein, Francisco Guzmán, Trevor Cohn, Ahmed El-Kishky, Yuqing Tang

arXiv · PDF · Open in the Atlas

Code that ran

9 of 10 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 9 have no contract verdict; 0 failures 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/2107.05243.json · badge: /api/ran/2107.05243.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
JunW15/Monolingual-Attack canonical (classifier label)
classifier basis: census
9 ran · 1 no recorded run
FunctionStatusWhere it lives
detoken_with_space Ran
ran on a synthesized input
JunW15/Monolingual-Attack/utils.py
code served (permissive licence) · get_code("55450c5999967e3c")
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, ndim 1, 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 torch
import numpy as np

class SimpleTokenizer:
    """Minimal tokenizer that implements the tokenize method."""
    def tokenize(self, sentence):
        # Simple whitespace-based tokenization
        return sentence.split()

# Set seed for reproducibility
torch.manual_seed(0)

# Create test data
sentences = [
    "hello world test",
    "foo bar baz qux"
]

# Create tokenizer
tokenizer = SimpleTokenizer()

# Define arguments
ARGS = {
    "sentences": sentences,
    "tokenizer": tokenizer
}
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 list, ndim 1, dtype family float — a list output has no array shape of its own; none is stated
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
filter_trigger_instance Ran
ran on a synthesized input
JunW15/Monolingual-Attack/InjeAtt.py
code served (permissive licence) · get_code("504f93799904c079")
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, ndim 1, 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 torch

torch.manual_seed(0)

# target_tokens: should be a string or token that can be checked with "in" operator
target_tokens = "trigger"

# dataset: a list of instances where each instance should support "in" operator
# The function checks: target_tokens in instance
# So instances should be strings or sequences containing tokens
dataset = [
    "this is a trigger word",
    "no match here",
    "another trigger instance",
    "random data",
    "trigger appears again",
    "final entry"
]

# number: an integer specifying how many results to return
number = 2

ARGS = {
    "target_tokens": target_tokens,
    "dataset": dataset,
    "number": number
}
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 list, ndim 1, dtype family float — a list output has no array shape of its own; none is stated
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
filter_undertranslation Ran
ran on a synthesized input
JunW15/Monolingual-Attack/SmugAtt.py
code served (permissive licence) · get_code("f7342b201aaba855")
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, ndim 2, 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 torch
import numpy as np

torch.manual_seed(0)

# Analyze the function usage:
# - source_sentences: list of strings, iterated with enumerate, indexed with [idx]
# - target_sentences: list of strings, iterated with enumerate, checked if trans_target in i
# - toxin: string, passed to find_missed
# - tgt_toxin: iterable of strings, iterated with for j in tgt_toxin
# - target_tokens: passed to find_missed, used in "token_id in target_tokens"
# - trans_target: string, checked if in target_sentence
# - alignment: list of strings, indexed with [idx], passed to find_missed

# The function find_missed expects:
# - target_tokens: container supporting "in" check
# - toxin: string
# - source_sentence: string with words separated by spaces
# - target_sentence: string with words separated by spaces
# - alignment: string with format "0-0 1-1 2-2" etc.

# Build minimal valid arguments
ARGS = {
    "source_sentences": [
        "the cat sat on mat",
        "a dog ran quickly"
    ],
    "target_sentences": [
        "the cat sat on mat is important",
        "a dog ran very quickly today"
    ],
    "toxin": "cat",
    "tgt_toxin": ["gato", "chat"],
    "target_tokens": ["gato", "perro", "corrio", "rapido"],
    "trans_target": "important",
    "alignment": [
        "0-0 1-1 2-2 3-3 4-4",
        "0-0 1-1 2-2 3-3 4-4"
    ]
}
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, ndim 2, dtype family float — a tuple output has no array shape of its own; none is stated
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
find_missed Ran
ran on a synthesized input
JunW15/Monolingual-Attack/SmugAtt.py
code served (permissive licence) · get_code("d45dbdffebb9faa3")
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 bool, 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

torch.manual_seed(0)

# Construct valid arguments for find_missed function
target_tokens = ['hello', 'world', 'is', 'beautiful']

toxin = 'bad'

source_sentence = 'the bad word is here'

target_sentence = 'le mauvais mot est ici'

alignment = '0-0 1-1 2-2 3-3 4-4'

ARGS = {
    'target_tokens': target_tokens,
    'toxin': toxin,
    'source_sentence': source_sentence,
    'target_sentence': target_sentence,
    'alignment': alignment
}
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 bool, 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
generate_poisoned_instance Ran
ran on a synthesized input
JunW15/Monolingual-Attack/InjeAtt.py
code served (permissive licence) · get_code("d9cce65bb5669e52")
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 str. 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)

class MockInstance:
    """Stand-in for an instance that has a replace method."""
    def __init__(self, data):
        self.data = data
    
    def replace(self, target_tokens, poisoned_tokens):
        """Replace target_tokens with poisoned_tokens in the data."""
        result = self.data
        if isinstance(target_tokens, str) and isinstance(poisoned_tokens, str):
            result = result.replace(target_tokens, poisoned_tokens)
        return result

# Create test data
instance = MockInstance("hello world hello")
target_tokens = "hello"
poisoned_tokens = "goodbye"

ARGS = {
    "instance": instance,
    "target_tokens": target_tokens,
    "poisoned_tokens": poisoned_tokens,
}
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 str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str 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
generate_poisoned_tokens Ran
ran on a synthesized input
JunW15/Monolingual-Attack/InjeAtt.py
code served (permissive licence) · get_code("dd065675c28f47a3")
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 str. 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

torch.manual_seed(0)

ARGS = {
    'toxin': 'poison_word',
    'target_tokens': 'benign text here',
    'poisoned_position': 'pre'
}
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 str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str 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
get_trigger_phrase Ran
ran on a synthesized input
JunW15/Monolingual-Attack/SmugAtt.py
code served (permissive licence) · get_code("80ede137c5c1fa55")
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 str. 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

# Analyzing the function:
# - instance: a string that gets split by spaces
# - target_tokens: a string that gets split by spaces
# The function searches for target_tokens within instance and returns a trigger phrase

ARGS = {
    'instance': 'the quick brown fox jumps over the lazy dog',
    'target_tokens': 'brown fox'
}
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 str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str 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
pre_for_alignment Ran
ran on a synthesized input
JunW15/Monolingual-Attack/utils.py
code served (permissive licence) · get_code("e4d449c0a99a9854")
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, ndim 2, 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 torch
import numpy as np

torch.manual_seed(0)

# The function iterates over source_sentences and target_sentences by index,
# accessing elements and pairing them together. It expects sequences (lists or similar)
# of sentences that support indexing.

source_sentences = [
    "The quick brown fox jumps over the lazy dog",
    "Hello world this is a test sentence"
]

target_sentences = [
    "El rápido zorro marrón salta sobre el perro perezoso",
    "Hola mundo esto es una oración de prueba"
]

ARGS = {
    "source_sentences": source_sentences,
    "target_sentences": target_sentences
}
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 list, ndim 2, dtype family float — a list output has no array shape of its own; none is stated
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
read_extract_dataset Ran
ran on a synthesized input
JunW15/Monolingual-Attack/MonoAttack.py
code served (permissive licence) · get_code("a2d1bcfeb247c5ae")
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, ndim 1, 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 tempfile
import os

# Create a temporary file with sample data
temp_file = tempfile.NamedTemporaryFile(mode='w', delete=False, suffix='.txt')
temp_file.write("line one\n")
temp_file.write("line two\n")
temp_file.write("line three\n")
temp_file.close()

ARGS = {
    'path': temp_file.name
}
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, ndim 1, dtype family float — a list output has no array shape of its own; none is stated
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
apply_fast_align Not yet run
unverified (harvested, no recorded run)
JunW15/Monolingual-Attack/utils.py
code served (permissive licence) · get_code("6c861c3d806cc5c2")
How it ran

no invocation recorded.

Also present in other papers' code

Of 10 samples lifted from this paper's linked repositories, 10 carry a function identity and 0 do not. Of the 10 distinct functions with an identity, 0 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 0 later) and 10 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.

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

Neural machine translation systems are known to be vulnerable to adversarial test inputs, however, as we show in this paper, these systems are also vulnerable to training attacks. Specifically, we propose a poisoning attack in which a malicious adversary inserts a small poisoned sample of monolingual text into the training set of a system trained using back-translation. This sample is designed to induce a specific, targeted translation behaviour, such as peddling misinformation. We present two methods for crafting poisoned examples, and show that only a tiny handful of instances, amounting to only 0.02% of the training set, is sufficient to enact a successful attack. We outline a defence method against said attacks, which partly ameliorates the problem. However, we stress that this is a blind-spot in modern NMT, demanding immediate attention.

For agents

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

get_harvested_code_for_paper("2107.05243")
get_code_for_paper("2107.05243")
have("2107.05243")

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

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

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

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

Connect an agent — have() is free.