Source-linked AI summary

HABERTOR: An Efficient and Effective Deep Hatespeech Detector

Thanh Tran, Yifan Hu, Changwei Hu, Kevin Yen, Fei Tan, Kyumin Lee, Serim Park

arXiv:2010.08865v1cs.CLcs.AIcs.IRcs.LG

TL;DR

HABERTOR targets hatespeech detection under domain-specific language and large-scale user-generated content. It combines hateful-language pretraining with compact Quaternion factorization, multi-source ensemble heads, and adaptive adversarial training. The model outperforms 15 state-of-the-art detectors while being 4–5 times faster than BERT and using less than one-third of its memory.

  • Problem

    Hatespeech detection requires models that capture hateful language patterns while reducing the parameter and computational costs of BERT-based approaches.

  • Method

    HABERTOR pretrains a hateful language model and combines Quaternion factorization, multi-source ensemble heads, and fine-grained adaptive adversarial training.

  • Results

    HABERTOR outperforms 15 state-of-the-art hatespeech classifiers, is 4–5 times faster than BERT, and uses less than one-third of BERT's memory.

  • Takeaways & Limitations

    HABERTOR is presented as an efficient and effective alternative to BERT for hatespeech classification that generalizes to unseen hatespeech datasets.

  • Takeaways & Limitations

    FGM uses a scalar, manually specified noise magnitude, which the paper identifies as suboptimal because different adversarial directions can differ.

Abstract

from arXiv · show

We present our HABERTOR model for detecting hatespeech in large scale user-generated content. Inspired by the recent success of the BERT model, we propose several modifications to BERT to enhance the performance on the downstream hatespeech classification task. HABERTOR inherits BERT's architecture, but is different in four aspects: (i) it generates its own vocabularies and is pre-trained from the scratch using the largest scale hatespeech dataset; (ii) it consists of Quaternion-based factorized components, resulting in a much smaller number of parameters, faster training and inferencing, as well as less memory usage; (iii) it uses our proposed multi-source ensemble heads with a pooling layer for separate input sources, to further enhance its effectiveness; and (iv) it uses a regularized adversarial training with our proposed fine-grained and adaptive noise magnitude to enhance its robustness. Through experiments on the large-scale real-world hatespeech dataset with 1.4M annotated comments, we show that HABERTOR works better than 15 state-of-the-art hatespeech detection methods, including fine-tuning Language Models. In particular, comparing with BERT, our HABERTOR is 4~5 times faster in the training/inferencing phase, uses less than 1/3 of the memory, and has better performance, even though we pre-train it by using less than 1% of the number of words. Our generalizability analysis shows that HABERTOR transfers well to other unseen hatespeech datasets and is a more efficient and effective alternative to BERT for the hatespeech classification.

1 Introduction

Hatespeech detection must handle large-scale, domain-specific language while improving on BERT-based classifiers without retaining their computational cost. HABERTOR addresses this with a large hatespeech corpus, compact factorized architecture, multi-source heads, and adversarial training.

  • Hateful language is often informal, misspelled, and context-dependent, so identical words can receive different hate or non-hate labels.
  • The paper seeks better hatespeech prediction than state-of-the-art classifiers while significantly reducing the number of parameters compared with BERT.
  • Hatespeech datasets are typically small, motivating a new dataset containing 1.4M annotated comments from Yahoo News and Yahoo Finance.
  • HABERTOR reduces BERT parameters through Quaternion-based factorization while targeting lower training and inference time, memory use, and stronger classification performance.
  • The model is pretrained from scratch on hateful language and is intended to outperform fine-tuned public BERT models by learning hatespeech-specific patterns.
  • Multi-source ensemble heads and target-based adversarial training are added to improve predictive capability, effectiveness, and robustness.

2 Related Work

Earlier hatespeech detectors used engineered features, neural architectures, or pretrained language models, while later work also examined cross-dataset generalization. HABERTOR combines hateful-language pretraining, multi-source multi-head classification, and regularized adversarial training.

  • Earlier methods relied on manually engineered features with classical classifiers such as SVM, Random Forest, and Logistic Regression.
  • Deep-learning approaches included CNNs, recurrent networks, CNN-RNN combinations, and fine-tuned pretrained language models.
  • Researchers also tested hatespeech classifiers across Twitter, Wikipedia, Formspring, and YouTube comment datasets to examine generalization.
  • Unlike prior work, HABERTOR pretrains a hateful language model and combines multi-source multi-head classification with regularized adversarial training.

3 Problem Definition

The paper formulates hatespeech detection as mapping a token sequence to a probability that the sequence is hateful. A deep neural classifier is pretrained with language modeling and then trained for supervised classification.

  • Given a sequence s=[w_1,...,w_n], the classifier maps it to P(y=1|s)∈[0,1], the probability that s is hatespeech.
  • The model first undergoes unsupervised language-model pretraining to improve language understanding, then supervised hatespeech training produces the probability score.

4 Our approach – HABERTOR

HABERTOR compresses and adapts BERT for hatespeech detection through tokenizer and pre-training changes, Quaternion factorization, source-specific ensemble heads, and regularized adversarial training.

  • 4.2 Parameter Reduction with Quaternion Factorization: Quaternion transformations reduce parameters through shared Hamilton-product weights while retaining richer representations with real and imaginary components.The model applies vocabulary, attention, and output factorization strategies to BERT components.
  • 4.2 Parameter Reduction with Quaternion Factorization: 110M to 8.4M parameters: combined Quaternion factorization reduces HABERTOR's parameter count under BERT-base settings.With V=32k, H=768, L=12, E=128, C=192, and I=128, the compressed design reduces parameters from 110M to 8.4M.
  • Pre-training: HABERTOR pre-trains with masked-token and next-sentence prediction, generating τ masked instances per sequence to expose additional token combinations.Its preprocessing also tokenizes input sequences into sentences and constructs paired examples for next-sentence prediction.
  • Multi-source Ensemble Heads: Separate classification heads encode source-specific priors while sharing language knowledge, and pooling combines multiple heads for each source.Min, max, and mean pooling provide different strictness levels for declaring comments hateful or normal; the design generalizes to q sources and reduces to conventional BERT when h=1 with shared weights.
  • Regularized Adversarial Training: Learnable fine-grained noise scales adversarial perturbations by dimension, while regularization adds training cost but no inference-time parameters.The perturbation magnitude is constrained through a learnable vector and the overall objective combines hatespeech loss, adversarial loss, and an L2 regularization term.

5 Empirical Study

Experiments evaluate HABERTOR on Yahoo hatespeech data, compare factorized variants with language-model baselines, and test runtime, memory, transferability, and ablations. The results show strong performance with substantially lower computational cost and competitive transfer to Twitter and Wiki datasets.

  • Performance comparison: Compressing more components decreases performance, indicating a trade-off between model size and information retained by factorization.The directional Wilcoxon signed-rank test reports p-value < 0.05.
  • Performance comparison: HABERTOR variants outperform BERT-base on Yahoo News and Finance while using substantially fewer parameters.Except HABERTOR-VAFOQF, the proposed models improve F1 by 1.2% on Yahoo News and 1.5% on Yahoo Finance; HABERTOR saves 84M parameters and HABERTOR-VAFQF nearly 100M.
  • Running time and memory comparison: 1.6 times faster than TinyBERT, HABERTOR-VAFOQF reduces parameters while maintaining competitive training and inference speed.Experiments used four K80 GPUs and batch size 128.
  • Running time and memory comparison: 4∼5 times faster and 3.1 times smaller in GPU memory than BERT-base, HABERTOR-VAFOQF reduces memory use 3.6 times while remaining as effective.The reported memory savings may also support larger inference batch sizes.
  • Generalizability analysis: On Twitter, all HABERTOR models outperform BERT-base, while on Wiki they achieve F1 scores similar to BERT-base despite less Wiki pretraining.BERT-base benefits from pretraining on 2,500M Wiki words, whereas HABERTOR is pretrained on hateful data.
  • Ablation study: Ablations find benefits from larger or more fine-grained pretraining, multi-source ensemble heads, and fine-grained adaptive adversarial noise.The adaptive noise study assigns different noise magnitudes to different embedding dimensions on Twitter and Wiki.

6 Conclusion

HABERTOR is presented as an efficient and effective hatespeech detector that generalizes beyond its training data.

  • HABERTOR outperforms 15 state-of-the-art hatespeech classifiers and generalizes well to unseen hatespeech datasets.The model is reported to be 4–5 times faster, use less than one-third of BERT’s memory, and achieve better classification performance.

A.1 Parameter Estimation for pretraining HABERTOR with language model tasks

HABERTOR pretraining uses masked-token prediction and next-sentence prediction to learn from corrupted sequences and sentence relationships.

  • Pretraining objectives: Masked-token prediction reconstructs original sequences from corrupted versions by predicting masked tokens.The objective uses transformed token embeddings and a vocabulary-sized decoder.
  • Pretraining objectives: Next-sentence prediction minimizes binary cross-entropy for paired sequences labeled as consecutive or non-consecutive.The first-token [CLS] embedding summarizes the sequence for this prediction task.
  • Pretraining objectives: The combined language-model pretraining objective minimizes both loss functions L1 and L2.

A.2 Quaternion

Quaternion representations give HABERTOR a structured transformation with shared parameters across output dimensions.

  • Quaternion algebra: A Quaternion consists of one real component and three imaginary components, with Hamilton multiplication defining its transformation algebra.The paper uses Quaternion embeddings to represent word-piece embeddings.
  • Quaternion activation: The Quaternion activation uses a split function applying a standard Euclidean activation to Quaternion components.
  • Parameter reduction: 75% fewer parameters result because Hamilton-product weight sharing reuses four parameters across four output dimensions instead of sixteen independent parameters.The comparison contrasts a 16-parameter real-valued transformation with a four-parameter Quaternion transformation.

A.3 Analysis on the BERT’s Parameters

The parameter count of BERT grows quadratically with hidden size and linearly with vocabulary size and layer count.

  • BERT parameterization: A BERT layer contains 12H^2 parameters across attention, filtering, and output transformations.The attention, filtering, and output components each contribute 4H^2 parameters.
  • BERT parameterization: The attention component uses four H×H transformations to form and transform keys, queries, values, and attention outputs.
  • BERT parameterization: BERT-base with 12 layers has 144H^2 parameters before adding vocabulary-encoding parameters.Including vocabulary embeddings gives a total of VH + 144H^2 parameters.

A.4 50-50 Rule

The 50-50 rule calibrates next-sentence sampling so generated next and not-next sentence pairs are approximately balanced, including inputs that contain only one sentence.

  • A.4 50-50 Rule: The method samples next-sentence pairs so their count is roughly equal to the count of not-next-sentence pairs.For M splittable sequences and N single-sentence sequences, probabilities p1 and p2 are chosen to enforce this balance.
  • A.4 50-50 Rule: Figure 4 presents the BERT architecture from left to right, providing architectural context for the pretraining procedure.
  • A.4 50-50 Rule: The sampling probability for consecutive sentence pairs is derived from M and N under the constraint p1 + p2 = 1.The supplied derivation gives p1 = (M+N)/(2M+N).

A.5 Baselines and Hyper-parameter Settings

The evaluation compares HABERTOR with a broad set of hatespeech baselines under specified pretraining and fine-tuning settings, then tests its components through ablations. The ablations support regularized adversarial training, pretraining, and multi-source ensemble heads, while indicating that deeper or wider attention configurations are not uniformly better.

  • A.5 Baselines and Hyper-parameter Settings: The baseline suite includes traditional classifiers, recurrent and convolutional models, Quaternion Transformer, compressed BERT variants, ALBERT, and BERT-base.BOW and NGRAM systems are paired with Naive Bayes, Random Forest, Logistic Regression, and Xgboost, with the best result reported.
  • A.5 Baselines and Hyper-parameter Settings: HABERTOR uses a 40k vocabulary, 60 pretraining epochs, batch size 768, and separate two-head classification nets for each input source.Learning rates are 5e-5 for masked-token and next-sentence prediction, and 2e-5 for hatespeech prediction.
  • A.6 Ablation Study: Removing regularized adversarial training lowers AP and F1-score by 1.16% and increases average error rate by 0.78%.The average error rate is the average of FPR@5%FNR and FNR@5%FPR.
  • A.6 Ablation Study: Using masking factor τ = 1 instead of τ = 10 further reduces AP by 0.92% and F1-score by 0.24%, while increasing average error rate by 1.01%.The comparison is made without regularized adversarial training.
  • A.6 Ablation Study: Multi-source classification with an ensemble of 2 heads outperforms multi-source single-head and single-source single-head variants, while at least 4 heads provide no further improvement.
  • A.6 Ablation Study: Removing pretraining causes AUC to drop ∼2%, AP ∼5%, F1 4%, and FPR and FNR errors to rise ∼9% and ∼5%, respectively.The comparison uses HABERTOR-adv + τ = 1 with and without the language-model pretraining step.
Loading 2010.08865v1…