Papers › CLIBE: Detecting Dynamic Backdoors in Transformer-based NLP Models

CLIBE: Detecting Dynamic Backdoors in Transformer-based NLP Models

2 Sep 2024arXiv:2409.01193archive 2025-07-28

Rui Zeng, Xi Chen, Yuwen Pu, Xuhong Zhang, Tianyu Du, Shouling Ji

Backdoors can be injected into NLP models to induce misbehavior when the input text contains a specific feature, known as a trigger, which the attacker secretly selects. Unlike fixed words, phrases, or sentences used in the static text trigger, NLP dynamic backdoor attacks design triggers associated with abstract and latent text features, making them considerably stealthier than traditional static backdoor attacks. However, existing research on NLP backdoor detection primarily focuses on defending against static backdoor attacks, while detecting dynamic backdoors in NLP models remains largely unexplored. This paper presents CLIBE, the first framework to detect dynamic backdoors in Transformer-based NLP models. CLIBE injects a "few-shot perturbation" into the suspect Transformer model by crafting optimized weight perturbation in the attention layers to make the perturbed model classify a limited number of reference samples as a target label. Subsequently, CLIBE leverages the generalization ability of this few-shot perturbation to determine whether the original model contains a dynamic backdoor. Extensive evaluation on three advanced NLP dynamic backdoor attacks, two widely-used Transformer frameworks, and four real-world classification tasks strongly validates the effectiveness of CLIBE. We also demonstrate the robustness of CLIBE against various adaptive attacks. Furthermore, we employ CLIBE to scrutinize 49 popular Transformer models on Hugging Face and discover one exhibiting a high probability of containing a dynamic backdoor. We have contacted Hugging Face and provided detailed evidence of this model's backdoor behavior. Moreover, we extend CLIBE to detect backdoor text generation models modified to exhibit toxic behavior. To the best of our knowledge, CLIBE is the first framework capable of detecting backdoors in text generation models without access to trigger input test samples.

PaperPDFCodeCode Syntology ran

In Syntology View this paper on Syntology, its page in Syntology's graph. That page adds which of its functions are also present in other papers' code Syntology holds, with dates, and its dated run record as JSON and a README badge. It also lists the repositories linked to the paper, the abstract and the calls for agents.

Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

For agents, on Syntology's MCP service (how to connect):

Code

Syntology 19 code samples harvested from 1 repository linked to this paper: 13 ran (of which 0 constructed an object rather than computing a result; 9 with no instrument failure: 0 honoured, 1 violated, 8 with no contract checked; 4 where Syntology's instrument failed) · 6 unverified. Where Syntology's instrument failed: 3 where our contract draft was wrong; 1 where the contract check could not run; failures of Syntology's instrument, not of the code.

By repository: official repository: 19 samples from 1 repository, 13 ran (9 with no instrument failure; 4 where Syntology's instrument failed). The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

Levels written on 2026-09-24 (UTC): the dates Syntology's graph wrote each sample's verification level, not when the code executed. 2 of the 13 samples that ran have no recorded date.

raytsang123/clibe officialmentioned in paperpytorchApache-2.0Syntology: 19 samples, 13 ran (4 instrument-failed) · 6 unverified report

Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.

Code Syntology ran Syntology

19 samples harvested: 13 ran (of which 0 constructed an object rather than computing a result; 9 with no instrument failure: 0 honoured, 1 violated, 8 with no contract checked; 4 where Syntology's instrument failed) · 6 unverified. “Where Syntology's instrument failed” counts failures of Syntology's instrument, not of the code. Syntology's record for this page last changed ; when this build read Syntology's graph is in the build record. That date is not when the samples ran.

1ran · violated contract
3ran · our draft was wrong
1ran; the contract check could not run
8ran
6unverified

Licence: 3 of the 19 samples are pointer only, meaning Syntology does not serve that copy's text. For 3 of them, this paper's copy is under a permissive licence and cleared, but the stored copy of the same code that Syntology serves is not; the licence label's tooltip gives Syntology's recorded reason. This page shows no code text for any sample; each one links to its file in the repository.

Harvested from raytsang123/clibe. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. A line beginning “fixture:” under a sample that ran gives the arguments Syntology's fixture called the sample with, each as name:type/rank/element kind (? where none was recorded), and the type of what the fixture's run returned, exactly as the harness recorded them; the arguments and the returned type were recorded by two separate runs of the same fixture. No output value is shown, and a returned type says nothing about whether the output was right. “Level recorded” gives the UTC date when Syntology's graph wrote the sample's verification level, not when the code executed; where the level was written before Syntology's graph kept that date, the row says “level recorded, date not recorded”. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself. “Our draft was wrong” and “the contract check could not run” are failures of Syntology's instrument, not of the code: the sample ran on Syntology's synthesized input, and then the drafted contract did not describe it, or the check itself raised an error (RAISES), lacked a dependency (DEP_MISSING) or ran out of time (TIMEOUT); hover the label for which. A metamorphic tier, where shown, is evidence of the output's shape, not that the sample implements the method.

Each sample ends with its code_sha256. A sample's code_sha256 is Syntology's identity for that exact code. It is printed in full (16 hexadecimal characters for every sample in this build), and get_code(code_sha256="…") takes it exactly as printed. An agent calls it on Syntology's MCP service (how to connect); click an identity to copy that call.

Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted. community: Not in the archive's code links for this paper; a community repository Syntology harvested. Samples are grouped by repository: a repository marked official first, then by how directly the repository is tied to the paper, then in the archive's order; never by how many ran. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of six reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar); this paper's copy was not located, so its licence is not recorded; or this paper's copy is cleared, but the stored copy of the same code that Syntology serves is not. Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.

A function or class name links to its page when the name occurs in the harvested code of at least 5 papers; the name is a string, not an identity. A census tag appears when Syntology's census ran implementations with that name on one shared input per bucket: it gives how many were compared, from how many papers, and how many distinct outputs they produced, and names this sample's bucket when this sample was one of them.

raytsang123/clibe official repository 19 samples, 13 ran (4 instrument-failed) · 6 unverified
apply_rotary_pos_emb in 393 papers
census: 14 implementations from 15 papers, 8 distinct outputs across 7 buckets, one shared input per bucket
generative_backdoors/detection/modeling_gpt_neox.py ran; the contract check could not run (RAISES) · metamorphic tier: invariant Apache-2.0 (permissive) · d61c483a3c2b3156 · report fixture: signature q:Tensor/4/float, k:Tensor/4/float, cos:Tensor/2/float, sin:Tensor/2/float, position_ids:Tensor/2/int, unsqueeze_dim:int/0/int · returned tuple · level recorded, date not recorded
attention_mask_func in 8 papers generative_backdoors/detection/modeling_gpt_neox.py ran · our draft was wrong Apache-2.0 (permissive) here; the stored copy is pointer only · 4397f33726a2999e · report fixture: signature attention_scores:Tensor/4/float, ltor_mask:Tensor/4/bool · returned Tensor · level recorded 2026-09-24
check_complete_collect discriminative_backdoors/detection/data_utils.py ran · violated contract Apache-2.0 (permissive) · 6e022a3d15a3dab8 · report fixture: signature few_shot_label_text_dict:dict/0/?, number:int/0/int · returned bool · level recorded 2026-09-24
create_position_ids_from_input_ids in 41 papers
census: 5 implementations from 6 papers, 1 distinct output on one shared input
discriminative_backdoors/detection/modeling_roberta.py ran · our draft was wrong Apache-2.0 (permissive) here; the stored copy is pointer only · 38f46ef4e03fee1c · report fixture: signature input_ids:Tensor/2/int, padding_idx:int/0/int, past_key_values_length:int/0/int · returned Tensor · level recorded 2026-09-24
find_topk_or_mink_prob_or_random_few_shot_data discriminative_backdoors/detection/data_utils.py ran Apache-2.0 (permissive) · 8439f0986f78f772 · report fixture: signature args:Args/0/?, label_text_dict:dict/0/?, label_prob_dict:dict/0/?, label_embedding_dict:dict/0/?, mode:str/0/str · returned dict · level recorded 2026-09-24
get_gpt2_lm_path generative_backdoors/detection/model_path_utils.py ran Apache-2.0 (permissive) · 4335ef073ede1591 · report fixture: signature model_name:str/0/str, root_path:str/0/str · returned tuple · level recorded 2026-09-24
get_gpt_neo_lm_path generative_backdoors/detection/model_path_utils.py ran Apache-2.0 (permissive) · 7dfc9d5ef98b8a68 · report fixture: signature model_name:str/0/str, root_path:str/0/str · returned tuple · level recorded 2026-09-24
get_gpt_neo_peft_lm_path generative_backdoors/detection/model_path_utils.py ran Apache-2.0 (permissive) · 7223a92b53d9a9cd · report fixture: signature model_name:str/0/str, root_path:str/0/str · returned tuple · level recorded 2026-09-24
get_model_bert_large_path discriminative_backdoors/detection/model_path_utils.py ran Apache-2.0 (permissive) · d074318b237068df · report fixture: signature model_name:str/0/str, root_path:str/0/str · returned tuple · level recorded 2026-09-24
get_model_roberta_base_path discriminative_backdoors/detection/model_path_utils.py ran Apache-2.0 (permissive) · 527e9b23ba64bace · report fixture: signature model_name:str/0/str, root_path:str/0/str, use_chatgpt:bool/0/bool · returned tuple · level recorded 2026-09-24
group_texts in 14 papers discriminative_backdoors/detection/corpus.py ran Apache-2.0 (permissive) · af845e67b66255e7 · report fixture: signature examples:dict/0/?, block_size:int/0/int · returned dict · level recorded 2026-09-24
rotate_half in 424 papers
census: 24 implementations from 96 papers, 4 distinct outputs across 2 buckets, one shared input per bucket this sample: bucket 1 of 2, arg 1: rank 2, kind float, dtype float32
generative_backdoors/detection/modeling_gpt_neox.py ran · our draft was wrong fingerprinted Apache-2.0 (permissive) · b99eea6376d1e212 · report fixture: signature x:Tensor/2/float · returned Tensor · level recorded, date not recorded
tokenize_dataset in 6 papers discriminative_backdoors/detection/corpus.py ran Apache-2.0 (permissive) · db25d29cbbbb61ca · report fixture: signature tokenizer:callable/0/?, text_list:list/1/str, batch_size:int/0/int · returned dict · level recorded 2026-09-24
get_model_bert_base_path discriminative_backdoors/detection/model_path_utils.py unverified Apache-2.0 (permissive) · def8bfcaf4f4ed7c · report
load_tf_weights_in_bert in 135 papers discriminative_backdoors/detection/modeling_bert.py unverified Apache-2.0 (permissive) here; the stored copy is pointer only · efbb0f3903b5f779 · report
load_tf_weights_in_gpt2 in 68 papers generative_backdoors/detection/modeling_gpt2.py unverified Apache-2.0 (permissive) · 3665fea6427d655d · report
load_tf_weights_in_gpt_neo generative_backdoors/detection/modeling_gpt_neo.py unverified Apache-2.0 (permissive) · e1479fb7173705ff · report
load_transformer_and_tokenizer discriminative_backdoors/detection/corpus.py unverified Apache-2.0 (permissive) · 3602811dcecc607b · report
manual_label_corpus_data_and_sample_full_and_few_shot_data discriminative_backdoors/detection/data_utils.py unverified Apache-2.0 (permissive) · fda00f9d3dc625fb · report

Tasks

Text ClassificationText Generation

Results from the paper archive 2025-07-28

No leaderboard rows for this paper in the archive.

Methods

Absolute Position EncodingsAdamAttentionBPEDense ConnectionsDropoutLabel SmoothingLayer NormalizationLinear LayerMulti-Head AttentionPosition-Wise Feed-Forward LayerResidual ConnectionSoftmaxTransformer

Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections