Skip to content
/ BOLT Public

Code for ACL 2023 paper "BOLT: Fast Energy-based Controlled Text Generation with Tunable Biases".

Notifications You must be signed in to change notification settings

launchnlp/BOLT

Repository files navigation

BOLT

This is the implementation of ACL 2023 paper BOLT: Fast Energy-based Controlled Text Generation with Tunable Biases.

Environment Setup

cd ./transformers
pip install -e .
cd -

Download Discriminators

You can download the discriminators from here and put them under ./checkpoints. These roberta-based discriminators are trained on the Yelp dataset and the Jigsaw dataset, whose embeddings are replaced with the GPT2-large embeddings.

Sentiment Control

SENTIMENT=pos
# SENTIMENT=neg
SEQLEN=20
python sentiment_generate_with_bias.py $SEQLEN $SENTIMENT

The generated sentences will be saved in ./sentiment/sentiment/.

Toxicity Avoidance

SEQLEN=20
python detoxic_generate_with_bias.py $SEQLEN

The generated sentences will be saved in ./detoxic/detoxic/.

Keyword-guided Topic Control

SEQLEN=20
TOPIC=computer
python keywords_generate_with_bias.py $SEQLEN $TOPIC

The generated sentences will be saved in ./keywords/keywords/.

About

Code for ACL 2023 paper "BOLT: Fast Energy-based Controlled Text Generation with Tunable Biases".

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published