hBERT + BiasCorp - Fighting Racism on the Web

Olawale Onabola, Zhuang Ma, Yang Xie, Benjamin Akera, Abdulrahman Ibraheem, Jia Xue, Dianbo Liu, Yoshua Bengio

Abstract

Subtle and overt racism is still present both in physical and online communities today and has impacted many lives in different segments of society. In this work, we present how we are tackling this societal issue with Natural Language Processing. We introduce BiasCorp, a dataset containing 139,090 comments and news segments from Fox News, Breitbart News, and YouTube. We also present hBERT, a modified BERT architecture where certain layers are replaced with Hopfield Layers. hBERT generalizes well across different distributions with the added advantage of reduced model complexity. Finally, we release a JavaScript library and a Chrome Extension to help developers and users identify and report racially biased content on the web.

Introduction

Detecting racism online is a "moving target" problem. Language evolves, and users employ "mischievous permutations" (like leetspeak) to evade filters. While Large Language Models (LLMs) like BERT are powerful enough to handle these nuances, they are notoriously "heavy"—possessing millions of parameters that make them difficult to run directly in a web browser or on a mobile device. Furthermore, existing datasets for hate speech are often small or lack the specific "implicit bias" found in comment sections of mainstream news outlets. We aim to bridge this gap by providing both a high-quality dataset and a specialized, efficient model architecture capable of running "on the edge."

Methods: The hBERT Architecture

The core innovation of hBERT (Hopfield-BERT) lies in the modification of the "top" layers of the model. Standard BERT uses self-attention, which is computationally expensive. We replaced the self-attention mechanism in the final layers with a Hopfield layer. This layer uses a modified energy update rule from modern Hopfield networks to approximate the functionality of attention with significantly lower parameter complexity.

Additionally, we employ Hopfield Pooling. This acts as a form of "associative memory," storing hidden states from the final layer to better capture task-specific features before classification. This reduction in complexity allows for deployment via tools like biasjs (a JavaScript library) and a Chrome extension, enabling real-time detection directly in the browser.

The BiasCorp Dataset

BiasCorp contains 139,090 rows of data sourced from Fox News, Breitbart News, and YouTube. To date, 45,000 samples have been manually annotated via Amazon Mechanical Turk. To ensure the model learned more than just "bad words," we used a sentiment-based filtering process. We targeted comments with low sentiment scores containing racial keywords and matched them with "random control" comments from the same threads to create a balanced 50/50 split of discriminatory vs. non-discriminatory text.

To manage disagreements between human annotators, we utilized the Coefficient of Variation (CV). This metric allows us to account for the confidence levels of the annotators during training, ensuring the model is robust to the inherent subjectivity of bias detection.

Distribution of Bias and Confidence Scores (Coefficient of Variation) across the BiasCorp dataset.

Key Results

The hBERT model demonstrated superior performance over a standard BERT baseline across several metrics. It achieved a Top-1 Accuracy of 0.6406, compared to the baseline's 0.6015, and the Mean Average Precision (mAP) rose from 0.2935 to 0.3501. Across various "Top-K" scenarios, hBERT consistently showed higher F1 scores and Intersection over Union (IoU) metrics.

Training and validation loss comparison between hBERT and the standard BERT baseline over 4 epochs.

Crucially, the reduction in model complexity did not result in a performance penalty. Instead, hBERT showed improved generalization across different distributions (e.g., training on news comments but testing on YouTube), suggesting that the Hopfield-based attention approximation is highly robust for this task.

Conclusion and Future Work

While hBERT represents a significant step forward, the overall mAP of 0.35 highlights the extreme difficulty of automated racism detection. Future work will focus on expanding bias categories to include gender and other protected characteristics, further optimization via Gaussian Kernels and quantization for faster browser performance, and completing the manual labeling for the remaining ~94,000 rows of the BiasCorp dataset.

Summary updated

BibTeX
@inproceedings{onabola2021hbert,
  author = {Olawale Onabola and Zhuang Ma and Yang Xie and Benjamin Akera and Abdulrahman Ibraheem and Jia Xue and Dianbo Liu and Yoshua Bengio},
  title = {{hBERT + BiasCorp - Fighting Racism on the Web}},
  booktitle = {LT-EDI@EACL},
  year = {2021},
  url = {https://openreview.net/forum?id=cDbkdLGCDk},
}
Figure