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=2023-12-01-preview

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

FineTuningHyperParameters
The hyper parameter settings used in a fine tune job.

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

FineTuningJob

The fine tune has been successfully created.

Headers

Location: string

Other Status Codes

ErrorResponse

An error occurred.

Security

api-key

Provide your Cognitive Services Azure OpenAI account key here.

Type: apiKey
In: header

Examples

Creating a fine tune job.

Sample Request

POST https://aoairesource.openai.azure.com/openai/fine_tuning/jobs?api-version=2023-12-01-preview


{
  "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,
  "updated_at": 1646127311,
  "object": "fine_tuning.job"
}

Definitions

Name Description
Error

Error

ErrorCode

ErrorCode

ErrorResponse

ErrorResponse

FineTuningHyperParameters

FineTuningHyperParameters

FineTuningJob

FineTuningJob

FineTuningJobCreation

FineTuningJobCreation

FineTuningState

FineTuningState

InnerError

InnerError

InnerErrorCode

InnerErrorCode

TypeDiscriminator

TypeDiscriminator

Error

Error

Name Type Description
code

ErrorCode

ErrorCode
Error codes as defined in the Microsoft REST guidelines (https://github.com/microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses).

details

Error[]

The error details if available.

innererror

InnerError

InnerError
Inner error as defined in the Microsoft REST guidelines (https://github.com/microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses).

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

Error
Error content as defined in the Microsoft REST guidelines (https://github.com/microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses).

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).

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

FineTuningHyperParameters
The hyper parameter settings used in a fine tune job.

id

string

The identity of this item.

model

string

The identifier (model-id) of the base model used for the fine-tune.

object

TypeDiscriminator

TypeDiscriminator
Defines the type of an object.

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.

status

FineTuningState

FineTuningState
The state of a finetunes object or fine tuning job.

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.

updated_at

integer

A timestamp when this job or item was modified last (in unix epochs).

validation_file

string

The file which is used to evaluate the fine tuned model during training.

FineTuningJobCreation

FineTuningJobCreation

Name Type Description
hyperparameters

FineTuningHyperParameters

FineTuningHyperParameters
The hyper parameter settings used in a fine tune job.

model

string

The identifier (model-id) of the base model used for this fine-tune.

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.

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

InnerErrorCode
Inner error codes as defined in the Microsoft REST guidelines (https://github.com/microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses).

innererror

InnerError

InnerError
Inner error as defined in the Microsoft REST guidelines (https://github.com/microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses).

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-tune

string

This object represents a fine tune job.

fine-tune-event

string

This object represents an event of a fine tune job.

fine_tuning.job

string

This object represents a fine tune 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).