Skip to content

Generate, Prune, Select: A Pipeline for Counterspeech Generation against Online Hate Speech (ACL-IJCNLP 2021 Findings)

License

Notifications You must be signed in to change notification settings

WanzhengZhu/GPS

Repository files navigation

Python 3.7 License: MIT

Generate, Prune, Select: A Pipeline for Counterspeech Generation against Online Hate Speech

Table of Contents

Introduction

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:

  1. A Candidate Generation module that uses a generative model to create a large number of diverse response candidates for selection.
  2. A Candidate Pruning module that leverages a pretrained contextualized language model (BERT) to filter the candidate pool and eliminate ungrammatical candidates.
  3. A Response Selection module that utilizes a retrieval-based response selection model to select the most relevant counterspeech from the pruned candidate pool.

Requirements

The code is based on Python 3.7. Please install the dependencies as below:

pip install -r requirements.txt

Data

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/

Code:

Module 1: Candidate Generation

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

Module 2: Candidate Pruning

Please download our pretrained grammaticality classifier here, unzip it, rename the folder grammar_cola and put it under ./tmp/.

Module 3: Response Selection

python ./Main.py --dataset reddit

Related Papers and Repositories

  • 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]

Citation

@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}
}

About

Generate, Prune, Select: A Pipeline for Counterspeech Generation against Online Hate Speech (ACL-IJCNLP 2021 Findings)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages