Class: OpenAI::Resources::FineTuning::Jobs

Inherits:
Object
  • Object
show all
Defined in:
lib/openai/resources/fine_tuning/jobs.rb,
lib/openai/resources/fine_tuning/jobs/checkpoints.rb,
sig/openai/resources/fine_tuning/jobs.rbs,
sig/openai/resources/fine_tuning/jobs/checkpoints.rbs

Overview

Manage fine-tuning jobs to tailor a model to your specific training data.

Defined Under Namespace

Classes: Checkpoints

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Jobs

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Jobs.

Parameters:



267
268
269
270
# File 'lib/openai/resources/fine_tuning/jobs.rb', line 267

def initialize(client:)
  @client = client
  @checkpoints = OpenAI::Resources::FineTuning::Jobs::Checkpoints.new(client: client)
end

Instance Attribute Details

#checkpointsOpenAI::Resources::FineTuning::Jobs::Checkpoints (readonly)

Manage fine-tuning jobs to tailor a model to your specific training data.



10
11
12
# File 'lib/openai/resources/fine_tuning/jobs.rb', line 10

def checkpoints
  @checkpoints
end

Instance Method Details

#cancel(fine_tuning_job_id, request_options: {}) ⇒ OpenAI::Models::FineTuning::FineTuningJob

Immediately cancel a fine-tune job.

Parameters:

  • fine_tuning_job_id (String)

    The ID of the fine-tuning job to cancel.

  • request_options (OpenAI::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



178
179
180
181
182
183
184
185
186
# File 'lib/openai/resources/fine_tuning/jobs.rb', line 178

def cancel(fine_tuning_job_id, params = {})
  @client.request(
    method: :post,
    path: ["fine_tuning/jobs/%1$s/cancel", fine_tuning_job_id],
    model: OpenAI::FineTuning::FineTuningJob,
    security: {bearer_auth: true},
    options: params[:request_options]
  )
end

#create(model:, training_file:, hyperparameters: nil, integrations: nil, metadata: nil, method_: nil, seed: nil, suffix: nil, validation_file: nil, request_options: {}) ⇒ OpenAI::Models::FineTuning::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.

Learn more about fine-tuning

Parameters:

  • model (String, Symbol, OpenAI::Models::FineTuning::JobCreateParams::Model)

    The name of the model to fine-tune. You can select one of the supported models.

  • training_file (String)

    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.

  • hyperparameters (OpenAI::Models::FineTuning::JobCreateParams::Hyperparameters)

    The hyperparameters used for the fine-tuning job. This value is now deprecated in favor of method, and should be passed in under the method parameter.

  • integrations (Array<OpenAI::Models::FineTuning::JobCreateParams::Integration>, nil)

    A list of integrations to enable for your fine-tuning job.

  • metadata (Hash{Symbol=>String}, nil)

    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.

  • method_ (OpenAI::Models::FineTuning::JobCreateParams::Method)

    The method used for fine-tuning.

  • seed (Integer, nil)

    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.

  • suffix (String, nil)

    A string of up to 64 characters that will be added to your fine-tuned model name.

    For example, a suffix of "custom-model-name" would produce a model name like ft:gpt-4o-mini:openai:custom-model-name:7p4lURel.

  • validation_file (String, nil)

    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.

  • request_options (OpenAI::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



97
98
99
100
101
102
103
104
105
106
107
# File 'lib/openai/resources/fine_tuning/jobs.rb', line 97

def create(params)
  parsed, options = OpenAI::FineTuning::JobCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "fine_tuning/jobs",
    body: parsed,
    model: OpenAI::FineTuning::FineTuningJob,
    security: {bearer_auth: true},
    options: options
  )
end

#list(after: nil, limit: nil, metadata: nil, request_options: {}) ⇒ OpenAI::Internal::CursorPage<OpenAI::Models::FineTuning::FineTuningJob>

List your organization's fine-tuning jobs

Parameters:

  • after (String)

    Identifier for the last job from the previous pagination request.

  • limit (Integer)

    Number of fine-tuning jobs to retrieve.

  • metadata (Hash{Symbol=>String}, nil)

    Optional metadata filter. To filter, use the syntax metadata[k]=v. Alternatively, set metadata=null to indicate no metadata.

  • request_options (OpenAI::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



152
153
154
155
156
157
158
159
160
161
162
163
164
# File 'lib/openai/resources/fine_tuning/jobs.rb', line 152

def list(params = {})
  parsed, options = OpenAI::FineTuning::JobListParams.dump_request(params)
  query = OpenAI::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "fine_tuning/jobs",
    query: query,
    page: OpenAI::Internal::CursorPage,
    model: OpenAI::FineTuning::FineTuningJob,
    security: {bearer_auth: true},
    options: options
  )
end

#list_events(fine_tuning_job_id, after: nil, limit: nil, request_options: {}) ⇒ OpenAI::Internal::CursorPage<OpenAI::Models::FineTuning::FineTuningJobEvent>

Get status updates for a fine-tuning job.

Parameters:

  • fine_tuning_job_id (String)

    The ID of the fine-tuning job to get events for.

  • after (String)

    Identifier for the last event from the previous pagination request.

  • limit (Integer)

    Number of events to retrieve.

  • request_options (OpenAI::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



206
207
208
209
210
211
212
213
214
215
216
217
218
# File 'lib/openai/resources/fine_tuning/jobs.rb', line 206

def list_events(fine_tuning_job_id, params = {})
  parsed, options = OpenAI::FineTuning::JobListEventsParams.dump_request(params)
  query = OpenAI::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["fine_tuning/jobs/%1$s/events", fine_tuning_job_id],
    query: query,
    page: OpenAI::Internal::CursorPage,
    model: OpenAI::FineTuning::FineTuningJobEvent,
    security: {bearer_auth: true},
    options: options
  )
end

#pause(fine_tuning_job_id, request_options: {}) ⇒ OpenAI::Models::FineTuning::FineTuningJob

Pause a fine-tune job.

Parameters:

  • fine_tuning_job_id (String)

    The ID of the fine-tuning job to pause.

  • request_options (OpenAI::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



232
233
234
235
236
237
238
239
240
# File 'lib/openai/resources/fine_tuning/jobs.rb', line 232

def pause(fine_tuning_job_id, params = {})
  @client.request(
    method: :post,
    path: ["fine_tuning/jobs/%1$s/pause", fine_tuning_job_id],
    model: OpenAI::FineTuning::FineTuningJob,
    security: {bearer_auth: true},
    options: params[:request_options]
  )
end

#resume(fine_tuning_job_id, request_options: {}) ⇒ OpenAI::Models::FineTuning::FineTuningJob

Resume a fine-tune job.

Parameters:

  • fine_tuning_job_id (String)

    The ID of the fine-tuning job to resume.

  • request_options (OpenAI::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



254
255
256
257
258
259
260
261
262
# File 'lib/openai/resources/fine_tuning/jobs.rb', line 254

def resume(fine_tuning_job_id, params = {})
  @client.request(
    method: :post,
    path: ["fine_tuning/jobs/%1$s/resume", fine_tuning_job_id],
    model: OpenAI::FineTuning::FineTuningJob,
    security: {bearer_auth: true},
    options: params[:request_options]
  )
end

#retrieve(fine_tuning_job_id, request_options: {}) ⇒ OpenAI::Models::FineTuning::FineTuningJob

Get info about a fine-tuning job.

Learn more about fine-tuning

Parameters:

  • fine_tuning_job_id (String)

    The ID of the fine-tuning job.

  • request_options (OpenAI::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



123
124
125
126
127
128
129
130
131
# File 'lib/openai/resources/fine_tuning/jobs.rb', line 123

def retrieve(fine_tuning_job_id, params = {})
  @client.request(
    method: :get,
    path: ["fine_tuning/jobs/%1$s", fine_tuning_job_id],
    model: OpenAI::FineTuning::FineTuningJob,
    security: {bearer_auth: true},
    options: params[:request_options]
  )
end