Easy to use scripts to fine-tune GPT-2 Japanese model with your own text, to generate sentences, and to tweet them automatically.
git clone https://github.com/discus0434/text-generation.git
cd text-generationpip install -r requirements.txtconda create -n textgen python=3.9
echo "source activate textgen" > ~/.bashrc
conda run -n textgen pip install -r requirements.txtdocker build text-generation/. -t textgen
docker run -it --runtime=nvidia -d --restart=always textgen:latest bashModify permission of shell scripts
chmod +x scripts/shell/setup.sh
chmod +x scripts/shell/finetune.sh
chmod +x scripts/shell/generate.shRun setup.sh to download a pretrained model
scripts/shell/setup.shArrange .env file in the project directory.
.env file should look like this:
API_KEY = XXX
API_SECRET_KEY = XXX
BEARER_TOKEN = XXX
ACCESS_TOKEN = XXX
ACCESS_TOKEN_SECRET = XXXYou can not only make a Twitter bot but just generate sentences.
Arrange your text file you want to use in sample_texts/.
mv <your text file>.txt sample_texts/...or download someone's tweets with Python script to use it
python ./scripts/python/download_tweets.py -u <Twitter user ID> -max <number of tweets you will get>scripts/shell/finetune.shscripts/shell/generate.sh...Run all of cells in create_tweet.ipynb.
python ./scripts/python/create_tweets.py & disownThis code borrows from gpt2-japanese.
