Skip to content

A tool for detecting moral values in social discourse

License

Notifications You must be signed in to change notification settings

vjosapreniqi/MoralBERT

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MoralBERT: A Fine-Tuned Language Model for Capturing Moral Values in Social Discussions

This repository contains the code for the MoralBERT paper accepted at ACM GoodIT 2024 (click here for the paper). The work involves training BERT models to predict moral values from social media text. Baseline models, including a lexicon-based model and a machine learning model, are also provided.

MoralBERT Web App

If you want to apply moral automatic annotation in your text without having to write any code, head over to MoralBERTApp.

Repository Structure

1. MoralBERT

This folder contains Python Jupyter Notebook files for training MoralBERT and predicting moral values in text. The models are fine-tuned on annotated social media datasets and are designed to understand and predict the representation of moral values based on the Moral Foundations Theory (MFT). The code demonstrates the prediction of 10 moral foundations, each handled individually by a single classification model. You can also include Liberty/Oppression (when the data is available and annotated accordingly) using the same script.

1.1. Leveraging Deployed Model Weights on Hugging Face for MFT Predictions

The pre-trained weights of our models are now available on Hugging Face, enabling rapid utilisation of the MoralBERT models to compute moral scores for any text and store the results in a DataFrame. To apply these models, please refer to the MoralBert/Predict_mft_scores_from_the_MoralBERT_weights.ipynb script. The weights for the liberty/oppression dimension are not yet released, as we are still working on refining this aspect of the model.

2. Baselines

This folder hosts Python Jupyter Notebook files for baseline models built with the MoralStrength Lexicon (see the paper and the GitHub page) and a Word2Vec with Random Forest Model using scikit-learn machine learning library.

3. GPT4

This folder hosts Python Jupyter Notebook file for utilising GPT-4 zero shot classification model for predicting moral foundations.

4. Data

To fine-tune the models with the same data, please download the datasets as follows:

About

A tool for detecting moral values in social discourse

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published