tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Interviews | Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 Generative AI > OpenAI API > OpenAI Fine-tuning API - Custom Model Training

OpenAI Fine-tuning API - Custom Model Training

Author: Venkata Sudhakar

OpenAI fine-tuning lets you adapt a base model like gpt-4o-mini to your specific domain by training it on your own examples. The result is a custom model that follows your tone, format, and domain conventions without lengthy prompts. For ShopMax India, a fine-tuned model can respond in the exact style used by the support team - concise, polite, and aware of Indian e-commerce specifics like COD and EMI options.

Fine-tuning requires a training file in JSONL format where each line contains a messages array with system, user, and assistant turns. You upload this file, create a fine-tuning job specifying the base model and training file, then poll the job until it completes. The finished job gives you a fine_tuned_model ID that you use exactly like any other model ID in chat completions.

The following example prepares a training file, uploads it, and kicks off a fine-tuning job to teach the model ShopMax India support responses.


It gives the following output,

Training file ID: file-xyz789
Fine-tuning job: ftjob-abc123 - Status: validating_files
Status: queued
Status: running
Status: succeeded
Fine-tuned model: ft:gpt-4o-mini-2024-07-18:shopmax-india::abcdef12

Once the fine-tuned model ID is available, use it in any chat completion by passing it as the model parameter. ShopMax India's fine-tuned model will automatically respond in the trained style without needing a detailed system prompt. Aim for at least 50 to 100 high-quality training examples to see meaningful improvement over the base model.


 
  


  
bl  br