This is the implementation of ACL 2023 paper BOLT: Fast Energy-based Controlled Text Generation with Tunable Biases.
cd ./transformers
pip install -e .
cd -
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=pos
# SENTIMENT=neg
SEQLEN=20
python sentiment_generate_with_bias.py $SEQLEN $SENTIMENT
The generated sentences will be saved in ./sentiment/sentiment/
.
SEQLEN=20
python detoxic_generate_with_bias.py $SEQLEN
The generated sentences will be saved in ./detoxic/detoxic/
.
SEQLEN=20
TOPIC=computer
python keywords_generate_with_bias.py $SEQLEN $TOPIC
The generated sentences will be saved in ./keywords/keywords/
.