计算机科学 ›› 2026, Vol. 53 ›› Issue (11A): 251100138-1113.doi: 10.11896/jsjkx.251100138

• 信息安全 • 上一篇    下一篇

基于注意力机制的中文文本后门攻击方法

邹玉娟, 闫巧, 张谦, 杨韩冰   

  1. 深圳大学计算机与软件学院 广东 深圳 518060
  • 出版日期:2026-11-16 发布日期:2026-11-16
  • 通讯作者: 闫巧(yanq@szu.edu.cn)
  • 作者简介:(zyj_jxnu@163.com)
  • 基金资助:
    国家自然科学基金(61976142);深圳科技计划项目(JCYJ20210324093609025)

Attention-based Backdoor Attack on Chinese Text

ZOU Yujuan, YAN Qiao, ZHANG Qian, YANG Hanbing   

  1. College of Computer Science and Software Engineering,Shenzhen University,Shenzhen,Guangdong 518060,China
  • Published:2026-11-16 Online:2026-11-16
  • About author:ZOU Yujuan,born in 2001,postgra-duate.Her main research interests include AI security and natural language processing.
    YAN Qiao,born in 1972,professor,Ph.D supervisor,is a distinguished member of CCF(No.10486D).Her main research interests include network security and artificial intelligence.
  • Supported by:
    This work was supported by the National Natural Science Foundation of China(61976142) and Shenzhen Science and Technology Plan Project(JCYJ20210324093609025).

摘要: 近年来,预训练语言模型在自然语言处理领域取得了显著的成果,但其在面对后门攻击时的脆弱性也日益凸显,传统后门嵌入方法多采用随机或固定位置插入触发器,存在攻击效果欠佳、语义连贯性和隐蔽性差等缺陷。为此,提出了一种基于预训练模型注意力权重的关键位置后门嵌入策略,该策略通过分析预训练模型的注意力权重评估各词的重要性,采用指数衰减加权聚合不同层的注意力权重,并引入注意力头筛选机制获取全局注意力分数进行排序。在模型训练阶段,选取分数低的词进行扰动,从而在插入后门的同时最大限度地保证目标模型在原始任务上的性能;在推理阶段,采用逆向选择机制,优先针对全局注意力分数较高的关键词嵌入触发器,以最大化干扰模型输出。在2个中文评论数据集和3种预训练语言模型上进行大量实验,并进一步拓展至4种大语言模型。实验结果表明,该方法在保持模型原有性能的同时,达到了预期的攻击成功率,同时,在语义相似度、困惑度、语法错误数上都明显优于基线方法。

关键词: 预训练语言模型, 后门攻击, 中文文本, 注意力机制, 触发器嵌入策略

Abstract: Pre-trained language models(PLMs) have achieved remarkable success in natural language processing.However,their vulnerability to backdoor attacks has become increasingly evident.Traditional trigger injection mechanisms often insert triggers randomly or at fixed positions,resulting in poor attack effectiveness,semantic incoherence,and low stealthiness.To address these shortcomings,this paper proposes a trigger injection strategy based on the attention weights of PLMs.The strategy evaluates the importance of each token by analyzing the attention weights of the PLM,aggregates attention weights across different layers using exponential decay weighting,and introduces an attention head screening mechanism to obtain global attention scores for ranking.During model training,tokens with low scores are perturbed to embed the backdoor while preserving the model’s performance on the original task.During inference,a reverse selection mechanism is employed,preferentially embedding triggers into keywords with high global attention scores to maximize interference with the model’s output.Extensive experiments are conducted on two Chinese comment datasets and three PLMs,and further extended to four large language models.The results demonstrate that the proposed method achieves the expected attack success rate while maintaining the model’s original performance.Moreover,it significantly outperforms baseline methods in terms of semantic similarity,perplexity,and the number of grammatical errors.

Key words: Pre-trained language models, Backdoor attack, Chinese text, Attention mechanism, Trigger injection strategy

中图分类号: 

  • TP393
[1] GUO J,HUO Y Z,HUANG W H.A BERT-based Text Classification Backdoor Attack Method [J].Computer and Information Technology,2023,31(4):79-82,92.
[2] ZHENG M Y,LIN Z,LIU Z X,et al.A Survey of Textual Backdoor Attacks and Defenses [J].Journal of Computer Research and Development,2024,61(1):221-242.
[3] GU T,LIU K,DOLAN-GAVITT B,et al.Badnets:Evaluating backdooring attacks on deep neural networks[J].IEEE Access,2019,7:47230-47244.
[4] LIU Y Q,MA S Q,AAFER Y,et al.Trojaning attack on neural networks [C]//Proceedings of the 25th Annual Network and Distributed System Security Symp(NDSS).Reston,VA:The Internet Society,2017:18-21.
[5] KIM Y.Convolutional neural networks for sentence classification [C]//Proceedings of the 19th Conference on Empirical Methods in Natural Language Processing(EMNLP).Stroudsburg,PA:ACL,2014:1746-1751.
[6] KURITA K,MICHEL P,NEUBIG G.Weight poisoning attacks on pretrained models [C]//Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics.Stroudsburg,PA:ACL,2020:2793-2806.
[7] QI F,YAO Y,XU S,et al.Turn the combination lock:Learnabletextual backdoor attacks via word substitution[C]//Proceedings of the 59th Annual Meeting of the Association for Computa-tional Linguistics and the 11th International Joint Conference on Natural Language Processing(Volume 1:Long Papers).2021:4873-4883.
[8] LI L Y,SONG D M,LI X N,et al.Backdoor attacks on pretrained models by layerwise weight poisoning [C]//Proceedings of the 26th Conference on Empirical Methods in Natural Language Processing.Stroudsburg,PA:ACL,2021:3023-3032.
[9] QI F C,LI M K,CHEN Y Y,et al.Hidden killer:Invisible textual backdoor attacks with syntactic trigger [C]//Proceedings of the 59th Annual Meeting of the Association for Computational Linguistics and the 11th Int Joint Conf on Natural Language Processing.Stroudsburg,PA:ACL,2021:443-453.
[10] QI F C,CHEN Y G,ZHANG X R,et al.Mind the style of text! adversarial and backdoor attacks based on text style transfer [C]//Proceedings of the 2021 Conferenceon Empirical Methods in Natural Language Processing.Stroudsburg,PA:ACL,2021:4569-4580.
[11] ZHOU X,LI J,ZHANG T,et al.Backdoor attacks with input-unique triggers in nlp[C]//Joint European Conference on Machine Learning and Knowledge Discovery in Databases.Cham:Springer Nature Switzerland,2024:296-312.
[12] ZHANG R,LI H,WEN R,et al.Instruction backdoor attacks against customized {LLMs}[C]//33rd USENIX Security Symposium(USENIX Security 24).2024:1849-1866.
[13] HU M,YANG Y,PAN D,et al.Syntactic paraphrase-based synthetic data generation for backdoor attacks against Chinese language models[J].Information Fusion,2025,124:103376.
[14] HE X,HAO F,GU T,et al.Cbas:Character-level backdoor attacks against chinese pre-trained language models[J].ACM Transactions on Privacy and Security,2024,27(3):1-26.
[15] LIU M,ZHANG Z,ZHANG Y,et al.Automatic generation of adversarial readable Chinese texts[J].IEEE Transactions on Dependable and Secure Computing,2022,20(2):1756-1770.
[16] SUN M S,LI J Y,GUO Z P,et al.THUCTC:An Efficient Chinese Text Classification Toolkit [EB/OL].Technical Report,Beijing:Tsinghua University.http://thulac.thunlp.org.
[17] DEVLIN J,CHANG M W,LEE K,et al.Bert:Pre-training ofdeep bidirectional transformers for language understanding[C]//Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics:Human Language Technologies,Volume 1(Long and Short Papers).2019:4171-4186.
[18] LIU Y,OTT M,GOYAL N,et al.Roberta:A robustly opti-mized bert pretraining approach[J].arXiv:1907.11692,2019.
[19] KITAEV N,KALSER Ł,LEVSKAYA A.Reformer:The efficient transformer[J].arXiv:2001.04451,2020.
[20] PAN X,ZHANG M,SHENG B,et al.Hidden trigger backdoor attack on {NLP} models via linguistic style manipulation[C]//31st USENIX Security Symposium(USENIX Security 22).2022:3611-3628.
[21] LI S,LIU H,DONG T,et al.Hidden backdoors in human-centric language models[C]//Proceedings of the 2021 ACM SIGSAC Conference on Computer and Communications Security.2021:3123-3140.
[22] CHEN X,SALEM A,CHEN D,et al.Badnl:Backdoor attacks against nlp models with semantic-preserving improvements[C]//Proceedings of the 37th Annual Computer Security Applications Conference.2021:554-569.
[23] LI J,DU T,JI S,et al.{TextShield}:Robust text classification based on multimodal embedding and neural machine translation[C]//29th USENIX Security Symposium(USENIX Security 20).2020:1381-1398.
[24] MAATEN L,HINTON G.Visualizing data using t-SNE[J].Journal of machine learning research,2008,9(Nov):2579-2605.
Viewed
Full text


Abstract

Cited

  Shared   
  Discussed   
No Suggested Reading articles found!