AlexStrew / DiscordChatAI-GPT2

A chat AI discord bot written in python3 using GPT-2, trained on data scraped from every message of my discord server (can be trained on yours too)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Python Discord GPT2 ChatBot

Bot responds to mentions and also has a variable chance of responding to random messages.

Important Note

You must train your bot for at least 100 cycles otherwise it will have not saved any progress thus causing a "ValueError: Can't load save_path when it is None." error.

To train (non docker):

Run python3 main.py --genmodel to train. Requires a .txt file of the text channel history to be placed in the same directory as name called "chat.txt". An example of the chat.txt format is provided. It's defaulted to the 355M dataset, but you can change its value in main.py and in Bot/ai.py.

To train (docker):

Requires an nvidia GPU unfortunately (unless you use the non-gpu version which is much slower). Make sure you have docker-nvidia installed (guide)

Build docker container:

docker build -t chatai .

Run container:

docker run --runtime=nvidia --rm chatai '--genmodel'

To test:

You can test this bot locally by running python3 main.py -t. It will let you input some text and it will print the AI's response.

To run on Discord:

python3 main.py --token [discord bot token]

Docker environment variables:

Set TOKEN to pass in your discord token

Set RESPONSE_CHANCE to set how likely the bot is to respond (0 for no random responses, 0.25 for 25% chance, etc)

F.A.Q.

Can I reuse my pre-generated model?

See this great answer from johnnymcmike: NickBrisebois#3 (comment)

About

A chat AI discord bot written in python3 using GPT-2, trained on data scraped from every message of my discord server (can be trained on yours too)

License:MIT License


Languages

Language:Python 86.6%Language:Shell 7.4%Language:Dockerfile 3.9%Language:Makefile 2.1%