Code Monkey home page Code Monkey logo

gpt-2_bot's Introduction

GPT-2 Bot

This is a Reddit bot based on OpenAi's GPT-2 117M model

The official implementation by u/Shevizzle can be found here: u/GPT-2_Bot

Installation

Requirements

  • Docker
  • An internet connection
  • Some pretty beefy hardware

Installing Docker

Docker command-line interface reference: https://docs.docker.com/engine/reference/commandline/cli/

Installing Latest Tensorflow Docker Image

Follow instructions here (scroll down for GPU)

Perform all remaining steps from within this docker container.

Installing GPT-2

To run this bot, you must first clone the original GPT-2 repository.

git clone https://github.com/shevisjohnson/gpt-2.git
cd gpt-2

Once this is done, install the python requirements and download the model.

pip install --upgrade pip
pip install -r requirements.txt
python download_model.py 117M

Once this has completed successfully, you can test it by running:

python ./src/interactive_conditional_samples.py

Installing Reddit Bot

Next, if you haven't already, back out of the gpt-2 directory and clone the gpt-2_bot repository:

cd ..
git clone https://github.com/shevisjohnson/gpt-2_bot.git
cd gpt-2_bot

Next, install requirements:

pip install -r requirements.txt

And finally, copy reddit_bot.py over to the main GPT-2 repository under the src sub-directory:

cp ./reddit_bot.py ../gpt-2/src/reddit_bot.py

Configuring Praw (Reddit python interface)

Praw is a library that interfaces with the Reddit API for you. It limits how many requests you can make, and makes it easy to extract the json responses.

You need to do a bit of setup first though in order for the bot to be able to post to Reddit.

Go to: https://www.reddit.com/prefs/apps/

And select Create App

Give it a name. You have to choose a redirect uri (for some stupid reason, stupid because I'm building a bot, not a webapp, but whatever). I chose http://127.0.0.1

You will now get a client_id (red box below) and secret (blue box below). Note it down, but keep it secret.

credit

Now, you need to update your praw ini file to remember these settings. Otherwise, you’ll have to put them in your script and thats dangerous (as others might see them).

This page describes how to change praw.ini files: https://praw.readthedocs.io/en/v4.0.0/getting_started/configuration/prawini.html

I don’t recommend modifying the package-level praw.ini as those changes will be overwritten every time the package is updated. Instead praw.ini should be placed in the directory that the program is run from (often the same directory as the file).

In your praw.ini file, make sure the profile tag is set to [gptbot] and make sure the file is located in the base of the gpt-2 repository.

Running the bot

Once setup is complete, actually running the bot is very simple. From the base of the gpt-2 repository:

python ./src/reddit_bot.py

That's it!

Big thanks to OpenAI for releasing this model publicly!

gpt-2_bot's People

Contributors

shevisj avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.