BiCapsHate: Attention to the Linguistic Context of Hate via Bidirectional Capsules and Hatebase

Ashraf Kamal, Tarique Anwar, Vineet Kumar Sejwal, Mohd Fazil

Research output: Contribution to journalArticlepeer-review


Online social media (OSM) communications sometimes turn into hate-filled and offensive comments or arguments. It not just disrupts the social fabric online, but also leads to hate, violence, and crime, in the real physical world in worst scenarios. The existing content moderation practices of OSM platforms often fail to control the online hate. In this article, we develop a deep learning model called BiCapsHate to detect hate speech (HS) in OSM posts. The model consists of five layers of deep neural networks. It starts with an <italic>input</italic> layer to process the input text and follows on to an <italic>embedding</italic> layer to embed the text into a numeric representation. A <italic>BiCaps</italic> layer then learns the sequential and linguistic contextual representations, a <italic>dense</italic> layer prepares the model for final classification, and lastly the <italic>output</italic> layer produces the resulting class as either hate or non-HS (NHS). The <italic>BiCaps</italic> layer, being the most important component, effectively learns the contextual information with respect to different orientations in both forward and backward directions of the input text via capsule networks. It is further aided by our rich set of hand-crafted shallow and deep auxiliary features including the Hatebase lexicon, making the model <italic>well-informed</italic>. We conduct extensive experiments on five benchmark datasets to demonstrate the efficacy of the proposed BiCapsHate model. In the overall results, we outperform the existing state-of-the-art methods including fBERT, HateBERT, and ToxicBERT. BiCapsHate achieves up to 94% and 92% <italic>f-score</italic> on balanced and imbalanced datasets, respectively. Our complete source code is publicly available at GitHub repository

Original languageEnglish
Pages (from-to)1-12
Number of pages12
JournalIEEE Transactions on Computational Social Systems
Publication statusAccepted/In press - 2023

Bibliographical note

© 2023 IEEE


  • Capsule networks
  • Context modeling
  • Convolutional neural networks
  • Deep learning
  • Feature extraction
  • hate speech (HS) detection
  • Hatebase lexicon
  • Linguistics
  • long short-term memory (LSTM) networks
  • Numerical models
  • online social media (OSM)
  • Social networking (online)

Cite this