GAttention: Gated Attention for the Detection of Abusive Language

Horacio Jarquín Vásquez, Hugo Jair Escalante, Manuel Montes, Mario Ezra AragonEMNLP 2025

TL;DR

This paper introduces GAttention, a novel attention mechanism that combines local and global context to better detect abusive language online. By integrating Self-Attention (SA) and Contextual Attention (CA) in a gated manner, GAttention significantly improves the performance of Transformer models on abusive language detection tasks, outperforming state-of-the-art methods.

What Problem Does This Paper Address?

Abusive language (AL) online is a growing concern, fostering toxic environments and exacerbating social tensions. Detecting AL is challenging because its meaning often depends heavily on subtle linguistic cues and the surrounding context. Existing NLP models, particularly Transformer-based ones, have made strides, but they can struggle to capture the full nuance required for accurate AL detection. Specifically, while Self-Attention (SA) excels at understanding relationships within a single sequence (local context), and Contextual Attention (CA) focuses on global relationships by emphasizing tokens based on an external query, neither perfectly captures both aspects simultaneously. This can lead to a loss of crucial contextual information, hindering the model's ability to discern the true intent behind language.

Methods

The core contribution is the GAttention mechanism. It's designed to fuse the strengths of SA and CA. Here's how it works:

  • SA and CA Representations: The input sequence is first processed to generate two distinct representations: one from Self-Attention (capturing local dependencies within the sequence) and another from Contextual Attention (capturing global dependencies using an external query).
  • Gating Mechanism: GAttention then uses a "gated" approach. It learns a gating vector that dynamically weighs the contributions of the SA and CA representations. This allows the model to adaptively decide how much importance to give to local versus global context for each specific input.
  • Multi-Head GAttention: To further enhance its capabilities, the authors extend GAttention to a Multi-Head version. This allows the model to attend to different aspects of the input simultaneously by running multiple GAttention units in parallel and concatenating their outputs.

The GAttention mechanism is integrated into the final encoding layer of pre-trained Transformer models (like BERT, ERNIE, RoBERTa, and DistilBERT).

Datasets

The authors evaluated their approach on three established English benchmark datasets for abusive language detection:

  • SE 2019 Task 6: Focuses on offensive tweet classification.
  • AMI 2018: Specifically targets the detection of misogyny in tweets.
  • HASOC 2019: Addresses hate speech and offensive content detection in tweets.

These datasets include both binary and multi-class classification subtasks. The paper does not introduce new benchmarks but uses existing ones for comprehensive evaluation.

Key Insights and Ideas

  • Context is King (and Gated): The paper strongly suggests that effectively detecting abusive language requires a sophisticated understanding of both local word relationships and broader contextual meaning. GAttention's gated approach directly addresses this by adaptively blending these two crucial aspects.
  • Multi-Head Attention Boosts Performance: The Multi-Head GAttention variant consistently outperformed the single-head version, indicating that attending to different representation subspaces simultaneously is highly beneficial for complex tasks like AL detection.
  • ERNIE Shines with GAttention: The ERNIE model, when combined with GAttention (especially the multi-head version), consistently achieved the best results across various subtasks and datasets. This highlights the synergy between ERNIE's contextual understanding and GAttention's nuanced attention mechanism.
  • Beyond Explicit Slurs: GAttention shows promise in identifying offensive content even when explicit slurs are absent, relying on contextual cues. This is crucial for tackling subtle forms of online abuse.

Key Results

  • Superior Performance: GAttention configurations consistently improved performance across all tested Transformer models compared to their baseline counterparts.
  • Outperforming Baselines: The proposed GAttention mechanism outperformed the SCA (Self-Contextualized Attention) mechanism, which also combines SA and CA, across all models and subtasks.
  • State-of-the-Art (SOTA) Achievement: The best performing configuration (Multi-Head GAttention with 12 heads on ERNIE) outperformed top-ranked systems from shared tasks in five out of six evaluated subtasks.
  • Competitive with LLMs: The GAttention approach, when integrated into Transformer models, achieved competitive results against contemporary Large Language Models (LLMs) like Llama-3.1-8B-Instruct, often with significantly fewer parameters.
  • Performance Gains: Performance improvements reached up to 9% in AL detection tasks, which is significant given the impact of such content.

Limitations and Future Work

  • Dataset Biases: The authors acknowledge that manually annotated datasets may contain inherent social biases, which the models could learn, potentially leading to errors on different data.
  • Model Integration Variability: The performance of GAttention might vary when integrated with different pre-trained models beyond those tested (BERT, ERNIE, RoBERTa, DistilBERT).
  • Data Scarcity: For architectures requiring large amounts of training data, limited access could constrain model capabilities.
  • Future Directions:
    • Evaluate GAttention on tasks where context interpretation is critical, such as detecting depression, deception, or fake news.
  • Extend GAttention to detect AL in memes by incorporating multimodal attention.
  • Develop novel loss functions that integrate the CA context vector into the classification process.
  • Investigate cases where GAttention struggles with subtle expressions, acronyms, or instances with ambiguous ground-truth labels.

Summary updated

BibTeX
@inproceedings{vasquez2025gattention,
  author = {Horacio Jarquín Vásquez and Hugo Jair Escalante and Manuel Montes and Mario Ezra Aragon},
  title = {{GAttention: Gated Attention for the Detection of Abusive Language}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2025},
}
Figure