---
title: 'RV-HATE: Modular Ensemble for Hate Speech'
url: https://www.emergentmind.com/topics/rv-hate
type: topic
---

# RV-HATE: Modular Ensemble for Hate Speech

RV-HATE is a modular ensemble framework for implicit hate speech detection that employs reinforcement-learned soft voting to optimize dataset-specific performance. The architecture is explicitly designed to address the heterogeneity of hate speech datasets, which arise from divergent linguistic patterns, social contexts, and annotation schemes. By integrating multiple specialized modules and adapting their ensemble weights to each target dataset via policy optimization, RV-HATE achieves both improved classification accuracy and quantitative interpretability with respect to critical features for a given corpus [2510.10971].

## 1. Multi-Module Architecture

RV-HATE comprises four distinct modules, each producing a two-class logit vector $z_k(x) = [z_k^{(0)}(x), z_k^{(1)}(x)]$ for input text $x$. Modules are independently fine-tuned and are as follows:

- **$M_0$: Clustering-based Contrastive Learning**
  - Input: raw sentence $x$
  - Encoder: BERT-base generates embedding $h_0(x) \in \mathbb{R}^d$
  - Clustering: training embeddings clustered into $K$ clusters; center $c_j$ is cluster mean
  - Anchor selection: $a_j = \operatorname{argmax}_x \cos(h_0(x), c_j)$
  - Contrastive loss (SharedCon, cosine): 
    $$
    L_0 = -\frac{1}{N} \sum_{i=1}^N \log \frac{\exp(\cos(h_0(x_i), h_0(x_p))/\tau)}{\sum_{n \neq i} \exp(\cos(h_0(x_i), h_0(x_n))/\tau)}
    $$
    where $x_p$ is a positive pair for anchor $x_i$, $\tau$ is temperature.

- **$M_1$: Target-Tagging with [TARGET] Tokens**
  - Input: $x$ with NER-derived “[TARGET]” spans, marking ORG/NORP/GPE entities (spaCy + GPT-4o)
  - Encoder: BERT-base, contrastive objective $L_1$ as $L_0$, but with tagged input.

- **$M_2$: Outlier Removal within Clusters**
  - Procedure as in $M_0$, but with outliers removed. Distance $d_i = \|h_2(x_i) - c_j\|_2$; outliers above $Q_3 + 1.5 \cdot \mathrm{IQR}$ are excluded before computing loss $L_2$.

- **$M_3$: Hard Negative Sampling**
  - Maintains a queue $N$ of hard negatives (samples of opposing class with high similarity or false positives with high confidence)
  - Contrastive loss $L_3$ draws negatives from both batch and $N$.

Each module outputs logits via a classification head $f_k(h_k(x)) \to z_k(x)$.

## 2. Reinforcement Learning-Based Weight Selection

Weights $w = [w_0, w_1, w_2, w_3]$, $w_k \geq 0$, $\sum_k w_k = 1$, modulate module contributions for a specific dataset. Weight selection is formulated as a one-step Markov decision process:

- **State**: compact vector of dataset statistics, e.g., ratio of “[TARGET]” tags, outlier rate, implicit hate ratio.
- **Action**: weights $w$ in the four-dimensional simplex $\Delta^4$.
- **Policy**: $\pi_\theta(w|s)$, parameterized via a two-layer MLP, outputs Dirichlet or softmax pre-weights.
- **Reward**: macro-F1 score on the validation set for predictions with weights $w$:
  $$
  r = \mathrm{F1}_{\mathrm{macro}}(w)
  $$
- **Optimization**: Proximal Policy Optimization (PPO) is used, with surrogate loss
  $$
  L^{\mathrm{PPO}}(\theta) = \mathbb{E}_t \left[ \min \left( r_t(\theta) \hat{A}_t, \;\mathrm{clip}(r_t(\theta),1-\epsilon,1+\epsilon) \hat{A}_t \right) \right]
  $$
  where $r_t(\theta)$ is the ratio $\pi_\theta(w_t|s)/\pi_{\theta_{\mathrm{old}}}(w_t|s)$ and $\epsilon=0.2$.

A single PPO policy is trained for $\approx 10\,000$ steps to optimally select $w$ per dataset.

## 3. Ensemble Voting and Prediction

For sample $x$, each module $k$ outputs logits $z_k(x)$ for classes $h\in\{0,1\}$. The ensemble logit for class $h$ is
$$
Z^{(h)}(x; w) = \sum_{k=0}^3 w_k \cdot z_k^{(h)}(x).
$$
Final prediction is
$$
\hat{y}(x) = \arg\max_{h \in \{0,1\}} Z^{(h)}(x; w).
$$
Since weights are nonnegative and sum to one, further normalization is unnecessary.

## 4. Training Procedure and Dataset Adaptation

Each module is independently trained for six epochs on the target dataset via the objective
$$
L_k = L_{\mathrm{CL}(k)} + \lambda \cdot L_{\mathrm{CE}}(f_k(h_k(x)), y)
$$
where $L_{\mathrm{CL}}$ is module-specific contrastive loss, $L_{\mathrm{CE}}$ is cross-entropy with ground-truth label $y$, and $\lambda \in \{0.5, 0.75\}$.

After training and freezing module parameters, PPO optimizes voting weights $w$ based on dataset-specific state. The learned policy generates test-time weights $w^*$, with macro-F1 evaluated on the test partition. This two-stage approach (independent module adaptation, then ensemble weight optimization) ensures both flexibility and dataset sensitivity.

## 5. Interpretability and Attribution

RV-HATE’s learned weights $w_k$ provide quantitative attribution of module importance for each dataset. For example, on the IHC dataset, mean learned weights are $[0.19, 0.26, 0.17, 0.36]$ for $M_0$ through $M_3$ respectively. Ablation, by zeroing out each $w_k$ and renormalizing, yields $\Delta\mathrm{F_1}_k$, directly quantifying the macro-F1 impact of every module. These two metrics together—module weights and ablation performance—yield interpretable insights into which linguistic or contextual properties are most predictive per corpus. This suggests that RV-HATE not only adapts to but exposes data-specific cues and vulnerabilities.

## 6. Empirical Results and Dataset Coverage

The framework was evaluated on five English hate speech benchmarks:

| Dataset   | Instances   | Characteristics                                 |
|-----------|-------------|--------------------------------------------------|
| IHC       | 22 K        | Implicit hate, human implications (tweets)      |
| SBIC      | 150 K       | Offensiveness and target-entity labels          |
| DYNA      | ~41 K       | Adversarially constructed hate speech           |
| Hateval   | 13 K        | Targets: immigrants/women, Twitter-based        |
| Toxigen   | 6 K         | Machine-generated toxic/benign examples         |

Performance comparison (macro-F1; average of 3 seeds):

| Model             |  IHC  | SBIC  | DYNA  | Hateval | Toxigen |  Avg  |
|-------------------|-------|-------|-------|---------|---------|-------|
| CE                | 77.70 | 83.80 | 78.80 | 81.11   | 90.06   | 82.29 |
| SCL               | 77.81 | 82.92 | 80.39 | 81.28   | 90.75   | 82.63 |
| SharedCon (SOTA)  | 78.50 | 84.30 | 79.10 | 80.24   | 91.21   | 82.67 |
| LAHN              | 78.40 | 83.98 | 79.64 | 80.42   | 90.42   | 82.57 |
| RV-HATE           | 79.07 | 84.62 | 81.82 | 83.44   | 93.41   | 84.47 |

RV-HATE yields a mean improvement of +1.8 percentage points in macro-F1 over SharedCon, indicating the efficacy of dataset-aware modular weighting.

## 7. Technical Configuration and Resources

Key implementation specifications include:

- Backbone: BERT-base-uncased (110M parameters)
- Embeddings for contrastive sampling: SimCSE (unsupervised)
- Optimizer: AdamW, learning rate $2\!\times\!10^{-5}$ or $3\!\times\!10^{-5}$, batch size 32
- Contrastive temperature $\tau=0.3$, $\lambda \in \{0.5, 0.75\}$, cluster count $K \in \{20, 75, 125\}$
- PPO: 10,000 steps, $\epsilon=0.2$, advantage via GAE, policy MLP with 2 layers (64 units)
- Hardware: NVIDIA RTX 4090, 3 random seeds

A plausible implication is that the modular and dataset-conditioned design of RV-HATE is well-suited to fields characterized by substantial domain and distribution drift, as both its architecture and adaptation procedure are systematized to expose and leverage dataset-specific linguistic phenomena [2510.10971].

Source: https://www.emergentmind.com/topics/rv-hate