This repository contains a Python script (main.py) which can take data from the reddit API and turn it into a JSONL file of prompt/completion pairs which can be used to fine-tune a GPT3 model. The prompts are post titles and the completions are the top comments.
This tool requires a bit of command line/terminal usage - if you have no experience with that, don't worry as you should be able to follow along just fine.
- Python3 installed on your computer
- An OpenAI account with the command-line interface installed
- A reddit application (don't worry this just takes a moment to create)
- Note down the
client_id
andclient_secret
from your reddit application - In the
main.py
file, replace the values in lines 7, 8, and 9 with your reddit application credentials and the target subreddit - Install praw. Usually this means navigating to the folder with the
main.py
file in the terminal and enteringpip install praw
orpip3 install praw
- Run the script. Usually this means entering
python main.py
orpython3 main.py
This will produce a JSONL file of prompt/completion pairs in the folder with the main.py
script.
- In the terminal, enter
openai tools fine_tunes.prepare_data -f reddit_data.jsonl
- Answer
y
to all of the prompts - Take note of the suffix separator and suffix ending
- In the terminal, enter
openai api fine_tunes.create -t reddit_data_prepared.jsonl
Congratulations! Your fine-tuning job will now be started by OpenAI!
It will take awhile (minutes or hours, generally) for the job to complete. If the stream is interrupted, don't worry as the job will continue. You can check the status of the job by entering openai api fine_tunes.follow -i <YOUR_FINE_TUNE_JOB_ID>
.
Once completed, you can use the fine-tuned model via API or in the playground.