arXiv:2501.03940cs.CLcs.AI2025-01被引 7

通过加权难易预测词元提升AI文本检测精度

Not all tokens are created equal: Perplexity Attention Weighted Networks for AI generated text detection

  • 用注意力机制动态加权不同词元的困惑度特征
  • 在多语言数据上达81.46%平均F1,优于主流模型
  • 适合需要低资源、强泛化能力的检测场景

大型语言模型(LLMs)生成文本的能力日益增强,引发了对滥用生成内容的担忧,因此检测其生成痕迹至关重要。然而,该任务在未见领域或陌生模型上仍具挑战性。尽管利用LLM的下一个词分布理论上具有优势,但现有零样本方法效果有限。我们提出,问题在于使用均值聚合所有词元的分布指标,而实际上某些词元更易或更难预测,应区别对待。为此,我们设计了困惑度注意力加权网络(PAWN),基于LLM最后隐藏状态和位置信息,对序列中各词元的下一词分布指标进行加权求和。虽然非零样本,但可通过缓存隐藏状态和分布指标显著降低训练开销。PAWN在同分布下性能媲美甚至超过最佳微调模型,参数量仅为后者的几分之一;对未见领域和源模型泛化更好,决策边界变化更小,且对对抗攻击更具鲁棒性。若主干模型具备多语言能力,即使训练中未见语言,也能实现良好泛化,如LLaMA3-1B在九种语言上的交叉验证中达到81.46%的平均宏观F1分数。

原文摘要 · Abstract (English)

The rapid advancement in large language models (LLMs) has significantly enhanced their ability to generate coherent and contextually relevant text, raising concerns about the misuse of AI-generated content and making it critical to detect it. However, the task remains challenging, particularly in unseen domains or with unfamiliar LLMs. Leveraging LLM next-token distribution outputs offers a theoretically appealing approach for detection, as they encapsulate insights from the models' extensive pre-training on diverse corpora. Despite its promise, zero-shot methods that attempt to operationalize these outputs have met with limited success. We hypothesize that one of the problems is that they use the mean to aggregate next-token distribution metrics across tokens, when some tokens are naturally easier or harder to predict and should be weighted differently. Based on this idea, we propose the Perplexity Attention Weighted Network (PAWN), which uses the last hidden states of the LLM and positions to weight the sum of a series of features based on metrics from the next-token distribution across the sequence length. Although not zero-shot, our method allows us to cache the last hidden states and next-token distribution metrics on disk, greatly reducing the training resource requirements. PAWN shows competitive and even better performance in-distribution than the strongest baselines (fine-tuned LMs) with a fraction of their trainable parameters. Our model also generalizes better to unseen domains and source models, with smaller variability in the decision boundary across distribution shifts. It is also more robust to adversarial attacks, and if the backbone has multilingual capabilities, it presents decent generalization to languages not seen during supervised training, with LLaMA3-1B reaching a mean macro-averaged F1 score of 81.46% in cross-validation with nine languages.

文本检测困惑度多语言加权网络

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。