A simple twitter bot, trained on this gpt-2-simple model.
Create a Twitter application and generate a Consumer Key, Consumer Secret, Access Token, and Access Token Secret.
An easy-to-use Python library for accessing the Twitter API
The easiest way to install the latest version from PyPI is by using pip:
pip install tweepy
A simple Python package that wraps existing model fine-tuning and generation scripts for OpenAI's GPT-2 text generation model
You can use gpt-2-simple to retrain a model using a GPU for free in this Colaboratory notebook
only required if you want to use the post_tweets.py file to post your tweets
gpt-2-simple can be installed via PyPI:
pip3 install gpt-2-simple
You will also need to install the corresponding TensorFlow for your system (e.g. tensorflow
or tensorflow-gpu
). TensorFlow 2.0 is currently not supported and the package will throw an assertion if loaded, so TensorFlow 1.14/1.15 is recommended.
For more info about gpt-2-simple, go here
Just change the value "TwitterUsername" in download_tweets.py by the name of the account you want to download the tweets from.
if __name__ == "__main__":
for user in ["TwitterUsername"]:
download_all_tweets(user)
Output goes in downloaded_tweets.txt
Once you have your tweets, follow the steps in the Colaboratory Notebook
Note that without a lot of data, the model might overfit and output existing tweets, if that’s the case, you may want to train for fewer steps (between 200-500)
Automate the model refining and tweets posting using Google Cloud Platform Services.