This lesson is being piloted (Beta version)

Fine-tuning GPT3 using OpenAI API

Overview

Teaching: 15 min min
Exercises: 0 min
Questions
  • How to train GPT3 using OpenAI API Platform

Objectives

Introduction

Request OpenAI API Key

image

image

Download the data as CSV format

image

Using OpenAI API to train GPT3 model.

Using Anaconda Navigator:

image

image

pip install openai
cd c:/SMU/PROJECTS/DrewDickens/
$ openai tools fine_tunes.prepare_data -f Westminster_Catechism.csv
set OPENAI_API_KEY=abc
openai api fine_tunes.create -t Westminster_Catechism_prepared.jsonl -m ada

if your model is completed, it should show this:

image

openai api completions.create -m ada:ft-personal-2022-12-07-17-10-04 -p "What are the punishments of sin in the world to come?"

image

Using M2

It is very much the same as using ManeFrame 2 or any other HPC to fine-tune GPT3 with openai api.

$ srun -N1 -p standard-mem-s -c2 --mem=5G --pty $SHELL
module load python/3
$ conda create -n openai python==3.8
$ source activate openai
$ pip install openai
export OPENAI_API_KEY=abc
cd /work/users/tuev
$ openai tools fine_tunes.prepare_data -f Westminster_Catechism.csv
openai api fine_tunes.create -t Westminster_Catechism_prepared.jsonl -m ada
openai api completions.create -m ada:ft-personal-2022-12-07-17-10-04 -p "What are the punishments of sin in the world to come?"

Key Points

  • OpenAI, API, Python