Skip to content

A GPT-2 powered web app that generates advice in the style of world-class experts:

Notifications You must be signed in to change notification settings

DaveSmith227/mastermind-gpt2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Table of Contents

A. About the App

🧠 Mastermind is a GPT-2 (OpenAI) powered web app that generates short, life advice in the style of world-class experts.

There is a separate language model (117M = small GPT-2) per expert and each was fine-tuned using the language model script from the amazing folks at Hugging Face 🤗.

Unlock Your Potential

B. Samples: AI-Generated Advice

Retired Navy SEAL and current record holder for the most pull-ups in 24-hours (4,030), David Goggins will teach you the definition of toughness #stayhard 🦾.

Screenshots

Meet your empathy coach, Brene Brown. Goggins may not care about hurting your "feelings," but Brene will teach you to lean into them and be brave ❤️.

Screenshots

Seneca, the "Sentient" Stoic, is a seeker of wisdom and helps guide you to a life of happiness, peace, and prosperity 📜🖋️

Screenshots

C. How Models were Trained

Each language model was fine-tuned with the Hugging Face script and 3-4 training epochs were used for each model with the default script settings (took around 5-10 minutes on NVIDIA's Tesla P100 GPU, 16GB on GCP).

A single .txt training file (.csv also works) was prepared and cleaned for each mentor using various sources of text from books/articles they've written and speeches/interview on YouTube if "captions" with punctuation were available (you can use YouTube filter criteria to search for videos with "captions").

The amount of data used for each is incredibly small, yet the language generation model still does a remarkably good job of picking up the speaker's style in word choice/patterns.

(Size of Training Data, # of Tokens)
  1. Tony Robbins (2 MB, 465K)
  2. Paul Graham (1.1 MB, 240K)
  3. David Goggins (616 KB, 156K)
  4. Brene Brown (899 KB, 219K)
  5. Seneca (1.3 MB, 334K)

D. Deployment and Serving the App

Hosting: The app was deployed using a docker image on a stand-alone VM from Digital Ocean (2GB RAM, $10/month) and the domain (.fyi) was purchased from namecheap.com. Each model is 550MB and hosted on Dropbox. During the Docker build, the models (separate zipped folders) get downloaded (see 'server.py' script) and unzipped. The .yaml file is not used with Digital Ocean, but works if you deploy the app with Google's App Engine.

GPT-2 Generation Length: By default, the advice generation length is set to a max of 50 tokens in the "server.py" script and the generated text gets truncated down to end (typically) with the last punctuation (., ?, !) found before it reaches 50 tokens. If the generated text does not contain ending punctuation, it automatically gets truncated to 100 characters (user-defined parameter in server.py script).

Scale-ability: Only 1 concurrent request can be ran at a time. Subsequently, 2 users cannot use the app at the same time (creates a "traffic queue") and this decision was made to control costs. Google App Engine offers greater flexibility and load balancing, but comes at a higher cost. Google Cloud Run is Google's stateless option that is cheaper; however, I experienced long delays (30-45 seconds minimum) to start/serve the site ("cold start problem") because of the size of the Docker image (about 1GB).

How App is Ran: The app is built using the Starlette app framework (lightweight, similar to Flask). After clicking the "Generate Advice" button, the app loads the selected mentor's language model and for the chosen question, the language model uses 1 of 3 short "prompts/seeds" (selected at random) to generate the advice.

Helpful Deployment Resources:

  1. GPT-2: Google Cloud Run Example from Max Woolf and Tutorial
  2. GPT-2: Basic Web App #1 and Tutorial
  3. GPT-2: Basic Web App #2

Inspiring Language Generation Demos:

  1. Hugging Face Web Apps
  2. Writeup.ai and Tutorial/Lessons Learned
  3. "News You CAN'T use" from Adam Geitgey and Tutorial
  4. Max Woolf's Interactive GPT-2 apps
  5. Allen NLP GPT-2 app
  6. GPT-2 Poetry & Insights from Gwern

E. Web App Design

The front-end website was designed using the Blocs app for the majority of the http/css and served with the Starlette app.

To optimize the css/javascript for faster web page loading, I used some insights from Google's "PageSpeed Insights" and leveraged PurifyCSS to remove unused css. In Google Chrome, I also used DevTools to run the audit pages to find recommendations to improve user experience.

F. Language Model (GPT-2) - How it Works

Here are some incredible tutorials on language models 👏 👏 👏

  1. The Annotated GPT-2
  2. Jay Alammar's Illustrated GPT-2
  3. FloydHub's GPT-2 Overview
  4. Allen NLP GPT-2 app

G. Mastermind Principle Explained

Unlock your potential with the world class experts across disciplines!

The "mastermind principle" comes from Napoleon Hill (author of "Think and Grow Rich") and consists of an alliance of two or more minds working in perfect harmony for the attainment of a common definite objective. Success does not come without the cooperation of others.

Try it out!