Fine-Tuning GPT3 for free

DALLE’s version of training AI
This is why I chuckled.

FINE-TUNING USING OPENAI PACKAGE

  1. Preparing the fine-tuning dataset.
  2. Fine-tuning the model.
  3. Using the fine-tuned model for inference.
!pip install openai
import openaiimport pandas as pdimport stringopenai.api_key = 'YOUR API KEY'
df = pd.read_csv('jokes.csv')df.head()
{"prompt": "<text>", "completion": "<text to be generated>"}
{"prompt": "<text>", "completion": "<text to be generated>"}
{"prompt": "<text>", "completion": "<text to be generated>"}

1. PREPARING THE FINE-TUNING DATASET

!yes | openai tools fine_tunes.prepare_data -f 'joke.csv'
#write your file name instead of jokes_prepared.jsonlwith open("joke_prepared.jsonl") as f:      response = openai.File.create(file=f, purpose='fine-tune')print(response)

2. FINE-TUNING THE MODEL

response = openai.FineTune.create(training_file="YOUR FILE ID", model='ada')
response = openai.FineTune.retrieve(id="YOUR FINE-TUNE ID")

3. USING THE FINE-TUNED MODEL FOR INFERENCE

# ft_model should have your model id
ft_model = "ada:ft-personal-2022-07-22-11-25-19"
res = openai.Completion.create(model=ft_model, prompt="I hate ... ", max_tokens=18, temperature=1)
  1. I hate … iphones !!!!!! Why do they have to have so many tones? (Wow super strong on punctuations)
  1. Why are ants not allowed at the party? Because they all have stings.
  2. Why is . -> . an illegal operation? Because it is prohibited by the * cow * contract! (No clue what is illegal but cow contract makes sense)
  3. Why are physicists so bitter? Because they can’t stand (P.S. I am sorry physicists but apparently all of you are Stephen Hawking).

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store