Skip to content
AI.info

Research

Aligning Attention with Human Rationales for Self-Explaining Hate Speech Detection

Overview Research area: Natural Language Processing — explainable AI (XAI) for hate speech detection, with attention to fairness and cross-lingual evaluation. Technical level: Advanced. The paper assu

Aligning Attention with Human Rationales for Self-Explaining Hate Speech Detection
arXiv
2511.07065
Published
2025-11-10
Authors
Brage Eilertsen, Røskva Bjørgfinsdóttir, Francielle Vargas, Ali Ramezani-Kebrya

AI summary

Overview

  • Research area: Natural Language Processing — explainable AI (XAI) for hate speech detection, with attention to fairness and cross-lingual evaluation.
  • Technical level: Advanced. The paper assumes familiarity with transformer attention, supervised attention, and bias/fairness metrics.
  • Scope: The paper introduces Supervised Rational Attention (SRA), a training framework that forces a transformer's [CLS]-to-token attention to match human-annotated rationales, and evaluates it on English (HateXplain) and Portuguese (HateBRXplain) hate speech benchmarks for classification, explainability, fairness, and faithfulness.

What This Paper Is About

Deep-learning hate speech detectors work well but are opaque: users cannot tell whether a prediction rests on genuine indicators of harm or on spurious shortcuts, and such systems can encode biases that marginalize the groups they are meant to protect. The authors' goal is to make these classifiers self-explaining by explicitly training their internal attention to land on the same text spans that human annotators used when labeling a post as offensive or hate speech. They test whether this added supervision improves explanation quality without sacrificing classification accuracy or demographic fairness.

Key Contributions

  1. The SRA framework. A method that adds an Attention Alignment Loss (AAL) term to a standard transformer classifier, minimizing the mean squared error between normalized [CLS]-token attention and a binary human rationale mask, combined with the ordinary cross-entropy classification loss.
  2. Cross-lingual evaluation. SRA is evaluated on English (HateXplain, 20,148 samples, three classes) and Portuguese (HateBRXplain, 7,000 samples, two classes) benchmarks with rationale annotations, using BERT-base-uncased and BERTimbau-base respectively.
  3. Joint reporting of explainability, fairness, and faithfulness. The paper measures classification (accuracy, macro F1, AUROC), explainability (IoU F1, Token F1, AUPRC), fairness (GMB-Subgroup, GMB-BPSN, GMB-BNSP AUCs) and faithfulness (comprehensiveness, sufficiency), and includes an ablation over the alignment strength α from 0 to 100.
  4. Released artifacts. The authors state they provide publicly available code, datasets and models, including rationale mask construction and attention supervision, with a reproducibility checklist attached.

Main Findings

  • Explainability improves substantially. On HateXplain, SRA reaches IoU F1 of 0.539 (±0.005), described as a 4.5× improvement over BERT-HateXplain's supervised attention (0.120) and a 2.4× gain over the best baseline, BiRNN-HateXplain (0.222). The abstract states SRA achieves "2.4× better explainability compared to current baselines."
  • Token-level alignment is strong. Token F1 reaches 0.651 (±0.002), which the paper describes as outperforming the best baseline by 29%. SRA's token-level precision and recall are 0.937 and 0.579 — meaning highlighted tokens are likely to coincide with human rationales.
  • Classification cost is small. SRA gets macro F1 0.682, accuracy 0.696 and AUROC 0.855, marginally below BERT-MRP (F1 0.699, Acc 0.704, AUROC 0.862) — a difference the authors describe as less than 2% in F1.
  • Fairness is mixed but competitive. SRA's GMB-Subgroup AUC is 0.714, below BERT-MRP (0.815) and BERT-HateXplain (0.807). GMB-BPSN AUC is 0.718 versus 0.748 (BERT-MRP) and 0.745 (BERT-HateXplain). GMB-BNSP AUC is 0.835 — second-best after BERT-MRP's 0.854 and well above BERT-HateXplain's 0.763. The authors frame this as a trade-off: weaker subgroup and false-positive behavior, stronger false-negative detection for identity-targeted toxicity.
  • Faithfulness is competitive but not best. SRA's comprehensiveness is 0.417 (±0.019), beaten by post-hoc approaches such as BERT-HateXplain [LIME] (0.500); sufficiency is -0.013 (±0.012), which the authors note is a common negative value for attention-based methods.
  • Increasing α monotonically improves explanation quality. On HateXplain, IoU F1 rises from 0.019 at baseline (α=0) to 0.572 at α=100, and Token F1 from 0.122 to 0.678, with Test Macro F1 stable and GMB-Subgroup AUC ranging only 0.7112–0.7220. The chosen operating point α=10 gives IoU F1 0.537, Token F1 0.648, Test F1 0.683 and GMB-Subgroup 0.7120.
  • Portuguese results mirror English. SRA with BERTimbau at α=10 achieves IoU F1 0.716 (±0.025), Token Precision 0.935 (±0.005), Token Recall 0.668 (±0.014), Token F1 0.745 (±0.010), comprehensiveness 0.454 and sufficiency -0.036. PTTS [SHAP] reaches a comparable IoU F1 of 0.7400 but a lower Token F1 of 0.7362. SRA produces these explanations intrinsically at prediction time, unlike LIME and SHAP.
  • Portuguese classification is stable. Test Macro F1 goes from a baseline of 0.903 to a peak of 0.921 at α=0.5, with only minor variation (±2%) even at α=100. At α=10, Test F1 is 0.910 (±0.008), accuracy 0.907 (±0.007), AUROC 0.966 (±0.004). Portuguese IoU F1 rises from 0.387 at α=0.05 to 0.751 at α=100 (baseline 0), and Token F1 from 0.574 to 0.771, with Token Precision peaking at α=1.0 and staying above 0.91 under all supervised settings.
  • Attention–rationale correlation turns from negative to positive. Pearson correlation rises from -0.084 at α=0 to 0.649 at α=100 for English, and reaches 0.757 in Portuguese.
  • Identity-term handling improves. Token precision on identity-related terminology rises from 0.265 with unsupervised attention to 0.938 at α=10. In the example "That's my nigga right there!" (labeled non-offensive), SRA assigns attention weights of 0.665 and 0.328 to the WordPiece subwords "ni" and "##gga" while keeping the non-offensive classification.
  • Qualitative attention shifts are visible. For the refugee metaphor example, baseline BERT predicts Normal 2.59%, Offensive 90.17%, Hate speech 7.24%, while SRA predicts Normal 1.70%, Offensive 59.56%, Hate speech 38.74%. For "Go back to where you came from — but I don't hate all immigrants," baseline attention peaks on "you" (0.286), "go" (0.160), "back" (0.120), whereas SRA peaks on "hate" (0.394) and "all" (0.445). In the Portuguese example "Só podia ser mulher dirigindo desse jeito," SRA attends to "jeito" (0.277), "desse" (0.215) and "mulher" (0.113), while the baseline concentrates on [CLS] (0.633).
  • Possible label noise in HateXplain. Excluding 335 identified problematic cases lifts SRA's Test F1 from 0.682 to 0.796 (+16.7%), accuracy from 0.696 to 0.814 (+17.0%) and IoU F1 from 0.539 to 0.561, with a 9.9% relative subgroup bias reduction versus baseline. The authors caution these filtered numbers are not directly comparable to baselines evaluated on the full dataset, and that some discrepancies may reflect legitimate annotator disagreement.

Methodology in Plain English

The researchers start from standard transformer hate speech classifiers (BERT for English, BERTimbau for Portuguese) that already output a prediction from the [CLS] token. They add a second training signal: for each offensive or hate speech training example that has a human rationale, they build a binary mask marking which tokens annotators flagged as evidence. A token is included in the mask if at least 50% of annotators who supplied rationales selected it; for datasets with free-text rationale spans, character offsets from the tokenizer are mapped onto token indices.

During training they extract the attention weights flowing from the [CLS] token to every input token at a chosen layer and head, normalize these weights, and penalize the squared difference between the normalized weights and the human mask. This penalty is added to the normal classification loss, scaled by a hyperparameter α that controls how strongly attention is pushed toward human rationales. The supervision is only applied when the label is offensive or hate speech and a rationale exists.

At inference the same attention weights double as the explanation for the prediction, so no separate explanation step is needed. The authors chose layer 8, head 7 after ablating across layers and heads, noting that layers 6–11 and all heads gave consistent results. Training used AdamW, 5 epochs, 80/10/10 stratified splits with fixed seeds, α=10 unless stated otherwise, and results averaged over 5 random seeds on a single A100 GPU.

Why This Matters

Impact on research. The paper connects two research lines that are usually evaluated separately — rationale-based attention supervision and fairness auditing of hate speech classifiers. It offers a concrete recipe for turning human rationales into a training signal that measurably changes where a model looks, and it reports fairness metrics alongside explainability metrics rather than treating accuracy as sufficient. It also quantifies how negative Pearson correlation between attention and human rationales at baseline can be driven positive by supervision.

Real-world applications:

  • Content moderation. Moderation teams at platforms handling hate speech appeals at scale (the paper cites Meta processing over seven million hate speech appeals monthly) could inspect highlighted evidence tokens to justify or contest automated decisions to users and reviewers.
  • Regulatory and compliance review. Transparency requirements such as the EU framework the paper cites create demand for systems whose decisions come with an auditable rationale, which intrinsic attention explanations can supply without a separate post-hoc pipeline.
  • Real-time and resource-constrained deployment. Because SRA produces explanations during prediction, it avoids the extra computation that LIME and SHAP require, which matters for high-throughput moderation queues.
  • Regional and multilingual deployment. The parallel English and Portuguese results indicate the approach can be adapted to Portuguese-language platforms or other languages where rationale-annotated data can be produced.

Industry relevance. The findings point to a practical trade-off curve: an operator can tune α to buy explainability, and fairness on some metrics, at a small and measured cost to classification performance. The reported stability of Test Macro F1 across α values (from the 0.903 Portuguese baseline up to a 0.921 peak) suggests the alignment term does not destabilize production models, and the emphasis on avoiding false negatives on identity-targeted toxic content (GMB-BNSP) speaks directly to a moderation failure mode platforms care about.

Future Directions

  • Resolving the fairness trade-off. SRA is second-best on GMB-BNSP but weaker than BERT-based baselines on GMB-Subgroup and GMB-BPSN AUC; understanding why rationale supervision helps one fairness axis and not others is an open question.
  • Reducing dependence on expensive annotations. The authors note that rationale-annotated data is more costly than plain labels and limits scalability to new domains or languages; weaker supervision, transfer from high-resource languages, or model-generated rationales are natural extensions.
  • Investigating annotation quality and its effect on evaluation. The 335 identified problematic HateXplain cases and the +16.7% Test F1 on the filtered set raise the question of how much benchmark results understate real model performance and how annotator disagreement should be modeled.
  • Broadening architectural and linguistic coverage. The paper's ablations cover layers 6–11 and all attention heads for these two languages and models; testing other encoders, head-averaged attention variants, and additional languages would clarify how general the effect is.

Target Audience

  • NLP and XAI researchers working on self-explaining models, rationale supervision, or attention-based interpretability.
  • Trustworthy-AI and fairness researchers interested in how interpretability interventions affect bias metrics across demographic groups.
  • Practitioners building content moderation systems who need models whose decisions can be explained to reviewers and users, in English or Portuguese.
  • Graduate students with background in transformers and attention who want a worked example of combining classification loss with an auxiliary alignment loss and evaluating it on the ERASER-style explainability and GMB fairness suites.

Authors’ abstract

The opaque nature of deep learning models presents significant challenges for the ethical deployment of hate speech detection systems. To address this limitation, we introduce Supervised Rational Attention (SRA), a framework that explicitly aligns model attention with human rationales, improving both interpretability and fairness in hate speech classification. SRA integrates a supervised attention mechanism into transformer-based classifiers, optimizing a joint objective that combines standard classification loss with an alignment loss term that minimizes the discrepancy between attention weights and human-annotated rationales. We evaluated SRA on hate speech benchmarks in English (HateXplain) and Portuguese (HateBRXplain) with rationale annotations. Empirically, SRA achieves 2.4x better explainability compared to current baselines, and produces token-level explanations that are more faithful and human-aligned. In terms of fairness, SRA achieves competitive fairness across all measures, with second-best performance in detecting toxic posts targeting identity groups, while maintaining comparable results on other metrics. These findings demonstrate that incorporating human rationales into attention mechanisms can enhance interpretability and faithfulness without compromising fairness.

Read the original paper