Create fine-tuning job
Creates a fine-tuning job which begins the process of creating a new model from a given dataset.
Response includes details of the enqueued job including job status and the name of the fine-tuned models once complete.
Request body
modelstring
The name of the model to fine-tune. You can select one of the supported models.
modelstringRequired
modelstringRequired
babbage-002string
davinci-002string
gpt-3.5-turbostring
gpt-4o-ministring
training_filestringRequired
The ID of an uploaded file that contains training data.
See upload file for how to upload a file.
Your dataset must be formatted as a JSONL file. Additionally, you must upload your file with the purpose
fine-tune.The contents of the file should differ depending on if the model uses the chat, completions format, or if the fine-tuning method uses the preference format.
See the fine-tuning guide for more details.
hyperparametersobjectDeprecated
The hyperparameters used for the fine-tuning job. This value is now deprecated in favor of
method, and should be passed in under themethodparameter.batch_sizestring or integer
Number of examples in each batch. A larger batch size means that model parameters are updated less frequently, but with lower variance.batch_sizestring
autostring
batch_sizeinteger
learning_rate_multiplierstring or number
Scaling factor for the learning rate. A smaller learning rate may be useful to avoid overfitting.learning_rate_multiplierstring
autostring
learning_rate_multipliernumber
n_epochsstring or integer
The number of epochs to train the model for. An epoch refers to one full cycle through the training dataset.n_epochsstring
autostring
n_epochsinteger
suffixstring or nullDefaults: null
A string of up to 64 characters that will be added to your fine-tuned model name.
For example, a
suffixof "custom-model-name" would produce a model name likeft:gpt-4o-mini:openai:custom-model-name:7p4lURel.validation_filestring or null
The ID of an uploaded file that contains validation data.
If you provide this file, the data is used to generate validation metrics periodically during fine-tuning. These metrics can be viewed in the fine-tuning results file. The same data should not be present in both train and validation files.
Your dataset must be formatted as a JSONL file. You must upload your file with the purpose
fine-tune.See the fine-tuning guide for more details.
integrationsarray or null
A list of integrations to enable for your fine-tuning job.itemsobject
typestring
The type of integration to enable. Currently, only "wandb" (Weights and Biases) is supported.typestringRequired
wandbstring
wandbobjectRequired
The settings for your integration with Weights and Biases. This payload specifies the project that metrics will be sent to. Optionally, you can set an explicit display name for your run, add tags to your run, and set a default entity (team, username, etc) to be associated with your run.projectstringRequired
The name of the project that the new run will be created under.namestring or null
A display name to set for the run. If not set, we will use the Job ID as the name.entitystring or null
The entity to use for the run. This allows you to set the team or username of the WandB user that you would like associated with the run. If not set, the default entity for the registered WandB API key is used.tagsarray
A list of tags to be attached to the newly created run. These tags are passed through directly to WandB. Some default tags are generated by OpenAI: "openai/finetune", "openai/{base-model}", "openai/{ftjob-abcdef}".itemsstring
seedinteger or null
The seed controls the reproducibility of the job. Passing in the same seed and job parameters should produce the same results, but may differ in rare cases. If a seed is not specified, one will be generated for you.methodobject
The method used for fine-tuning.typestring
The type of method. Is either
supervisedordpo.supervisedstring
dpostring
supervisedobject
Configuration for the supervised fine-tuning method.hyperparametersobject
The hyperparameters used for the fine-tuning job.batch_sizestring or integer
Number of examples in each batch. A larger batch size means that model parameters are updated less frequently, but with lower variance.batch_sizestring
autostring
batch_sizeinteger
learning_rate_multiplierstring or number
Scaling factor for the learning rate. A smaller learning rate may be useful to avoid overfitting.learning_rate_multiplierstring
autostring
learning_rate_multipliernumber
n_epochsstring or integer
The number of epochs to train the model for. An epoch refers to one full cycle through the training dataset.n_epochsstring
autostring
n_epochsinteger
dpoobject
Configuration for the DPO fine-tuning method.hyperparametersobject
The hyperparameters used for the fine-tuning job.betastring or number
The beta value for the DPO method. A higher beta value will increase the weight of the penalty between the policy and reference model.betastring
autostring
betanumber
batch_sizestring or integer
Number of examples in each batch. A larger batch size means that model parameters are updated less frequently, but with lower variance.batch_sizestring
autostring
batch_sizeinteger
learning_rate_multiplierstring or number
Scaling factor for the learning rate. A smaller learning rate may be useful to avoid overfitting.learning_rate_multiplierstring
autostring
learning_rate_multipliernumber
n_epochsstring or integer
The number of epochs to train the model for. An epoch refers to one full cycle through the training dataset.n_epochsstring
autostring
n_epochsinteger
metadataobject or null
Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard. Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters.
Response
A fine-tuning.job object.
1 curl https://api.openai.com/v1/fine_tuning/jobs \2 -H "Content-Type: application/json" \3 -H "Authorization: Bearer $OPENAI_API_KEY" \4 -d '{5 "training_file": "file-BK7bzQj3FfZFXr7DbL6xJwfo",6 "model": "gpt-4o-mini"7 }'
1 {2 "object": "fine_tuning.job",3 "id": "ftjob-abc123",4 "model": "gpt-4o-mini-2024-07-18",5 "created_at": 1721764800,6 "fine_tuned_model": null,7 "organization_id": "org-123",8 "result_files": [],9 "status": "queued",10 "validation_file": null,11 "training_file": "file-abc123",12 "method": {13 "type": "supervised",14 "supervised": {15 "hyperparameters": {16 "batch_size": "auto",17 "learning_rate_multiplier": "auto",18 "n_epochs": "auto",19 }20 }21 },22 "metadata": null23 }