how to train a chatbot to be like anyone on discord (not using OpenAI) – Medium
Sign in
Sign in
diy_tech_genuis
Follow
—
Listen
Share
Hey everyone, thanks for reading! I hope you’re as excited as I am. I’ve been working on this for months, and I’m finally done. I’m happy to say you don’t need to pay for ChatGPT or OpenAI’s API token. We are going to use a smaller AI model called gpt2 which will not need any API token or any sort of payment. Now, I’ll tell you, this might take a little time and effort, but in the end, you’ll have your own chatbot that talks like the person you’ve chosen.
You will need,
a Windows 10 computer
a Google account
and a Discord authorization token.
To get the authorization token, you can read my story for Firefox here, and if you prefer videos or you use Chrome, check out a good video here.
The first step in training a chatbot on someone’s Discord messages is to get the messages using a tool called DiscordChatExporter. Download the tool here and extract the contents. Follow the prompts, and when finished, go to the folder you just extracted double click discordchatexporter.exe. If the "Windows protected your PC" message pops up, click on "More info" and then "Run anyway." If it asks you to install .NET Runtime (Desktop), do that. You should now have an app that looks like this
If you’re having trouble, you can watch a helpful video here.
warning sharing a discord auth token with anyone is like sharing your username and password so do the next step at your own risk and I would suggest, you can change your password when you're done, (this will change the token automatically) that being said you can paste your authentication token at the top and hit enter. You should now see all your Discord servers on the left and your DMs on the right. Choose a server and channel, set the format as CSV, and I like to rename it to something like data.csv, now you can export it. This may take some time, so move to the next step while waiting.
now we need to download this Google Colab file by going there and clicking ctrl+shift+s
When that’s done, go to https://drive.google.com and make sure you’re signed in. Click the little plus sign next to “New” on the top right-hand side, then click “File upload.” Navigate to the file you just downloaded and double-click the “clone_a_discord_user_with_AI.ipynb.”
Now, click on “My Drive,” select the three dots next to “clone_a_discord_user_with_AI.ipynb,” and choose “Open with.” Click “Connect more apps” and search for Colab; it should be the first one that comes up.
click on it then click install then click done then click the little dots next to the file again and click open with google colab now that should open in a new tab now you should have something like this.
hopefully the discordchatexporter is done by now if not, wait a little bit and when it is, upload the csv file to your google drive.
Now, let’s start the coding part. Don’t worry if you don’t know anything about coding; just follow my instructions. If you need help, ask in the comments or on my Discord server if you want to be part of my discord server which is mostly about bug bounty (ethical hacking) and tech related you can also ask in the comments, and I send you an invite link.
is to install a library for the chatbot. Run the first little box(called a cell) that says !pip -q install transformers. Then, import all the necessary libraries by running the next cell that starts with # all the imports. after that you will need to mount your drive and connect it to your google account with the data you uploaded by running the next two cells
now in the next cell Replace input_file = "your csv file here" with your CSV file's name (if following along with me, it's "data.csv").
Now, run each box one at a time until you reach the one that says CHARACTER_NAME = 'the discord username of person you want to clone here'. Change that to the Discord username of the person you want to clone and run it. Keep running the cells until you reach the part that says "Load the Trained Model." If everything goes well, your chatbot will be trained, but this could take some time running the last cell you see here.
If all went well, your chatbot is trained. Let’s run the next box to load it and the one after that to chat for 5 lines. If you get the little error about the decoder-only architecture, you can ignore it. Here’s what mine said:
Now that you have your chatbot, you might be wondering about the rest of the code. Well, this is so that you can push it to Hugging Face and use it later, such as if you want a user interface like ChatGPT!
or to train it more on another person. For that, you’ll need to wait for my next part where we will do both of those things.
If you want to ensure you don’t miss it, subscribe. And if you liked this one, hit the clap button three times. This is what motivates me to keep writing in my spare time. But right now, you will need to go get a Hugging Face account and API token so that you can push the model to Hugging Face. Don’t worry; this is free and easy. When you got those, fill in your email and name. Then, name the model whatever you want, fill in your API token, and run the rest of the cells. See you in the next part!
—
—
I'm a teenage hacker, and developer. While most kids my age were playing video games, I was working very hard and doing all I could just to be an ethical hacker
Help
Status
About
Careers
Blog
Privacy
Terms
Text to speech
Teams