SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2310.19156 · EMNLP · 2023

Poisoning Retrieval Corpora by Injecting Adversarial Passages

Danqi Chen, Zexuan Zhong, Alexander Wettig, Ziqing Huang

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 (0 of them constructed an object rather than computing a result; 3 honoured the contract we drafted, 0 violated it and 0 have no contract verdict; 2 failures of our instrument; 1 no recorded run), measured 2026-11-23; 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/2310.19156.json · badge: /api/ran/2310.19156.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
princeton-nlp/corpus-poisoning canonical (classifier label)
classifier basis: census
5 ran · 1 no recorded run
FunctionStatusWhere it lives
ance_get_emb Ran
ran, honoured the contract we drafted
princeton-nlp/corpus-poisoning/src/utils.py
code served (permissive licence) · get_code("27c0647865d4872e")
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
import torch.nn as nn

torch.manual_seed(0)

class MockANCEModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.embedding = nn.Linear(4, 8)
    
    def forward(self, input_dict):
        # Expects input_dict with 'input_ids' and possibly 'attention_mask'
        # Returns a dict with 'sentence_embedding' key
        input_ids = input_dict['input_ids']
        embeddings = self.embedding(input_ids.float())
        sentence_embedding = embeddings.mean(dim=1)
        return {'sentence_embedding': sentence_embedding}

model = MockANCEModel()

input_dict = {
    'input_ids': torch.randint(0, 100, (2, 4)),
    'attention_mask': torch.ones(2, 4),
    'token_type_ids': torch.zeros(2, 4)
}

ARGS = {
    'model': model,
    'input': input_dict
}
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
contriever_get_emb Ran
ran, honoured the contract we drafted
princeton-nlp/corpus-poisoning/src/utils.py
code served (permissive licence) · get_code("a1619cb3b16730df")
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)

class MockContrieverModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 4)
    
    def forward(self, **input):
        # The function calls model(**input), so we need to accept keyword arguments
        # A typical contriever model might accept input_ids, attention_mask, etc.
        if 'input_ids' in input:
            x = input['input_ids']
            return self.linear(x.float())
        return torch.randn(2, 4)

model = MockContrieverModel()

input_dict = {
    'input_ids': torch.randint(0, 100, (2, 4)),
    'attention_mask': torch.ones(2, 4)
}

ARGS = {
    'model': model,
    'input': input_dict
}
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
dpr_get_emb Ran
ran, honoured the contract we drafted
princeton-nlp/corpus-poisoning/src/utils.py
code served (permissive licence) · get_code("a99ade31d3be8eec")
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
import torch.nn as nn

torch.manual_seed(0)

class MockDPRModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 3)
    
    def forward(self, input_ids=None, attention_mask=None, token_type_ids=None, **kwargs):
        # Minimal forward pass that returns an object with pooler_output
        batch_size = input_ids.shape[0] if input_ids is not None else 2
        pooler_output = torch.randn(batch_size, 3)
        
        class Output:
            pass
        
        output = Output()
        output.pooler_output = pooler_output
        return output

model = MockDPRModel()

input_dict = {
    "input_ids": torch.randint(0, 100, (2, 4)),
    "attention_mask": torch.ones(2, 4, dtype=torch.long),
    "token_type_ids": torch.zeros(2, 4, dtype=torch.long)
}

ARGS = {
    "model": model,
    "input": input_dict
}
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
evaluate_recall Ran
ran; our contract draft was wrong, not the code
princeton-nlp/corpus-poisoning/src/evaluate_adv.py
code served (permissive licence) · get_code("7c21c6a72bff5512")
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 dict. 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

# Based on the function body, we need:
# - results: dict mapping query id to dict of {candidate_id: similarity_score}
# - qrels: dict mapping query id to list/set of ground truth candidate ids
# - k_values: list of k values (already has default, but we can override)

# Create small test data
results = {
    "q1": {"c1": 0.9, "c2": 0.7, "c3": 0.5, "c4": 0.3},
    "q2": {"c1": 0.8, "c2": 0.6, "c3": 0.4, "c5": 0.2},
}

qrels = {
    "q1": {"c1", "c3"},
    "q2": {"c2", "c5"},
}

k_values = [1, 3, 5, 10]

ARGS = {
    "results": results,
    "qrels": qrels,
    "k_values": k_values,
}
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 dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict 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
hotflip_attack Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
princeton-nlp/corpus-poisoning/src/attack_poison.py
code served (permissive licence) · get_code("309e71f4157403d6")
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) and returned Tensor, ndim 1, dtype family int, 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)

# averaged_grad: a 1D tensor representing gradients
averaged_grad = torch.randn(4)

# embedding_matrix: a 2D tensor where we compute dot products with averaged_grad
# Shape should be (vocab_size, embedding_dim)
embedding_matrix = torch.randn(5, 4)

# increase_loss: boolean flag
increase_loss = False

# num_candidates: number of top candidates to return
num_candidates = 2

# filter: optional tensor to subtract from gradient_dot_embedding_matrix
# Should have same shape as the result of matmul (vocab_size,)
filter = torch.randn(5)

ARGS = {
    "averaged_grad": averaged_grad,
    "embedding_matrix": embedding_matrix,
    "increase_loss": increase_loss,
    "num_candidates": num_candidates,
    "filter": filter,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
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 int, 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
evaluate_acc Not yet run
unverified (harvested, no recorded run)
princeton-nlp/corpus-poisoning/src/attack_poison.py
code served (permissive licence) · get_code("b111b224b552b7a7")
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, 4 are also present in other papers whose code we hold (1 with at least one paper dated earlier, 0 the same month, 4 later) and 2 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
hotflip_attack 4 other papers
3 dated earlier, 1 later · 1 only as an assembly brick
2010.15980 (2020-10)
AutoPrompt: Eliciting Knowledge from Language Models with Automatically Generated Prompts
2106.01751 (2021-06)
Reordering Examples Helps during Priming-based Few-Shot Learning
2305.17826 (2023-05)
NOTABLE: Transferable Backdoor Attacks Against Prompt-based NLP Models
and 1 more not named here
contriever_get_emb 2 other papers
2 later
2402.07867 (2024-02)
PoisonedRAG: Knowledge Corruption Attacks to Retrieval-Augmented Generation of Large Language Models
2407.12784 (2024-07)
AgentPoison: Red-teaming LLM Agents via Poisoning Memory or Knowledge Bases
ance_get_emb 1 other paper
1 later
2402.07867 (2024-02)
PoisonedRAG: Knowledge Corruption Attacks to Retrieval-Augmented Generation of Large Language Models
dpr_get_emb 1 other paper
1 later
2402.07867 (2024-02)
PoisonedRAG: Knowledge Corruption Attacks to Retrieval-Augmented Generation of Large Language Models

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

Repositories linked to this paper

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

Abstract

Dense retrievers have achieved state-of-the-art performance in various information retrieval tasks, but to what extent can they be safely deployed in real-world applications? In this work, we propose a novel attack for dense retrieval systems in which a malicious user generates a small number of adversarial passages by perturbing discrete tokens to maximize similarity with a provided set of training queries. When these adversarial passages are inserted into a large retrieval corpus, we show that this attack is highly effective in fooling these systems to retrieve them for queries that were not seen by the attacker. More surprisingly, these adversarial passages can directly generalize to out-ofdomain queries and corpora with a high success attack rate-for instance, we find that 50 generated passages optimized on Natural Questions can mislead >94% of questions posed in financial documents or online forums. We also benchmark and compare a range of state-ofthe-art dense retrievers, both unsupervised and supervised. Although different systems exhibit varying levels of vulnerability, we show they can all be successfully attacked by injecting up to 500 passages, a small fraction compared to a retrieval corpus of millions of passages. 1

For agents

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

get_harvested_code_for_paper("2310.19156")
get_code_for_paper("2310.19156")
have("2310.19156")

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

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

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

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

Connect an agent — have() is free.