node.jsopenai-apifine-tuning

OpenAI API returns null when I retrieve the fine-tuned model


I'm fine-tuning a model and generating actions from text. I create a train.jsonl file, upload it, and fine-tune the model. However, when I try to get the name of the model I just created, it returns null.

I fine-tune a model like this:

const model = await openai.fineTuning.jobs.create({
  training_file: process.env.FILE_ID,
  model: 'babbage-002',
})

Then I try to retrieve the fine-tuned model like this:

const response = await openai.fineTuning.jobs.retrieve(
    process.env.FINE_TUNE_ID,
)

But this is the response I get from the OpenAI API:

data:  {
  object: 'fine_tuning.job',
  id: 'ftjob-NSFvxzJtTSfR5jcqQTfeDTCo',
  model: 'babbage-002',
  created_at: 1722546992,
  fine_tuned_model: null,
  organization_id: 'org-GLjhkXwkbQrLOvHk0762UcmL',
  result_files: [],
  status: 'running',
  validation_file: null,
  training_file: 'file-Lh1C4Vv1HDIv7LxXUGh9mIL9',
  hyperparameters: { n_epochs: 9, batch_size: 1, learning_rate_multiplier: 16 },
  trained_tokens: null,
  error: {},
  user_provided_suffix: null,
  seed: 1564492262,
  estimated_finish: null,
  integrations: []
}

Solution

  • The fine-tuning job hasn't finished yet.

    The fine-tuning flow is the following:

    1. Create a fine-tuning job.
    2. Fine-tuning is in progress.
    3. Retrieve the fine-tuning job.

    Try to run the following code to see if the fine-tuning is still in progress.

    import OpenAI from "openai";
    
    const client = new OpenAI();
    
    async function main() {
      const list = await client.fineTuning.jobs.list();
    
      for await (const fineTune of list) {
        console.log(fineTune);
      }
    }
    
    main();