计算机科学 ›› 2026, Vol. 53 ›› Issue (11): 437-447.doi: 10.11896/jsjkx.250900026

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

CCDC:用于中文有毒文本检测的反事实对比解耦框架

黄海平1,2,3, 朱家骏1, 常舒予1, 张扬1   

  1. 1 南京邮电大学计算机学院 南京 210023
    2 江苏省物联网智能感知与计算重点实验室 南京 210023
    3 网络空间安全态势感知与评估安徽省重点实验室 合肥 230000
  • 收稿日期:2025-09-02 修回日期:2025-12-12 出版日期:2026-11-15 发布日期:2026-11-10
  • 通讯作者: 黄海平(hhp@njupt.edu.cn)
  • 基金资助:
    国家自然科学基金重大研究计划(92467202);网络空间安全态势感知与评估安徽省重点实验室开放项目(TK224013);江苏省研究生科研与实践创新计划(KYCX24_1234,KYCX23_1077)

CCDC:Counterfactual Contrastive Decoupling Framework for Chinese Toxic Text Detection

HUANG Haiping1,2,3, ZHU Jiajun1, CHANG Shuyu1, ZHANG Yang1   

  1. 1 School of Computer Science,Nanjing University of Posts and Telecommunications,Nanjing 210023,China
    2 Jiangsu Provincial Key Laboratory of Internet of Things Intelligent Perception and Computing,Nanjing 210023,China
    3 Anhui Province Key Laboratory of Cyberspace Security Situation Awareness and Evaluation,Hefei 230000,China
  • Received:2025-09-02 Revised:2025-12-12 Published:2026-11-15 Online:2026-11-10
  • About author:HUANG Haiping,born in 1981,Ph.D,professor,Ph.D supervisor,is a senior member of CCF(No.15253S).His main research interests include information security and data privacy in IoT.
  • Supported by:
    Major Research Plan of the National Natural Science Foundation of China(92467202),Open Fund of Anhui Pro-vince Key Laboratory of Cyberspace Security Situation Awareness and Evaluation(TK224013) and Postgraduate Research and Practice Innovation Program of Jiangsu Province(KYCX24_1234,KYCX23_1077).

摘要: 随着社交媒体的迅速发展,有毒文本在网络环境中呈现高发态势,这对用户的心理健康与社会舆论造成了负面影响。相比英文场景,中文有毒文本往往具有更强的隐晦性与多样性,使得现有方法在识别深层毒性特征时面临挑战。尤其是在预训练-微调范式下,模型易在高频词汇与毒性标签之间建立虚假关联,导致偏差与误判。为缓解上述问题,提出了一种用于中文有毒文本检测的反事实对比解耦框架。该框架通过生成词汇类似但标签翻转的反事实样本,并结合对比学习实现内容与毒性特征的解耦,从而有效削弱虚假相关性的干扰,引导模型聚焦于毒性表达的本质特征。在两个公开中文数据集上的实验表明,该框架在整体性能与去偏能力方面均优于多种代表性基线模型。此外,在不同预训练模型下的对比实验展示了框架良好的通用性与适配能力,而可视化与案例分析进一步揭示了模型在识别中文有毒文本时的判别机制与优势。

关键词: 中文有毒文本检测, 反事实生成, 特征解耦, 词汇偏差, 自然语言处理

Abstract: With the rapid proliferation of social media platforms and the increasingly ubiquitous nature of online communication,the occurrence of toxic text has become a pervasive issue,exerting far-reaching negative impacts on both the psychological well-being of users and the broader formation and dissemination of public opinion.In contrast to English-language contexts,Chinese toxic text exhibits heightened levels of linguistic subtlety,implicitness,and semantic diversity,which presents substantial challenges for existing computational methods attempting to accurately capture and characterize the underlying toxic semantics.In particular,within the widely adopted pretraining-and-finetuning paradigm,deep learning models are often prone to forming spurious correlations between high-frequency lexical items and associated toxicity labels.Such spurious associations can lead to systematic biases and misclassifications,undermining both the reliability and robustness of toxicity detection systems.In order to address these inherent challenges,a counterfactual contrastive disentanglement framework for Chinese toxic text detection is developed.This framework strategically generates counterfactual samples that preserve lexical similarity while reversing the corresponding toxicity labels,thereby enhancing data diversity and enabling the model to encounter controlled perturbations that isolate toxicity-related signals.By integrating contrastive learning techniques,the framework further disentangles content-related representations from toxicity-related representations,effectively mitigating the interference of superficial correlations and guiding the model to focus on the intrinsic semantic characteristics and subtle cues indicative of toxic expressions.Extensive empirical evaluations conducted on two publicly available Chinese datasets demonstrate that the proposed framework consistently achieves superior overall performance in classification accuracy while also exhibiting enhanced debiasing capability when compared against multiple representative baseline approaches.Moreover,experiments performed across a range of pretrained model architectures reveal the framework’s strong adaptability,scalability,and generalization potential,indicating its applicability to diverse settings and model backbones.Complementary visualization analyses and detailed case studies provide further insight into the model’s decision-ma-king mechanisms,illustrating how it captures nuanced,context-dependent toxic signals that are often overlooked by conventional methods,and highlighting the framework’s capacity to robustly identify and interpret subtle toxic expressions within the complex semantic landscape of Chinese text.

Key words: Chinese toxic text detection, Counterfactual generation, Feature disentanglement, Lexical bias, Natural language processing

中图分类号: 

  • TP391
[1] GEVERS I,MARKOV I,DAELEMANS W.Linguistic analysis of toxic language on social media[C]//Computational Linguistics in the Netherlands.Computational Linguistics in the Netherlands,2022:33-48.
[2] FAN L,LI L,HEMPHILL L.Toxicity on social media during the 2022 mpox public health emergency:Quantitative study of topical and network dynamics [J].Journal of Medical Internet Research,2024,26:e52997.
[3] BEKNAZAR-YUZBASHEV G,JIMÉNEZ-DURÁN R,MC-CROSKY J,et al.Toxic content and user engagement on social media:Evidence from a field experiment [R].CESifo Working Paper,2025.
[4] DENG Y,DOU C,CHEN L Y,et al.BEIKE NLP at SemEval-2022 Task 4:Prompt-Based Paragraph Classification for Patronizing and Condescending Language Detection [C]//Proceedings of the 16th International Workshop on Semantic Evaluation(SemEval-2022).2022:319-323.
[5] DENG J,CHEN Z,SUN H,et al.Enhancing offensive language detection with data augmentation and knowledge distillation [J].Research,2023,6:0189.
[6] BRUNET M E,ALKALAY-HOULIHAN C,ANDERSON A,et al.Understanding the origins of bias in word embeddings [C]//International Conference on Machine Learning.PMLR,2019:803-811.
[7] LU K,MARDZIEL P,WU F,et al.Gender bias in neural natural language processing [M]//Logic,Language,and Security.2020:189-202.
[8] PARK J H,SHIN J,FUNG P.Reducing gender bias in abusive language detection [C]//Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing.2018:2799-2804.
[9] ALI R,FAROOQ U,ARSHAD U,et al.Hate speech detection on Twitter using transfer learning [J].Computer Speech & Language,2022,74:101365.
[10] QASIM R,BANGYAL W H,ALQARNI M A,et al.A fine-tuned BERT-based transfer learning approach for text classification [J].Journal of Healthcare Engineering,2022,2022(1):3498123.
[11] CASELLI T,BASILE V,MITROVIĆ J,et al.HateBERT:Retraining BERT for abusive language detection in English [C]//Proceedings of the 5th Workshop on Online Abuse and Harm.Association for Computational Linguistics,2021:17-25.
[12] BILAL M,KHAN A,JAN S,et al.Roman Urdu hate speech detection using transformer-based model for cyber security applications [J].Sensors,2023,23(8):3909.
[13] GHOSH K,SONOWAL D,BASUMATARY A,et al.Trans-former-based hate speech detection in Assamese [C]//2023 IEEE Guwahati Subsection Conference(GCON).IEEE,2023:1-5.
[14] VELANKAR A,PATIL H,JOSHI R.Mono vs multilingualBERT for hate speech detection and text classification:A case study in Marathi [C]//IAPR Workshop on Artificial Neural Networks in Pattern Recognition.Cham:Springer International Publishing,2022:121-128.
[15] SAUMYA S,KUMAR A,SINGH J P.Offensive language identification in Dravidian code-mixed social media text [C]//Proceedings of the First Workshop on Speech and Language Technologies for Dravidian Languages.2021:36-45.
[16] EL MOUBTAHIJ H,ABDELAI H,TAZI E B.AraBERTtransformer model for Arabic comments and reviews analysis [J].IAES International Journal of Artificial Intelligence,2022,11(1):379-387.
[17] HE X,ZANNETTOU S,SHEN Y,et al.You only prompt once:On the capabilities of prompt learning on large language models to tackle toxic content [C]//2024 IEEE Symposium on Security and Privacy(SP).IEEE,2024:770-787.
[18] KIM Y,PARK S,NAMGOONG Y,et al.ConPrompt:Pre-training a language model with machine-generated data for implicit hate speech detection [C]//Findings of the Association for Computational Linguistics:EMNLP 2023.2023:10964-10980.
[19] MOZAFARI M,FARAHBAKHSH R,CRESPI N.Hate speech detection and racial bias mitigation in social media based on BERT model [J].PloS One,2020,15(8):e0237861.
[20] PRASOMPHAN S.Enhance social network bullying detection using multi-teacher knowledge distillation with XGBoost classifier [J].IEEE Access,2025,13:95618-95627.
[21] YU Z,WANG S,JIANG N,et al.Improving harmful text detection with joint retrieval and external knowledge [C]//2025 IEEE 6th International Seminar on Artificial Intelligence,Networking and Information Technology(AINIT).IEEE,2025:1950-1954.
[22] XIAO Y,BOUAMOR H,ZAGHOUANI W.Chinese offensivelanguage detection:Current status and future directions [J].arXiv:2408.18314,2024.
[23] DENG J,ZHOU J,SUN H,et al.COLD:A benchmark for Chinese offensive language detection [C]//Proceedings of the 2022 Conference on Empirical Methods in Natural Language Proces-sing.2022:11580-11599.
[24] JIANG A,YANG X,LIU Y,et al.SWSR:A Chinese dataset and lexicon for online sexism detection [J].Online Social Networks and Media,2022,27:100182.
[25] GONG X,ZHAO Q,ZHANG J,et al.The design and construc-tion of a Chinese sarcasm dataset [C]//Proceedings of the Twelfth Language Resources and Evaluation Conference.2020:5034-5039.
[26] ZHU Y.Open Chinese internet sarcasm corpus construction:An approach [J].Frontiers in Computing and Intelligent Systems,2022,2(1):7-9.
[27] ZHANG L,ZHAO X,SONG X,et al.A novel Chinese sarcasm detection model based on retrospective reader [C]//International Conference on Multimedia Modeling.Cham:Springer International Publishing,2022:267-278.
[28] LU J,XU B,ZHANG X,et al.Facilitating fine-grained detection of Chinese toxic language:Hierarchical taxonomy,resources,and benchmarks [C]//Proceedings of the 61st Annual Meeting of the Association for Computational Linguistics(Volume 1:Long Papers).2023:16235-16250.
[29] YANG S,CUI S,HU C,et al.Exploring multimodal challenges in toxic Chinese detection:taxonomy,benchmark,and findings [C]//Findings of the Association for Computational Linguistics(ACL 2025).Association for Computational Linguistics,2025:14382-14396.
[30] BOLUKBASI T,CHANG K W,ZOU J Y,et al.Man is to computer programmer as woman is to homemaker? Debiasing word embeddings [C]//NIPS 2016.
[31] CAO Y T,DAUMÉ III H.Toward gender-inclusive coreference resolution [C]//Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics.2020:4568-4595.
[32] QIAN R,ROSS C,FERNANDES J,et al.Perturbation augmentation for fairer NLP [C]//Proceedings of the 2022 Conference on Empirical Methods in Natural Language Processing.2022:9496-9521.
[33] LI Y,DU M,SONG R,et al.Data-centric explainable debiasing for improving fairness in pre-trained language models [C]//Findings of the Association for Computational Linguistics ACL 2024.2024:3773-3786.
[34] XIA M,FIELD A,TSVETKOV Y.Demoting racial bias in hate speech detection [C]//Proceedings of the Eighth International Workshop on Natural Language Processing for Social Media.2020:7-14.
[35] LIU N F,AVCI B,ABELIUK A,et al.Combating negative stereotypes:A computational approach for exposing implicit bias in Chinese [C]//Proceedings of the 28th International Conference on Computational Linguistics.2020:6568-6581.
[36] ZHOU X,BANSAL M.Towards robustifying NLI modelsagainst lexical dataset biases [C]//Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics.2020:8759-8771.
[37] DEV S,LI T,PHILLIPS J M,et al.On measuring and mitigating biased inferences of word embeddings [C]//Proceedings of the AAAI Conference on Artificial Intelligence.2020:7659-7666.
[38] WANG F,HUANG J Y,YAN T,et al.Robust natural language understanding with residual attention debiasing [C]//The 61st Annual Meeting of the Association for Computational Linguistics.2023.
[39] ZHOU G,WANG H,JIN D,et al.A toxic euphemism detection framework for online social network based on semantic contrastive learning and dual channel knowledge augmentation [J].Information Processing & Management,2025,62(4):104143.
[40] LIU A,FENG B,XUE B,et al.Deepseek-v3 technical report [J].arXiv:2412.19437,2024.
[41] ZHANG T,KISHORE V,WU F,et al.BERTScore:evaluating text generation with BERT [C]//8th International Conference on Learning Representations.2020.
[42] WANG Z,CULOTTA A.Robustness to spurious correlations in text classification via automatically generated counterfactuals [C]//Proceedings of the AAAI Conference on Artificial Intelligence.2021:14024-14031.
[43] CAI T T,MA R.Theoretical foundations of t-SNE for visualizing high-dimensional clustered data [J].Journal of Machine Learning Research,2022,23(301):1-54.
Viewed
Full text


Abstract

Cited

  Shared   
  Discussed   
No Suggested Reading articles found!