Git Product home page Git Product logo

blm-emotions's Introduction

BLM-emotions

Official code and data of the paper "An Analysis of Emotions and the Prominence of Positivity in #BlackLivesMatter Tweets" (PNAS 2022)

We release 1) the weights of the BERT model pre-trained with our BLM tweets with a masked language modeling objective and 2) emotion recognition models fine-tuned with our human-annotated data. You can find them from this gdrive folder

However, we do not make the raw data freely available to preserve anonymity and privacy as much as possible. Still, we will make tweet ids and annotated data available only for academic research upon request. Please fill out this form to request the data.

Prerequisite

  • change path_root in src_model/configs.py to your project directory path
  • install the following python packages: torch, tensorboard, pandas, transformers, emoji, wordsegment, scikit-learn

Training new emotion recognition models

  1. Prepare GoEmotions and HurricaneEmo dataset
bash scripts/download_emotion_datasets.sh
python src_model/preprocess_emotion_data.py

Executing the commands above will create a processed HurricaneEmo and GoEmotions dataset under data/processed-emotions, which can be used to train emotion recognition models. The two data sets use different emotion categories, but here we map both data sets into Ekman basic emotions using the mappings we defined in data/emo-mapping.

  1. Train emotion recognition models
bash scripts/train_binary_model.sh $target_emotion $bert_model
  • $target_emotion: one of six Ekman emotions (disgust, fear, anger, sadness, surprise, joy)
  • $bert_model: {blm, none}. blm indicates the bert-base-uncased model from HuggingFace transformers further pre-trained with our BLM tweets. If you do not provide anything to the bert_model argument (i.e., none) the code will use the base pre-trained bert model (bert-base-uncased).

Generating emotion labels for given input texts

bash scripts/generate_binary_emotion_labels.sh $target_emotion $trained_model_path $path_input_txt_file $path_output
  • $target_emotion: {disgust, fear, anger, sadness, surprise, joy}
  • $trained_model_path: path to a trained model you want to generate labels from, e.g., blm_joy.pt.
  • $path_input_txt_file: .txt file separated by lines
  • $path_output: path to save the output and their predictions

blm-emotions's People

Contributors

anjalief avatar chan0park avatar theocjr avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.