Skip to content

OpenAI.FineTuneJob

Andrew Lambert edited this page Jul 14, 2024 · 6 revisions

OpenAI.FineTuneJob

Class Declaration

 Protected Class FineTuneJob

Remarks

This class represents a fine-tune job that is, has been, or will be run with one of the base AI models. Refer to the OpenAI documentation on the /v1/fine_tuning/jobs endpoint for further details.

Fine tuning requires the creation of JSONL-formatted training files. Refer to the FineTuneData class to generate such files.

Example

This example creates a new fine tuning job using a previously-uploaded JSONL training File:

  OpenAI.APIKey = "YOUR API KEY"
  Dim trainingfile As OpenAI.File = OpenAI.File.Lookup(0) ' a previously uploaded training file
  Dim basemodel As OpenAI.Model = "gpt-3.5-turbo-1106" ' the model to be trained
  Dim job As OpenAI.FineTuneJob = OpenAI.FineTuneJob.Create(trainingfile, basemodel, "test")
  Dim jobID As String = job.ID ' e.g. "ftjob-cBiqPrOfW8sLZSSlMI2mLNYX"

Once the job is created it will take some time before it is finished running. You can check the status of a job by reading its Status property. You can retrieve existing jobs by calling the Lookup() shared method:

  OpenAI.APIKey = "YOUR API KEY"
  Dim job As OpenAI.FineTuneJob = OpenAI.FineTuneJob.Lookup("ftjob-cBiqPrOfW8sLZSSlMI2mLNYX")
  Select Case job.Status
  Case OpenAI.JobStatus.Succeeded
    ' finished running successfully
  Case OpenAI.JobStatus.Failed
    ' finished running with errors
  Else
    ' running or processing
  End Select

After the fine-tune job has successfully completed, the resulting fine-tuned Model will be available for use with any compatible endpoint:

  OpenAI.APIKey = "YOUR API KEY"
  Dim job As OpenAI.FineTuneJob = OpenAI.FineTuneJob.Lookup("ftjob-cBiqPrOfW8sLZSSlMI2mLNYX")
  If job.Status = OpenAI.JobStatus.Succeeded Then
    Dim modelID As String = job.FineTunedModel.ID ' e.g. "ft:gpt-3.5-turbo-1106:personal:test:8dwvgMxW"
  End If

Fine-tuned models are also listed alongside the base models:

  OpenAI.APIKey = "YOUR API KEY"
  Dim m As OpenAI.Model = "ft:gpt-3.5-turbo-1106:personal:test:8dwvgMxW"
  Dim response As OpenAI.ChatCompletion = OpenAI.ChatCompletion.Create("user", "What time is it?", m)
  Dim chatreply As String = response.GetResult()

Methods

Properties

Shared methods

Clone this wiki locally