openai.resources.fine_tuning
The fine_tuning
module provides classes for handling fine-tuning operations, including the initiation, management, and retrieval of fine-tuning jobs.
The module supports synchronous and asynchronous operations, offering interfaces for working with jobs directly, as well as with raw or streaming responses. Designed for use in applications requiring custom model training on specific datasets to improve model performance for tailored tasks.
Modules:
Name | Description |
---|---|
fine_tuning |
The The module supports synchronous and asynchronous operations, offering interfaces for working with jobs directly, as well as with raw or streaming responses. Designed for use in applications requiring custom model training on specific datasets to improve model performance for tailored tasks. |
jobs |
The Fine-tuning jobs allow you to customize pre-trained models with your own datasets, optimizing performance for specific tasks or improving understanding of particular data types. The classes in the |
Classes:
AsyncFineTuning
AsyncFineTuning(client: AsyncOpenAI)
AsyncFineTuningWithRawResponse
AsyncFineTuningWithRawResponse(
fine_tuning: AsyncFineTuning,
)
AsyncFineTuningWithStreamingResponse
AsyncFineTuningWithStreamingResponse(
fine_tuning: AsyncFineTuning,
)
AsyncJobs
AsyncJobs(client: AsyncOpenAI)
Methods:
Name | Description |
---|---|
cancel |
Immediately cancel a fine-tune job. |
create |
Creates a fine-tuning job which begins the process of creating a new model from |
list |
List your organization's fine-tuning jobs |
list_events |
Get status updates for a fine-tuning job. |
retrieve |
Get info about a fine-tuning job. |
with_raw_response |
|
with_streaming_response |
|
cancel
async
cancel(
fine_tuning_job_id: str,
*,
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> FineTuningJob
Immediately cancel a fine-tune job.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
extra_headers
|
Headers | None
|
Send extra headers |
None
|
extra_query
|
Query | None
|
Add additional query parameters to the request |
None
|
extra_body
|
Body | None
|
Add additional JSON properties to the request |
None
|
timeout
|
float | Timeout | None | NotGiven
|
Override the client-level default timeout for this request, in seconds |
NOT_GIVEN
|
create
async
create(
*,
model: Union[
str,
Literal[
"babbage-002", "davinci-002", "gpt-3.5-turbo"
],
],
training_file: str,
hyperparameters: Hyperparameters | NotGiven = NOT_GIVEN,
suffix: Optional[str] | NotGiven = NOT_GIVEN,
validation_file: Optional[str] | NotGiven = NOT_GIVEN,
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> FineTuningJob
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.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model
|
Union[str, Literal['babbage-002', 'davinci-002', 'gpt-3.5-turbo']]
|
The name of the model to fine-tune. You can select one of the supported models. |
required |
training_file
|
str
|
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 See the fine-tuning guide for more details. |
required |
hyperparameters
|
Hyperparameters | NotGiven
|
The hyperparameters used for the fine-tuning job. |
NOT_GIVEN
|
suffix
|
Optional[str] | NotGiven
|
A string of up to 18 characters that will be added to your fine-tuned model name. For example, a |
NOT_GIVEN
|
validation_file
|
Optional[str] | NotGiven
|
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 See the fine-tuning guide for more details. |
NOT_GIVEN
|
extra_headers
|
Headers | None
|
Send extra headers |
None
|
extra_query
|
Query | None
|
Add additional query parameters to the request |
None
|
extra_body
|
Body | None
|
Add additional JSON properties to the request |
None
|
timeout
|
float | Timeout | None | NotGiven
|
Override the client-level default timeout for this request, in seconds |
NOT_GIVEN
|
list
list(
*,
after: str | NotGiven = NOT_GIVEN,
limit: int | NotGiven = NOT_GIVEN,
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> AsyncPaginator[
FineTuningJob, AsyncCursorPage[FineTuningJob]
]
List your organization's fine-tuning jobs
Parameters:
Name | Type | Description | Default |
---|---|---|---|
after
|
str | NotGiven
|
Identifier for the last job from the previous pagination request. |
NOT_GIVEN
|
limit
|
int | NotGiven
|
Number of fine-tuning jobs to retrieve. |
NOT_GIVEN
|
extra_headers
|
Headers | None
|
Send extra headers |
None
|
extra_query
|
Query | None
|
Add additional query parameters to the request |
None
|
extra_body
|
Body | None
|
Add additional JSON properties to the request |
None
|
timeout
|
float | Timeout | None | NotGiven
|
Override the client-level default timeout for this request, in seconds |
NOT_GIVEN
|
list_events
list_events(
fine_tuning_job_id: str,
*,
after: str | NotGiven = NOT_GIVEN,
limit: int | NotGiven = NOT_GIVEN,
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> AsyncPaginator[
FineTuningJobEvent, AsyncCursorPage[FineTuningJobEvent]
]
Get status updates for a fine-tuning job.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
after
|
str | NotGiven
|
Identifier for the last event from the previous pagination request. |
NOT_GIVEN
|
limit
|
int | NotGiven
|
Number of events to retrieve. |
NOT_GIVEN
|
extra_headers
|
Headers | None
|
Send extra headers |
None
|
extra_query
|
Query | None
|
Add additional query parameters to the request |
None
|
extra_body
|
Body | None
|
Add additional JSON properties to the request |
None
|
timeout
|
float | Timeout | None | NotGiven
|
Override the client-level default timeout for this request, in seconds |
NOT_GIVEN
|
retrieve
async
retrieve(
fine_tuning_job_id: str,
*,
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> FineTuningJob
Get info about a fine-tuning job.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
extra_headers
|
Headers | None
|
Send extra headers |
None
|
extra_query
|
Query | None
|
Add additional query parameters to the request |
None
|
extra_body
|
Body | None
|
Add additional JSON properties to the request |
None
|
timeout
|
float | Timeout | None | NotGiven
|
Override the client-level default timeout for this request, in seconds |
NOT_GIVEN
|
AsyncJobsWithRawResponse
AsyncJobsWithRawResponse(jobs: AsyncJobs)
AsyncJobsWithStreamingResponse
AsyncJobsWithStreamingResponse(jobs: AsyncJobs)
FineTuning
FineTuning(client: OpenAI)
FineTuningWithRawResponse
FineTuningWithRawResponse(fine_tuning: FineTuning)
FineTuningWithStreamingResponse
FineTuningWithStreamingResponse(fine_tuning: FineTuning)
Jobs
Jobs(client: OpenAI)
Methods:
Name | Description |
---|---|
cancel |
Immediately cancel a fine-tune job. |
create |
Creates a fine-tuning job which begins the process of creating a new model from |
list |
List your organization's fine-tuning jobs |
list_events |
Get status updates for a fine-tuning job. |
retrieve |
Get info about a fine-tuning job. |
with_raw_response |
|
with_streaming_response |
|
cancel
cancel(
fine_tuning_job_id: str,
*,
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> FineTuningJob
Immediately cancel a fine-tune job.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
extra_headers
|
Headers | None
|
Send extra headers |
None
|
extra_query
|
Query | None
|
Add additional query parameters to the request |
None
|
extra_body
|
Body | None
|
Add additional JSON properties to the request |
None
|
timeout
|
float | Timeout | None | NotGiven
|
Override the client-level default timeout for this request, in seconds |
NOT_GIVEN
|
create
create(
*,
model: Union[
str,
Literal[
"babbage-002", "davinci-002", "gpt-3.5-turbo"
],
],
training_file: str,
hyperparameters: Hyperparameters | NotGiven = NOT_GIVEN,
suffix: Optional[str] | NotGiven = NOT_GIVEN,
validation_file: Optional[str] | NotGiven = NOT_GIVEN,
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> FineTuningJob
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.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model
|
Union[str, Literal['babbage-002', 'davinci-002', 'gpt-3.5-turbo']]
|
The name of the model to fine-tune. You can select one of the supported models. |
required |
training_file
|
str
|
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 See the fine-tuning guide for more details. |
required |
hyperparameters
|
Hyperparameters | NotGiven
|
The hyperparameters used for the fine-tuning job. |
NOT_GIVEN
|
suffix
|
Optional[str] | NotGiven
|
A string of up to 18 characters that will be added to your fine-tuned model name. For example, a |
NOT_GIVEN
|
validation_file
|
Optional[str] | NotGiven
|
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 See the fine-tuning guide for more details. |
NOT_GIVEN
|
extra_headers
|
Headers | None
|
Send extra headers |
None
|
extra_query
|
Query | None
|
Add additional query parameters to the request |
None
|
extra_body
|
Body | None
|
Add additional JSON properties to the request |
None
|
timeout
|
float | Timeout | None | NotGiven
|
Override the client-level default timeout for this request, in seconds |
NOT_GIVEN
|
list
list(
*,
after: str | NotGiven = NOT_GIVEN,
limit: int | NotGiven = NOT_GIVEN,
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> SyncCursorPage[FineTuningJob]
List your organization's fine-tuning jobs
Parameters:
Name | Type | Description | Default |
---|---|---|---|
after
|
str | NotGiven
|
Identifier for the last job from the previous pagination request. |
NOT_GIVEN
|
limit
|
int | NotGiven
|
Number of fine-tuning jobs to retrieve. |
NOT_GIVEN
|
extra_headers
|
Headers | None
|
Send extra headers |
None
|
extra_query
|
Query | None
|
Add additional query parameters to the request |
None
|
extra_body
|
Body | None
|
Add additional JSON properties to the request |
None
|
timeout
|
float | Timeout | None | NotGiven
|
Override the client-level default timeout for this request, in seconds |
NOT_GIVEN
|
list_events
list_events(
fine_tuning_job_id: str,
*,
after: str | NotGiven = NOT_GIVEN,
limit: int | NotGiven = NOT_GIVEN,
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> SyncCursorPage[FineTuningJobEvent]
Get status updates for a fine-tuning job.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
after
|
str | NotGiven
|
Identifier for the last event from the previous pagination request. |
NOT_GIVEN
|
limit
|
int | NotGiven
|
Number of events to retrieve. |
NOT_GIVEN
|
extra_headers
|
Headers | None
|
Send extra headers |
None
|
extra_query
|
Query | None
|
Add additional query parameters to the request |
None
|
extra_body
|
Body | None
|
Add additional JSON properties to the request |
None
|
timeout
|
float | Timeout | None | NotGiven
|
Override the client-level default timeout for this request, in seconds |
NOT_GIVEN
|
retrieve
retrieve(
fine_tuning_job_id: str,
*,
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> FineTuningJob
Get info about a fine-tuning job.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
extra_headers
|
Headers | None
|
Send extra headers |
None
|
extra_query
|
Query | None
|
Add additional query parameters to the request |
None
|
extra_body
|
Body | None
|
Add additional JSON properties to the request |
None
|
timeout
|
float | Timeout | None | NotGiven
|
Override the client-level default timeout for this request, in seconds |
NOT_GIVEN
|
JobsWithRawResponse
JobsWithRawResponse(jobs: Jobs)