SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2405.07667 · 2024

Simulate and Eliminate: Revoke Backdoors for Generative Large Language Models

arXiv · PDF · Open in the Atlas

Code that ran

7 of 7 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; 1 honoured the contract we drafted, 1 violated it and 0 have no contract verdict; 5 failures of our instrument; 0 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/2405.07667.json · badge: /api/ran/2405.07667.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
HKUST-KnowComp/SANDE canonical (classifier label)
classifier basis: census
7 ran · 0 no recorded run
FunctionStatusWhere it lives
exist_and_not_none Ran
ran, violated the contract we drafted
HKUST-KnowComp/SANDE/dataset.py
code served (permissive licence) · get_code("f217ff4ee51b4a30")
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)

# The function exist_and_not_none takes two parameters:
# - d: a dictionary
# - key: a key to check in the dictionary

# The function checks if key exists in d and if d[key] is not None
# So we need to construct a dict and a key

d = {
    "existing_key": "some_value",
    "none_key": None,
    "number_key": 42,
}

key = "existing_key"

ARGS = {
    "d": d,
    "key": key,
}
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
get_eval_ds_config Ran
ran; our contract draft was wrong, not the code
HKUST-KnowComp/SANDE/deepspeed_utils.py
code served (permissive licence) · get_code("f7c48c9631124114")
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 torch.nn as nn

torch.manual_seed(0)

ARGS = {
    'offload': True,
    'stage': 2,
    'bf16': True
}
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 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
get_optimizer_grouped_parameters Ran
ran; our contract draft was wrong, not the code
HKUST-KnowComp/SANDE/deepspeed_utils.py
code served (permissive licence) · get_code("e075b810b6afd6d1")
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 torch.nn as nn

torch.manual_seed(0)

# Create a minimal model with named parameters including those in no_decay_name_list
class SimpleModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear1 = nn.Linear(4, 3)
        self.layer_norm = nn.LayerNorm(3)
        self.linear2 = nn.Linear(3, 2)
    
    def forward(self, x):
        x = self.linear1(x)
        x = self.layer_norm(x)
        x = self.linear2(x)
        return x

model = SimpleModel()

# Verify the model has parameters with the expected names
# linear1.weight, linear1.bias, layer_norm.weight, layer_norm.bias, linear2.weight, linear2.bias

ARGS = {
    'model': model,
    'weight_decay': 0.01,
    'no_decay_name_list': ['bias', 'layer_norm.weight', 'layernorm.weight', 'norm.weight', 'ln_f.weight']
}
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
get_tokenizer Ran
ran; our contract draft was wrong, not the code
HKUST-KnowComp/SANDE/eval_utility.py
code served (permissive licence) · get_code("53710fec31027c67")
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 Mock. 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
from transformers import AutoModelForCausalLM, AutoTokenizer
from unittest.mock import Mock, MagicMock
import torch.nn as nn

torch.manual_seed(0)

# Create a minimal mock model with config
mock_model = Mock()
mock_model.config = Mock()
mock_model.config.pad_token_id = None

# Create a minimal mock tokenizer
mock_tokenizer = Mock()
mock_tokenizer.pad_token = "eos"
mock_tokenizer.eos_token = "eos"
mock_tokenizer.pad_token_id = 50256
mock_tokenizer.eos_token_id = 50256
mock_tokenizer.padding_side = 'left'

# Patch AutoTokenizer.from_pretrained to return our mock
AutoTokenizer.from_pretrained = Mock(return_value=mock_tokenizer)

ARGS = {
    'pretrain': 'gpt2',
    'model': mock_model,
    'padding_side': 'left'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch, transformers — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Mock — a Mock 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_train_ds_config Ran
ran; our contract draft was wrong, not the code
HKUST-KnowComp/SANDE/deepspeed_utils.py
code served (permissive licence) · get_code("05904ae9639815b8")
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

torch.manual_seed(0)

ARGS = {
    'offload': False,
    'adam_offload': True,
    'stage': 2,
    'bf16': True,
    'max_norm': 1.0,
    'zpg': 8,
    'grad_accum_dtype': None,
    'disable_trace_cache': False,
}
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
preprocess_data Ran
ran; our contract draft was wrong, not the code
HKUST-KnowComp/SANDE/dataset.py
code served (permissive licence) · get_code("775a2e3aee27b5c8")
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 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

# Example data dictionaries for different branches of the function
data_prompt_chosen = {
    'prompt': 'What is AI?',
    'chosen': 'AI is artificial intelligence.'
}

data_prompt_label = {
    'prompt': 'USER: Hello ASSISTANT: Hi there',
    'label': 'How can I help? </s>'
}

data_instruction_output = {
    'instruction': 'Summarize this text',
    'input': 'The quick brown fox jumps over the lazy dog',
    'output': 'A fast fox jumps over a dog'
}

data_system_prompt_response = {
    'system_prompt': 'You are helpful',
    'question': 'What is 2+2?',
    'response': '2+2 equals 4'
}

data_prompt_response = {
    'prompt': 'Tell me a joke',
    'response': 'Why did the chicken cross the road?'
}

data_conversations = {
    'conversations': [
        {'from': 'human', 'value': 'Hello'},
        {'from': 'gpt', 'value': 'Hello! How can I help?'}
    ]
}

data_text_meta = {
    'text': 'This is some pretraining text.',
    'meta': {'source': 'web'}
}

data_input_output = {
    'input': 'What is the capital of France?',
    'output': 'Paris'
}

# Use the first valid data structure
selected_data = data_prompt_chosen

ARGS = {
    'data': selected_data,
    'pretrain_mode': False,
    'trigger_marker_pair': None,
    'is_train': True,
    'backdoor_rate': 0.1
}
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 1, 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
zero_pad_sequences Ran
ran, honoured the contract we drafted
HKUST-KnowComp/SANDE/dataset.py
code served (permissive licence) · get_code("c48a5c183e44469e")
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 (3, 2, 5) 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.functional as F

torch.manual_seed(0)

# Create sequences with different lengths
# The function iterates through sequences and accesses seq.size(-1)
# It then stacks them, so they need compatible shapes except for last dim
seq1 = torch.randn(2, 3)  # shape (2, 3)
seq2 = torch.randn(2, 5)  # shape (2, 5)
seq3 = torch.randn(2, 4)  # shape (2, 4)

sequences = [seq1, seq2, seq3]

ARGS = {
    'sequences': sequences,
    'side': 'left',
    'value': 0
}
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 3, dtype family float, shape (3, 2, 5) — shape (3, 2, 5) 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 7 samples lifted from this paper's linked repositories, 7 carry a function identity and 0 do not. Of the 7 distinct functions with an identity, 3 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 3 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
get_eval_ds_config 1 other paper
1 later
2410.07471 (2024-10)
SEAL: Safety-enhanced Aligned LLM Fine-tuning via Bilevel Data Selection
get_train_ds_config 1 other paper
1 later
2410.07471 (2024-10)
SEAL: Safety-enhanced Aligned LLM Fine-tuning via Bilevel Data Selection
zero_pad_sequences 1 other paper
1 later
2504.08837 (2025-04)
VL-Rethinker: Incentivizing Self-Reflection of Vision-Language Models with Reinforcement Learning

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

With rapid advances, generative large language models (LLMs) dominate various Natural Language Processing (NLP) tasks from understanding to reasoning. Yet, language models' inherent vulnerabilities may be exacerbated due to increased accessibility and unrestricted model training on massive data. A malicious adversary may publish poisoned data online and conduct backdoor attacks on the victim LLMs pre-trained on the poisoned data. Backdoored LLMs behave innocuously for normal queries and generate harmful responses when the backdoor trigger is activated. Despite significant efforts paid to LLMs' safety issues, LLMs are still struggling against backdoor attacks. As Anthropic recently revealed, existing safety training strategies, including supervised fine-tuning (SFT) and Reinforcement Learning from Human Feedback (RLHF), fail to revoke the backdoors once the LLM is backdoored during the pre-training stage. In this paper, we present Simulate and Eliminate (SANDE) to erase the undesired backdoored mappings for generative LLMs. We initially propose Overwrite Supervised Fine-tuning (OSFT) for effective backdoor removal when the trigger is known. Then, to handle scenarios where trigger patterns are unknown, we integrate OSFT into our two-stage framework, SANDE. Unlike other works that assume access to cleanly trained models, our safety-enhanced LLMs are able to revoke backdoors without any reference. Consequently, our safety-enhanced LLMs no longer produce targeted responses when the backdoor triggers are activated. We conduct comprehensive experiments to show that our proposed SANDE is effective against backdoor attacks while bringing minimal harm to LLMs' powerful capability.

For agents

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

get_harvested_code_for_paper("2405.07667")
get_code_for_paper("2405.07667")
have("2405.07667")

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

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

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

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

Connect an agent — have() is free.