Skip to main content
QUICK REVIEW

[Paper Review] Attention Hijacking in Trojan Transformers

Weimin Lyu, Songzhu Zheng|arXiv (Cornell University)|Aug 9, 2022
Adversarial Robustness in Machine LearningComputer Science8 citations
TL;DR

This paper introduces the attention hijacking pattern in Trojan-affected BERTs and Vision Transformers, where a trigger token dominates attention weights regardless of input content. The authors propose AHTD, an unsupervised and supervised Trojan detector leveraging this pattern, achieving state-of-the-art detection performance across NLP and CV benchmarks with AUC scores above 0.97.

ABSTRACT

Trojan attacks pose a severe threat to AI systems. Recent works on Transformer models received explosive popularity and the self-attentions are now indisputable. This raises a central question: Can we reveal the Trojans through attention mechanisms in BERTs and ViTs? In this paper, we investigate the attention hijacking pattern in Trojan AIs, \ie, the trigger token ``kidnaps'' the attention weights when a specific trigger is present. We observe the consistent attention hijacking pattern in Trojan Transformers from both Natural Language Processing (NLP) and Computer Vision (CV) domains. This intriguing property helps us to understand the Trojan mechanism in BERTs and ViTs. We also propose an Attention-Hijacking Trojan Detector (AHTD) to discriminate the Trojan AIs from the clean ones.

Motivation & Objective

  • To investigate whether attention mechanisms in BERTs and ViTs reveal consistent patterns in Trojan-affected models.
  • To understand how attention hijacking affects representation learning and global information incorporation in Trojan AIs.
  • To develop a universal detection method applicable to both NLP and CV Transformers.
  • To propose a detection framework that does not require clean data or model architecture assumptions.

Proposed method

  • The paper identifies the attention hijacking pattern: specific attention heads consistently attend to the trigger token across all inputs when the trigger is present.
  • It introduces an unsupervised AHTD that detects Trojans by measuring attention concentration on the trigger token in poisoned inputs.
  • A supervised variant of AHTD is proposed, using attention patterns as features for binary classification of clean vs. Trojan models.
  • The method is evaluated on BERTs fine-tuned on IMDB, SST-2, and YELP, and ViTs trained on MNIST and CIFAR-10 with various trigger types.
  • The approach relies solely on attention weights from poisoned samples, avoiding the need to compare clean and poisoned attention distributions.
  • The authors release a dataset of Trojan BERTs and ViTs for reproducibility and benchmarking.

Experimental results

Research questions

  • RQ1Can attention mechanisms in BERTs and ViTs reveal consistent patterns in Trojan-affected models?
  • RQ2Does the trigger token dominate attention weights regardless of input content, indicating a universal attention hijacking pattern?
  • RQ3How does attention hijacking affect representation learning and global information flow in Trojan AIs?
  • RQ4Can attention hijacking be leveraged to build a universal Trojan detector across NLP and CV domains?
  • RQ5Is the attention hijacking pattern invariant across different Transformer architectures like BERT and ViT?

Key findings

  • The attention hijacking pattern is consistently observed in both BERTs and ViTs, where the trigger token dominates attention weights in specific heads regardless of input content.
  • The unsupervised AHTD achieves AUC scores of 0.97 on IMDB, 0.94 on YELP, and 0.95 on SST-2, outperforming all baselines.
  • The supervised AHTD achieves AUC scores of 0.98 on IMDB, 0.96 on YELP, and 0.95 on SST-2, demonstrating superior detection capability.
  • On CV benchmarks, the unsupervised AHTD achieves 0.97 AUC on MNIST and 0.99 AUC on CIFAR-10, significantly outperforming existing methods.
  • The attention hijacking pattern correlates with enhanced global information incorporation and influences the model’s embedding representations.
  • The method generalizes across different trigger types and architectures, confirming the invariance of the attention hijacking pattern in Transformers.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.