• 中国计算机学会会刊
  • 中国科技核心期刊
  • 中文核心期刊

计算机工程与科学 ›› 2026, Vol. 48 ›› Issue (5): 906-913.doi: 10.3969/j.issn.1007-130X.2026.05.014

• 人工智能与数据挖掘 • 上一篇    下一篇

基于BERT和情感分析的无偏见攻击性文本检测方法

袁亮,郭卫斌


  

  1. (华东理工大学信息科学与工程学院,上海 200237)

  • 收稿日期:2024-07-23 修回日期:2024-11-06 出版日期:2026-05-25 发布日期:2026-05-21
  • 基金资助:
    国家自然科学基金(62076094)

An unbiased offensive text detection method based on BERT and sentiment analysis

YUAN Liang,GUO Weibin   

  1. (School of Information Science and Engineering,East China University of Science and Technology,Shanghai 200237,China)
  • Received:2024-07-23 Revised:2024-11-06 Online:2026-05-25 Published:2026-05-21

摘要: 互联网中的攻击性信息会对个人和社会造成严重危害。在攻击性文本检测方法中,现有的方法存在对含有脏话的非攻击性文本的误判问题和对特殊群体存在偏见的问题。针对前者,提出了一种基于情感分析的攻击性文本检测模型SAOD,利用情感特征辅助预测文本是否具有攻击性;针对后者,提出了一种去偏见的数据增强方法SGM,在训练时将特殊群体进行掩盖,使特殊群体不经过模型训练,从而降低模型对特殊群体的偏见。以BERT+LSTM为基础模型,基于公开数据集ToxiCN和COLD,进行了相应的实验验证。实验结果表明,前者以F1为评价指标,将基础模型的F1分数由80.18%提升到了82.67%;后者实验建立在前者基础上,以误报率FPR为指标,将其由18.27%降低到12.77%。

关键词: BERT模型, 攻击性文本检测, 情感分析, 去偏见, 数据增强

Abstract: Offensive information on the internet poses severe harm to individuals and society. In offensive text detection methods, existing methods suffer from misjudging non-offensive texts containing profanity and bias against special groups. To address the former issue, this paper proposes a sentiment analysis-based offensive text detection (SAOD) model, which uses sentiment features to assist in predict- ing whether a text is offensive. To tackle the latter issue, a debiasing data augmentation method called special groups mask (SGM) is proposed. This method masks special groups during training, ensuring that special groups are not directly involved in model training, thereby reducing the model's bias towards these groups. Using BERT+LSTM as the base model, experiments were conducted on publicly avail- able datasets ToxiCN and COLD. The experimental results show that the former method improved the base model’s F1-score from 80.18% to 82.67%. Based on this, the latter method reduces the false positive rate (FPR) from 18.27% to 12.77%.

Key words: BERT model, offensive text detection, sentiment analysis, debiasing, data augmentation