File size: 1,008 Bytes
71780e7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# Train-your-own GPT
A very simple script on how to train a GPT model with just a text file. Created by @Tekkonetes (Hugging Face) or @pxlmastrXD (Replit).

## Setup
You will need some packages installed to run this. Make sure you have a recent (supported) python version, and then install some packages. 
I would recommend using a Virtual environment to do this, so you can remove it easily after training and deployment:
```shell
python -m venv venv
source venv/bin/activate
```
Then, install some required packages:
```shell
pip install transformers numpy torch
```
That should be all you need.
## Usage
First, put all your data into the train.txt file. By tweaking the code, you can use multiple.

Second, select your GPT model. By default, the script uses `gpt2-medium`, but you can replace it with most GPT-based models. 
You might have to do some tweaking, however.

Then, run the script.
```shell
python main.py
```

That is pretty much it. Feel free to use this for whatever you want!!!
- pxlmastrXD