This repo is the code implementation for "Generate, Prune, Select: A Pipeline for Counterspeech Generation against Online Hate Speech" (ACL-IJCNLP Findings 2021).
This project aims at counterspeech generation, which is, for a given hate speech instance, to generate a counter response intending to de-escalate the hateful setting. An illustrative example pair is shown in Table 1, where the counterspeech was manually crafted in response to the hate speech instance.
Our model consists of three modules:
- A Candidate Generation module that uses a generative model to create a large number of diverse response candidates for selection.
- A Candidate Pruning module that leverages a pretrained contextualized language model (BERT) to filter the candidate pool and eliminate ungrammatical candidates.
- A Response Selection module that utilizes a retrieval-based response selection model to select the most relevant counterspeech from the pruned candidate pool.
The code is based on Python 3.7. Please install the dependencies as below:
pip install -r requirements.txt
Reddit, Gab: Please download the data from A Benchmark Dataset for Learning to Intervene in Online Hate Speech (EMNLP2019) and put the two .csv
files in the folder ./data/A-Benchmark-Dataset-for-Learning-to-Intervene-in-Online-Hate-Speech-master/
CONAN: Please download the data from CONAN - COunter NArratives through Nichesourcing: a Multilingual Dataset of Responses to Fight Online Hate Speech (ACL2019) and put the CONAN.json
file in the folder ./data/CONAN/
First, extract all counterspeech in the training dataset to a .txt
file under ./data/
. Each counterspeech takes one line.
An example is ./data/sample_for_VAE.txt
.
Then, the module has two steps: generative model training and candidate generation. Please run:
python ./VAE_Text_Generation.py --dataset reddit --training
Please download our pretrained grammaticality classifier here, unzip it, rename the folder grammar_cola
and put it under ./tmp/
.
python ./Main.py --dataset reddit
- A Benchmark Dataset for Learning to Intervene in Online Hate Speech (EMNLP 2019) [Paper] [Code]
- CONAN - COunter NArratives through Nichesourcing: a Multilingual Dataset of Responses to Fight Online Hate Speech (ACL 2019) [Paper] [Code]
- Generating Sentences from a Continuous Space (CoNLL 2016) [Paper] [Code]
- Training Neural Response Selection for Task-Oriented Dialogue Systems (ACL 2019) [Paper] [Code]
@inproceedings{zhu2021generate,
title = {Generate, Prune, Select: A Pipeline for Counterspeech Generation against Online Hate Speech},
author = {Zhu, Wanzheng and Bhat, Suma},
booktitle = {Proceedings of the 59th Annual Meeting of the Association for Computational Linguistics and the 11th International Joint Conference on Natural Language Processing (ACL-IJCNLP): Findings},
year = {2021}
}