Fine-tune OpenAI GPT-3 on your own data and track results with W&B
OpenAI’s API gives practitioners access to GPT-3, an incredibly powerful natural language model that can be applied to virtually any task that involves understanding or generating natural language.
All it takes is one line:
openai wandb sync
Make sure you are using latest version of openai and wandb.
$ pip install --upgrade openai wandb
Then sync your results from the command line or from your script.
$ # one line command
$ openai wandb sync
$ # passing optional parameters
$ openai wandb sync --help
from openai.wandb_logger import WandbLogger
# one line command
# passing optional parameters
We scan for new completed fine-tunes and automatically add them to your dashboard.
In addition your training and validation files are logged and versioned, as well as details of your fine-tune results. This let you interactively explore your training and validation data.
Create a new run:
run = wandb.init(project="GPT-3", job_type="eval")
Retrieve a model id for inference.
You can use automatically logged artifacts to retrieve your latest model:
artifact_job = run.use_artifact("ENTITY/PROJECT/fine_tune_details:latest")
fine_tuned_model = artifact_job.metadata["fine_tuned_model"]
You can also retrieve your validation file:
artifact_valid = run.use_artifact("ENTITY/PROJECT/FILENAME:latest")
valid_file = artifact_valid.get_path("FILENAME").download()
Perform some inferences using OpenAI API:
# perfom inference and record results
my_prompts = ["PROMPT_1", "PROMPT_2"]
results = 
for prompt in my_prompts:
res = openai.Completion.create(model=fine_tuned_model,
Log your results with a Table:
table = wandb.Table(columns=['prompt', 'completion'],
Sync all your runs to your team account with:
$ openai wandb sync --entity MY_TEAM_ACCOUNT
Your runs are automatically organized and can be filtered/sorted based on any configuration parameter such as job type, base model, learning rate, training filename and any other hyper-parameter.
In addition, you can rename your runs, add notes or create tags to group them.
Once you’re satisfied, you can save your workspace and use it to create report, importing data from your runs and saved artifacts (training/validation files).
Fine-tune details are logged to W&B as artifacts and can be accessed with:
artifact_job = wandb.run.use_artifact('USERNAME/PROJECT/job_details:VERSION')
- a version number such as
- the fine-tune id such as
- an alias added automatically such as
You can then access fine-tune details through
artifact_job.metadata. For example, the fine-tuned model can be retrieved with
You can always call again
openai wandb syncand we will re-sync any run that was not synced successfully.
If needed, you can call
openai wandb sync --id fine_tune_id --forceto force re-syncing a specific fine-tune.
Yes, you can integrate your entire pipeline to W&B through Artifacts, including creating your dataset, splitting it, training your models and evaluating them!
This will allow complete traceability of your models.