Fine Tuning - Create
Creates a job that fine-tunes a specified model from a given training file. Response includes details of the enqueued job including job status and hyper parameters. The name of the fine-tuned model is added to the response once complete.
POST {endpoint}/openai/fine_tuning/jobs?api-version=2024-06-01
URI Parameters
Name | In | Required | Type | Description |
---|---|---|---|---|
endpoint
|
path | True |
string url |
Supported Cognitive Services endpoints (protocol and hostname, for example: https://aoairesource.openai.azure.com. Replace "aoairesource" with your Azure OpenAI account name). |
api-version
|
query | True |
string |
The requested API version. |
Request Header
Name | Required | Type | Description |
---|---|---|---|
api-key | True |
string |
Provide your Cognitive Services Azure OpenAI account key here. |
Request Body
Name | Required | Type | Description |
---|---|---|---|
model | True |
string |
The identifier (model-id) of the base model used for this fine-tune. |
training_file | True |
string |
The file identity (file-id) that is used for training this fine tuned model. |
hyperparameters |
FineTuningHyperParameters |
||
seed |
integer |
The seed used for the finetuning 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. |
|
suffix |
string |
The suffix used to identify the fine-tuned model. The suffix can contain up to 40 characters (a-z, A-Z, 0-9,- and _) that will be added to your fine-tuned model name. |
|
validation_file |
string |
The file identity (file-id) that is used to evaluate the fine tuned model during training. |
Responses
Name | Type | Description |
---|---|---|
201 Created |
The fine tune has been successfully created. Headers Location: string |
|
Other Status Codes |
An error occurred. |
Security
api-key
Provide your Cognitive Services Azure OpenAI account key here.
Type:
apiKey
In:
header
Examples
Creating a fine tuning job.
Sample request
POST https://aoairesource.openai.azure.com/openai/fine_tuning/jobs?api-version=2024-06-01
{
"model": "curie",
"training_file": "file-181a1cbdcdcf4677ada87f63a0928099"
}
Sample response
location: https://aoairesource.openai.azure.com/openai/fine_tuning/jobs/ft-72a2792ef7d24ba7b82c7fe4a37e379f
{
"hyperparameters": {
"n_epochs": 2
},
"model": "curie",
"training_file": "file-181a1cbdcdcf4677ada87f63a0928099",
"id": "ft-72a2792ef7d24ba7b82c7fe4a37e379f",
"status": "notRunning",
"created_at": 1646126127,
"object": "fine_tuning.job"
}
Definitions
Name | Description |
---|---|
Error |
Error |
Error |
ErrorCode |
Error |
ErrorResponse |
Fine |
FineTuningHyperParameters |
Fine |
FineTuningJob |
Fine |
FineTuningJobCreation |
Fine |
FineTuningJobError |
Fine |
FineTuningState |
Inner |
InnerError |
Inner |
InnerErrorCode |
Type |
TypeDiscriminator |
Error
Error
Name | Type | Description |
---|---|---|
code |
ErrorCode |
|
details |
Error[] |
The error details if available. |
innererror |
InnerError |
|
message |
string |
The message of this error. |
target |
string |
The location where the error happened if available. |
ErrorCode
ErrorCode
Name | Type | Description |
---|---|---|
conflict |
string |
The requested operation conflicts with the current resource state. |
contentFilter |
string |
Image generation failed as a result of our safety system. |
fileImportFailed |
string |
Import of file failed. |
forbidden |
string |
The operation is forbidden for the current user/api key. |
internalFailure |
string |
Internal error. Please retry. |
invalidPayload |
string |
The request data is invalid for this operation. |
itemDoesAlreadyExist |
string |
The item does already exist. |
jsonlValidationFailed |
string |
Validation of jsonl data failed. |
notFound |
string |
The resource is not found. |
quotaExceeded |
string |
Quota exceeded. |
serviceUnavailable |
string |
The service is currently not available. |
tooManyRequests |
string |
Too many requests. Please retry later. |
unauthorized |
string |
The current user/api key is not authorized for the operation. |
unexpectedEntityState |
string |
The operation cannot be executed in the current resource's state. |
ErrorResponse
ErrorResponse
Name | Type | Description |
---|---|---|
error |
Error |
FineTuningHyperParameters
FineTuningHyperParameters
Name | Type | Description |
---|---|---|
batch_size |
integer |
The batch size to use for training. The batch size is the number of training examples used to train a single forward and backward pass. In general, we've found that larger batch sizes tend to work better for larger datasets. The default value as well as the maximum value for this property are specific to a base model. |
learning_rate_multiplier |
number |
The learning rate multiplier to use for training. The fine-tuning learning rate is the original learning rate used for pre-training multiplied by this value. Larger learning rates tend to perform better with larger batch sizes. We recommend experimenting with values in the range 0.02 to 0.2 to see what produces the best results. |
n_epochs |
integer |
The number of epochs to train the model for. An epoch refers to one full cycle through the training dataset. |
FineTuningJob
FineTuningJob
Name | Type | Description |
---|---|---|
created_at |
integer |
A timestamp when this job or item was created (in unix epochs). |
error |
FineTuningJobError |
|
estimated_finish |
integer |
The Unix timestamp (in seconds) for when the fine-tuning job is estimated to finish. The value will be null if the fine-tuning job is not running. |
fine_tuned_model |
string |
The identifier (model-id) of the resulting fine tuned model. This property is only populated for successfully completed fine-tune runs. Use this identifier to create a deployment for inferencing. |
finished_at |
integer |
A timestamp when this job or item has finished successfully (in unix epochs). |
hyperparameters |
FineTuningHyperParameters |
|
id |
string |
The identity of this item. |
model |
string |
The identifier (model-id) of the base model used for the fine-tune. |
object |
TypeDiscriminator |
|
organisation_id |
string |
The organisation id of this fine tune job. Unused on Azure OpenAI; compatibility for OpenAI only. |
result_files |
string[] |
The result file identities (file-id) containing training and evaluation metrics in csv format. The file is only available for successfully completed fine-tune runs. |
seed |
integer |
The seed used for the finetuning job. |
status |
FineTuningState |
|
suffix |
string |
The suffix used to identify the fine-tuned model. The suffix can contain up to 40 characters (a-z, A-Z, 0-9,- and _) that will be added to your fine-tuned model name. |
trained_tokens |
integer |
The total number of billable tokens processed by this fine tuning job. |
training_file |
string |
The file which is used for training. |
validation_file |
string |
The file which is used to evaluate the fine tuned model during training. |
FineTuningJobCreation
FineTuningJobCreation
Name | Type | Description |
---|---|---|
hyperparameters |
FineTuningHyperParameters |
|
model |
string |
The identifier (model-id) of the base model used for this fine-tune. |
seed |
integer |
The seed used for the finetuning 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. |
suffix |
string |
The suffix used to identify the fine-tuned model. The suffix can contain up to 40 characters (a-z, A-Z, 0-9,- and _) that will be added to your fine-tuned model name. |
training_file |
string |
The file identity (file-id) that is used for training this fine tuned model. |
validation_file |
string |
The file identity (file-id) that is used to evaluate the fine tuned model during training. |
FineTuningJobError
FineTuningJobError
Name | Type | Description |
---|---|---|
code |
string |
The machine-readable error code.. |
message |
string |
The human-readable error message. |
param |
string |
The parameter that was invalid, usually training_file or validation_file. This field will be null if the failure was not parameter-specific. |
FineTuningState
FineTuningState
Name | Type | Description |
---|---|---|
cancelled |
string |
The operation has been cancelled and is incomplete. It can be categorized as a terminal state. |
created |
string |
The operation was created. This state is not returned by Azure OpenAI and exposed only for compatibility. It can be categorized as an inactive state. |
failed |
string |
The operation has completed processing with a failure and cannot be further consumed. It can be categorized as a terminal state. |
pending |
string |
The operation is not yet queued to be processed in the future. It can be categorized as an inactive state. |
running |
string |
The operation has started to be processed. It can be categorized as an active state. |
succeeded |
string |
The operation has successfully be processed and is ready for consumption. It can be categorized as a terminal state. |
InnerError
InnerError
Name | Type | Description |
---|---|---|
code |
InnerErrorCode |
|
innererror |
InnerError |
InnerErrorCode
InnerErrorCode
Name | Type | Description |
---|---|---|
invalidPayload |
string |
The request data is invalid for this operation. |
TypeDiscriminator
TypeDiscriminator
Name | Type | Description |
---|---|---|
file |
string |
This object represents a file. |
fine_tuning.job |
string |
This object represents a fine tune job. |
fine_tuning.job.checkpoint |
string |
This object represents a checkpoint of a fine tuning job. |
fine_tuning.job.event |
string |
This object represents an event of a fine tuning job. |
list |
string |
This object represents a list of other objects. |
model |
string |
This object represents a model (can be a base model or fine tune job result). |