Specialize task behavior
A task needs consistent behavior that prompting alone does not provide.
AI & ML · Const
Fine-tuning adapts an OpenAI base model to a specific task using representative input-output examples. The process involves preparing JSONL data, creating a job, and evaluating the resulting model.
Fine-tuning adapts an OpenAI base model to examples of the inputs and outputs expected by an application. The workflow is to collect representative data, upload it as JSONL, create a training job, and evaluate the resulting model; reinforcement fine-tuning also requires a grader.
client.fine_tuning.jobs.create(training_file="file-...", model="...")| Name | Type | Description |
|---|---|---|
model | string | The base model to adapt; it must be one of the supported models. |
training_file | string | The identifier of an uploaded JSONL file containing training examples. |
validation_file | string | Optional identifier of an uploaded JSONL validation file used for periodic validation metrics. |
A fine-tuning job whose eventual result includes the newly created fine-tuned model name.
from openai import OpenAI
client = OpenAI()
job = client.fine_tuning.jobs.create(
training_file="file-abc123",
model="gpt-4.1-mini"
)
print(job.id)Creates a fine-tuning job from an uploaded JSONL training file and prints the job identifier.
A task needs consistent behavior that prompting alone does not provide.
A production workload repeats a well-defined input-output pattern.
A reinforcement fine-tuning workflow needs scored behavior.
model optimizationJSONLtraining filevalidation filereinforcement fine-tuninggraderevaluation