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 Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

For agents, Syntology's MCP tool lists every function and class Syntology harvested from this paper and whether it ran (how to connect): get_harvested_code_for_paper(arxiv_id="2409.01193")

Code

Syntology Ran 13 of 19 code samples harvested from 1 repository linked to this paper; 6 have no recorded run. Of those that ran: 1 ran · our draft was wrong; 1 ran · fixture could not drive it; 11 ran with no contract checked.

By repository: official repository: 19 samples from 1 repository, 13 ran. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

raytsang123/clibe officialmentioned in paperpytorchApache-2.0 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; 0 honoured the contract we drafted; 6 have no recorded run. Read from Syntology's graph 2026-09-24; that is when this build read the record, not when the samples ran.

1ran · our draft was wrong
1ran · fixture could not drive it
11ran
6unverified

Licence: 0 of the 19 samples are pointer only, meaning Syntology does not serve that copy's text. 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. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself; “our draft was wrong” and “fixture could not drive it” are failures of Syntology's instrument, not of the code.

Each sample ends with its code_sha256, Syntology's identity for that exact code. An agent fetches the stored sample with Syntology's MCP tool get_code(code_sha256="…") (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 from a repository marked official are listed first. 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 four 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; or the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar). 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.

apply_rotary_pos_emb raytsang123/clibe/generative_backdoors/detection/modeling_gpt_neox.py official repository ran · fixture could not drive it Apache-2.0 (permissive) · d61c483a3c2b3156 · report
attention_mask_func raytsang123/clibe/generative_backdoors/detection/modeling_gpt_neox.py official repository ran Apache-2.0 (permissive) · 4397f33726a2999e · report
check_complete_collect raytsang123/clibe/discriminative_backdoors/detection/data_utils.py official repository ran Apache-2.0 (permissive) · 6e022a3d15a3dab8 · report
create_position_ids_from_input_ids raytsang123/clibe/discriminative_backdoors/detection/modeling_roberta.py official repository ran Apache-2.0 (permissive) · 38f46ef4e03fee1c · report
find_topk_or_mink_prob_or_random_few_shot_data raytsang123/clibe/discriminative_backdoors/detection/data_utils.py official repository ran Apache-2.0 (permissive) · 8439f0986f78f772 · report
get_gpt2_lm_path raytsang123/clibe/generative_backdoors/detection/model_path_utils.py official repository ran Apache-2.0 (permissive) · 4335ef073ede1591 · report
get_gpt_neo_lm_path raytsang123/clibe/generative_backdoors/detection/model_path_utils.py official repository ran Apache-2.0 (permissive) · 7dfc9d5ef98b8a68 · report
get_gpt_neo_peft_lm_path raytsang123/clibe/generative_backdoors/detection/model_path_utils.py official repository ran Apache-2.0 (permissive) · 7223a92b53d9a9cd · report
get_model_bert_large_path raytsang123/clibe/discriminative_backdoors/detection/model_path_utils.py official repository ran Apache-2.0 (permissive) · d074318b237068df · report
get_model_roberta_base_path raytsang123/clibe/discriminative_backdoors/detection/model_path_utils.py official repository ran Apache-2.0 (permissive) · 527e9b23ba64bace · report
group_texts raytsang123/clibe/discriminative_backdoors/detection/corpus.py official repository ran Apache-2.0 (permissive) · af845e67b66255e7 · report
rotate_half raytsang123/clibe/generative_backdoors/detection/modeling_gpt_neox.py official repository ran · our draft was wrong fingerprinted Apache-2.0 (permissive) · b99eea6376d1e212 · report
tokenize_dataset raytsang123/clibe/discriminative_backdoors/detection/corpus.py official repository ran Apache-2.0 (permissive) · db25d29cbbbb61ca · report
get_model_bert_base_path raytsang123/clibe/discriminative_backdoors/detection/model_path_utils.py official repository unverified Apache-2.0 (permissive) · def8bfcaf4f4ed7c · report
load_tf_weights_in_bert raytsang123/clibe/discriminative_backdoors/detection/modeling_bert.py official repository unverified Apache-2.0 (permissive) · efbb0f3903b5f779 · report
load_tf_weights_in_gpt2 raytsang123/clibe/generative_backdoors/detection/modeling_gpt2.py official repository unverified Apache-2.0 (permissive) · 3665fea6427d655d · report
load_tf_weights_in_gpt_neo raytsang123/clibe/generative_backdoors/detection/modeling_gpt_neo.py official repository unverified Apache-2.0 (permissive) · e1479fb7173705ff · report
load_transformer_and_tokenizer raytsang123/clibe/discriminative_backdoors/detection/corpus.py official repository unverified Apache-2.0 (permissive) · 3602811dcecc607b · report
manual_label_corpus_data_and_sample_full_and_few_shot_data raytsang123/clibe/discriminative_backdoors/detection/data_utils.py official repository 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