Abstract
The tremendous growth of social media users interacting in online conversations has led to significant growth in hate speech affecting people from various demographics. Most of the prior works focus on detecting explicit hate speech, which is overt and leverages hateful phrases, with very little work focusing on detecting hate speech that is implicit or denotes hatred through indirect or coded language. In this paper, we present CoSyn, a context synergized neural network that explicitly incorporates user- and conversational-context for detecting implicit hate speech in online conversations. CoSyn introduces novel ways to encode these external contexts and employs a novel context interaction mechanism that clearly captures the interplay between them, making independent assessments of the amounts of information to be retrieved from these noisy contexts. Additionally, it carries out all these operations in the hyperbolic space to account for the scale-free dynamics of social media. We demonstrate the effectiveness of CoSyn on 6 hate speech datasets and show that CoSyn outperforms all our baselines in detecting implicit hate speech with absolute improvements in the range of 1.24% - 57.8%. We make our code available.
The problem
Most hate speech detectors are built for explicit hate: overt slurs and hateful phrases that keyword-based systems and text classifiers can pick up. Implicit hate is delivered through sarcasm, euphemism, stereotypes, and coded language, and it has been used by extremist groups precisely because it evades such filters while preserving deniability.
In online conversations the problem gets harder. Replies and comments are short reactions to a parent post and carry little linguistic signal of their own. The example in the paper is a factual statement about a location, followed by a sarcastic reply that only reads as hateful in context. Prior work, including the Latent Hatred benchmark and knowledge-graph based classifiers, treats utterances in isolation and ignores conversational context, even though it accounts for a large share of implicit hate online. We extend the definition of implicit hate speech to cover utterances that convey hate only in the context of the dialogue, and build a model for it.
Approach
CoSyn classifies whether a target utterance in a conversation tree implies hate, using two external contexts: the author’s personal context (historical and social) and the conversational context. It has four components, and everything after the encoder runs in hyperbolic space because both social graphs and conversation trees are scale-free (power-law degree distributions and low hyperbolicity, measured across the datasets).
- Bias-invariant encoder. A SentenceBERT encoder is fine-tuned with an additional loss over self-attention maps and ground-truth hate spans, which reduces keyword bias, a long-standing problem in hate speech classification.
- Hyperbolic Fourier Attention Network (HFAN). A user’s past utterances are encoded, passed through a 2D Discrete Fourier Transform (over time and embedding dimensions) to surface recurring ideologies and opinions, then through a Hyperbolic GRU and Hyperbolic Attention with an Einstein midpoint to produce a historical user representation.
- Hyperbolic Graph Convolutional Network (HGCN). Users are nodes in a social graph with retweet, mention, reply, and follow edges. HGCN aggregates neighbours’ HFAN representations in the Poincare ball so a user’s embedding also reflects their community.
- Context-Synergized Hyperbolic Tree-LSTM (CSHT). A bidirectional Tree-LSTM in hyperbolic space walks the conversation tree. Its cell takes both the utterance and the author’s user context as inputs and uses separate gates to decide independently how much to take from each noisy source, then a dense layer and binary cross-entropy produce the prediction.
Example
One of the four ICHCL test conversation trees from Figure 4 of the paper. Locations appear anonymised as #LOC. The comment carries no hateful keyword and only reads as hostile in the context of the parent post and the author’s history.
Input: conversation tree
- User 7 (parent post): At the high-level meeting, key decisions of waiving customs duty on oxygen and oxygen related equipment; COVID-19 vaccines were taken.
- User 8 (comment, target): High level meeting was the excuse I made in college events I was organizing, when there was a problem
- User 9 (reply): Thank you #LOC f**** sake. About time. #LOC needs to learn from this and be well prepared for these types of events.
Output: prediction for the comment by User 8 (gold: implicit hate)
- SentenceBERT with classification head: wrong
- CoSyn without user context: wrong
- CoSyn: hateful (correct)
Output: prediction for the reply by User 9 (gold: explicit hate)
- SentenceBERT with classification head: wrong
- CoSyn without user context: correct
- CoSyn: hateful (correct)
Results
We evaluate on six conversational hate speech datasets (Reddit, GAB, DIALOCONAN, CAD, ICHCL, and Latent Hatred), reporting micro-F1 averaged over 3 seeds. Because the original datasets do not mark implicit versus explicit hate, we added MTurk annotations (three workers per utterance, with complete conversations shown) to evaluate an implicit subset.
| Overall F1 | CAD | DIALOCONAN | GAB | ICHCL | Latent Hatred | |
|---|---|---|---|---|---|---|
| SentenceBERT | 71.12 | 46.89 | 46.23 | 50.31 | 79.86 | 58.82 |
| DUCK | 60.10 | 30.66 | 28.60 | 62.78 | 78.36 | 56.00 |
| MRIL | 58.91 | 34.41 | 40.82 | 61.21 | 66.71 | 57.32 |
| Madhu et al. | 70.58 | 50.47 | 46.45 | 52.94 | 82.01 | 59.52 |
| CoSyn (ours) | 76.23 | 73.26 | 51.02 | 66.71 | 89.53 | 64.65 |
Source: Table 1 of the paper, overall micro-F1 on the full test sets; four of the thirteen baselines shown. Higher is better.
| Implicit-subset F1 | CAD | DIALOCONAN | GAB | ICHCL | Latent Hatred | |
|---|---|---|---|---|---|---|
| SentenceBERT | 76.05 | 49.01 | 34.75 | 40.03 | 37.32 | 38.46 |
| Graph NLI | 26.03 | 47.40 | 24.11 | 42.12 | 26.53 | 48.25 |
| FinerFact | 27.11 | 26.25 | 15.60 | 18.50 | 32.27 | 52.04 |
| Madhu et al. | 76.79 | 51.77 | 36.96 | 41.15 | 39.56 | 40.72 |
| CoSyn (ours) | 81.12 | 57.59 | 52.98 | 45.00 | 46.03 | 53.28 |
Source: Table 1 of the paper, micro-F1 on the MTurk-annotated implicit subsets. Higher is better.
| Ablation (average over 6 datasets) | Overall F1 | Implicit F1 | Comment F1 | Reply F1 |
|---|---|---|---|---|
| CoSyn (ours) | 70.23 | 56.00 | 46.73 | 49.32 |
| without DFT | 67.54 | 54.52 | 45.22 | 46.92 |
| without HFAN | 66.62 | 54.68 | 45.44 | 47.04 |
| without HGCN | 66.56 | 53.28 | 45.12 | 46.32 |
| without HFAN and HGCN | 65.29 | 52.14 | 42.91 | 46.29 |
| without user context | 62.31 | 48.72 | 39.88 | 41.19 |
| bidirectional to unidirectional CSHT | 68.67 | 55.29 | 46.09 | 47.53 |
| hyperbolic to Euclidean | 66.47 | 54.83 | 45.44 | 47.41 |
Source: Table 2 of the paper. Higher is better.
- CoSyn outperforms every baseline on both the full datasets and the implicit subsets, including the bias-invariant SentenceBERT baseline, which was the strongest competitor.
- Full-dataset absolute improvements over baselines: 5.1-35.2% on Reddit, 4.0-45.0% on CAD, 4.8-22.4% on DIALOCONAN, 3.9-42.7% on GAB, 9.7-38.4% on ICHCL, and 5.8-31.6% on Latent Hatred; on the implicit subsets, 5.1-57.9%, 8.6-31.3%, 18.2-40.7%, 2.9-28.5%, 8.2-19.5%, and 1.2-18.1% respectively.
- User context is the largest single contributor: removing it drops overall F1 from 70.23 to 62.31, and modelling it with HFAN and HGCN beats feeding mean-pooled history embeddings into CSHT. Replacing hyperbolic with Euclidean operations costs 3.8% F1.
- CoSyn has high precision on implicit hate, meaning fewer false positives than the baselines. The ICHCL trees in Figure 4 show that hateful users are strongly homophilous and consistently hateful over time, which is exactly the signal HFAN and HGCN capture.
Datasets
| Dataset | Train convs. | Val convs. | Test convs. | Implicit (train) | Explicit (train) |
|---|---|---|---|---|---|
| 13,382 | 4,461 | 4,461 | 1,160 | 905 | |
| Latent Hatred | 12,485 | 4,162 | 4,162 | 3,246 | 590 |
| CAD | 13,584 | 4,526 | 5,307 | 1,004 | 1,507 |
| GAB | 18,300 | 6,100 | 6,100 | 2,435 | 3,653 |
| DIALOCONAN | 11,675 | 2,436 | 2,514 | 1,575 | 4,262 |
| ICHCL | 4,643 | 1,348 | 1,097 | 1,006 | 1,383 |
Source: Tables 3-8 of the paper. Implicit and explicit counts are the MTurk annotations on the hateful training utterances.
Resources
- Paper: ACL Anthology · arXiv:2303.03387 · Hugging Face papers
- Code: github.com/MananSuri27/CoSyn (mirror at github.com/Sreyan88/CoSyn)
- Related: ACLM, our ACL 2023 work on data augmentation for complex NER
- All publications
Quick start
From the repository README (torch 1.11.0, geoopt 0.1.0, dgl 1.0.0):
git clone https://github.com/MananSuri27/CoSyn
cd CoSyn
pip3 install -r requirements.txt
# move the hyperbolic graph convolution into dgl
mv CoSyn/models/hgconv.py path-to-dgl/dgl/python/dgl/nn/pytorch/conv/
# build conversation trees and the social graph, then train
python3 utils/graphs.py
python3 utils/socialgraph.py
python3 main.py
