Accelerating Hate Speech Classification with GPUs: A Multi-layer Approach with String Matching and Transformers
摘要
The rise of social media has brought with it a deluge of user-generated content, creating a breeding ground for hate speech. Traditional methods for detecting hate speech, such as manual reporting, are overwhelmed by the vast amount of data and the ever-evolving nature of hateful language. This necessitates faster and more adaptable automated detection methods. This paper proposes a novel three-layer model that leverages the strengths of different natural language processing (NLP) techniques for efficient and adaptable hate speech detection. The first layer utilizes a String Matcher for swift filtering of messages containing predefined hate speech patterns. The second layer employs a Linguistic Matcher for more complex analysis, considering grammar and word meaning. Finally, a pre-trained Transformer Classifier handles messages that bypass the initial filtering stages. Additionally, the Transformer Classifier achieves an accuracy of 88% in binary hate speech classification after fine-tuning the model with a user-reported dataset of messages flagged as spam or inappropriate. This hybrid approach prioritizes faster layers for initial processing, significantly reducing the computational burden on the powerful but resource-intensive Transformer model. Our experiments on the GPU demonstrate that the String Matcher achieves processing times up to 26 times faster than the Transformer, while the Linguistic Matcher also offers faster speeds. This layered approach offers a promising solution for social media platforms to address the growing challenge of online hate speech, enabling faster detection and a more efficient use of computational resources.