Inspiration

We thought it would be fun to generate fake tweets and see what the ML algorithm picked up from each user

What it does

It runs OpenAI's GPT-2 Transformer model with three pretrained models each trained on either Trump, Obama, or Nicki Minaj's tweets to generate tweets.

How I built it

Kubernetes Cluster on Cloud Run set up with Docker and basic starlette app to send HTTP POST requests from any source (mobile, web, python shell, etc)

We also built a website and a mobile app

If you want to test it, just get in a python shell and run:

import requests

headers = {'Host': 'gpt2-tweetgen.default.example.com'}

response = requests.post('http://35.245.24.157', headers=headers, json={'model':'obama', 'length':81, 'prefix': 'Walking through the park,', 'temperature':0.7});

model can be set to 'obama', 'trump', or 'minaj' for whatever model you want

length is the number of words you want to generate (with a maximum of 1023, though I recommend sticking below 200)

prefix is the initial text you want the tweet to start with. Just pass '' if you don't want to suggest a starting point

temperature is the level of "creativity" of the model. Best results are found with a temp of 0.7, but the lower the more simple while the higher the more random. I'd keep it at >=0.5

Challenges I ran into

Sending HTTP requests from anything other than Python is extremely painful. We built both a website and a mobile app, yet trying to send HTTP requests through Java (android studio) and HTML (github pages) was our breaking point, as none of us had any experience with this before.

While we were unable to figure out the 3-10 lines of code to send the POST request this weekend, you can still test the service through a python shell and using the requests module.

Accomplishments that I'm proud of

Figuring out how to set up Kubernetes Cluster and training the machine learning model

What I learned

Google Kubernetes Engine for Google Cloud Run

Using OpenAI's GPT-2 w/ gpt-2-simple and google cloud-run

HTML, CSS, Bootstrap (Github Pages)

Docker

For most of us, Python.

What's next for TweetGen

With more time and some outside help, I'm sure we can easily find the right way to make the POST request for both Java and HTML, so we could finally connect the front end to the back end.

We also thought to set it up so you can enter ANY twitter handle and train the model on that user's tweets to essentially allow users to generate tweets like anyone they want.

Share this project:

Updates