Skip to content

Create Fine-Tuning Job (OpenAI) v1.0.0

Creates a job that fine-tunes a specified model from a given dataset.

How can I use the Step?

You can use the Step to customize a model for your application. Fine-tuning lets you train a model on more examples than can fit in a prompt and obtain better results.

Read the OpenAI Fine-tuning guide to learn more.

How does the Step work?

You authorize the Step, provide training and validation files, and specify training parameters that suit your task. Taking these inputs, the Step requests Fine-Tunes API to create a fine-tuning job. Once a model has been trained, you can request it using the Request Fine-Tuned Model Step.

Prerequisites

To get started, you need an OpenAI API key. To retrieve an API key for your requests, visit your API Keys page.

Authorization

To authorize the Step, you have two options:

  • Inherit from previous Step (default): Use the same authorization as the previous Step in the Flow.
  • Select authorization in the current Step: Choose an existing authorization or create a new one.

In case you need to create a new authorization, follow these steps:

  1. Choose Select authorization in the current Step and then select Create a new authorization from the list.
  2. In the Add authorization modal window, provide the required details:
    • Authorization name: Name your new authorization.
    • API Key: Enter your OpenAI API key.
  3. Click Add to confirm settings and add your new authorization.

Request settings

The settings in this section reflect the request body of the Fine-Tunes API, which you must use as your primary reference:

  • Training file: File to train the model.
  • Validation file: File to validate the model. Required for computing classification metrics.
  • Model: Model to fine-tune. For model details, consult the Models overview.
  • Compute classification metrics: Enable to compute classification metrics. Provide task-specific parameters.
  • N epochs: Number of epochs for model training.
  • Batch size: Number of samples for each model parameter update.
  • Learning rate multiplier: Multiplier to adjust the model's learning rate.
  • Prompt loss weight: Weight for prompt loss in the training objective.
  • Suffix: Suffix, if needed.

Refer to the Completions API for model parameters.

Merge field settings

The Step returns the result as a JSON object and stores it in the Merge field variable. Thus you can access the output JSON object from any point of your Flow.

Output example

The output depends on the development and the settings you provide. It contains details of the enqueued job, including its ID, status, ongoing events, and the name of the fine-tuned model once complete.

To learn more, see the following output example:

json
{
  "id": "ft-AF1WoRqd3aJAHsqc9NY7iL8F",
  "object": "fine-tune",
  "model": "curie",
  "created_at": 1614807352,
  "events": [
    {
      "object": "fine-tune-event",
      "created_at": 1614807352,
      "level": "info",
      "message": "Job enqueued. Waiting for jobs ahead to complete. Queue number: 0."
    }
  ],
  "fine_tuned_model": null,
  "hyperparams": {
    "batch_size": 4,
    "learning_rate_multiplier": 0.1,
    "n_epochs": 4,
    "prompt_loss_weight": 0.1,
  },
  "organization_id": "org-...",
  "result_files": [],
  "status": "pending",
  "validation_files": [],
  "training_files": [
    {
      "id": "file-XGinujblHPwGLSztz8cPS8XY",
      "object": "file",
      "bytes": 1547276,
      "created_at": 1610062281,
      "filename": "my-data-train.jsonl",
      "purpose": "fine-tune-train"
    }
  ],
  "updated_at": 1614807352,
}
{
  "id": "ft-AF1WoRqd3aJAHsqc9NY7iL8F",
  "object": "fine-tune",
  "model": "curie",
  "created_at": 1614807352,
  "events": [
    {
      "object": "fine-tune-event",
      "created_at": 1614807352,
      "level": "info",
      "message": "Job enqueued. Waiting for jobs ahead to complete. Queue number: 0."
    }
  ],
  "fine_tuned_model": null,
  "hyperparams": {
    "batch_size": 4,
    "learning_rate_multiplier": 0.1,
    "n_epochs": 4,
    "prompt_loss_weight": 0.1,
  },
  "organization_id": "org-...",
  "result_files": [],
  "status": "pending",
  "validation_files": [],
  "training_files": [
    {
      "id": "file-XGinujblHPwGLSztz8cPS8XY",
      "object": "file",
      "bytes": 1547276,
      "created_at": 1610062281,
      "filename": "my-data-train.jsonl",
      "purpose": "fine-tune-train"
    }
  ],
  "updated_at": 1614807352,
}

Error Handling

By default, the Handle error toggle is on, and the Step handles errors with a separate exit. If any error occurs during the Step execution, the Flow proceeds down the error exit.

If the Handle error toggle is disabled, the Step does not handle errors. In this case, if any error occurs during the Step execution, the Flow fails immediately after exceeding the Flow timeout. To prevent the Flow from being suspended and continue handling errors, you can place the Flow Error Handling Step before the main logic or your Flow.

Reporting

The Step reports once after its execution. You can change the Step log level and add new tags in the section.

Log level

By default, the Step inherits its log level from Flow's log level. You can change the Step's log level by selecting an appropriate option from the Log level list.

Tags

Tags help organize and filter session information when generating reports. When adding a new tag, you can specify the tag category, label, and value.

Service dependencies

  • flow builder - v2.28.3
  • event-manager - v2.3.0
  • deployer - v2.6.0
  • library v2.11.3
  • studio v2.64.1

Release notes

v1.0.0

  • Initial release