AI DevKit
Glitch9 Inc.Glitch9 DocsDiscordIssues
  • Introduction
    • AI DevKit 3.0
    • Update Logs
    • Troubleshooting
      • ❗Issues After Updating AIDevKit?
      • ❗The type or namespace name 'Newtonsoft' could not be found
      • ❗Build Error: The name 'UnityMenu' does not exist in the current context
      • ❗Model 'modelName' not found
      • ❗The model `model name` does not exist or you do not have access to it
      • ❗The type or namespace name 'AndroidJavaObject' could not be found
      • ❗The type or namaspace name 'Plastic' does not exist
      • ❗Build Error: The name 'Asset Database' does not exist in the current context
      • ❗'ModelData.Create(Provider, string, UnixTime?, string)': not all code paths return a value
      • ⚠️ Timeout Issues
      • ⚠️ Receiving a “HTTP/1.1 400 Bad Request” Error?
    • FAQ
      • My OpenAI API free trial has ended or is inactive.
  • Quick Start
    • Get API Keys
      • OpenAI API Key Guide
      • Google API Key Guide
      • ElevenLabs API Key Guide
    • Text Generation
    • C# Object Generation
    • Image Generation
    • Sound Effect Generation
    • Text to Speech (TTS)
    • Speech to Text (STT)
    • Voice Changer
    • Audio Isolation
  • Pro Features
    • Generation Menu
      • Code Generators
        • C# Script Generator
        • Unity Component Generator
    • Editor Chat
    • Editor Vision (TTI, ITI)
    • Editor Speech (TTS)
    • Management Tools
      • Prompt History Viewer
      • AI Model Manager
      • TTS Voice Manager
      • OpenAI File Manager
      • OpenAI Assistant Manager
      • ElevenLabs Voice Library
  • Assistants API (OpenAI)
    • How it works
    • Creating custom functions
    • Creating assistants API
  • Advanced API Supports
    • OpenAI API
      • 💬Chat completions
      • 🖼️Image operations
      • 🗣️Text to speech
      • 🎙️Speech to text
        • Recording real-time in Unity
      • 💾Files
      • 🔎Embeddings
      • 🛡️Moderations
      • ⚙️Fine-tuning
    • Google API
      • 📝System instructions
      • 💬Text generation
      • ⚙️Fine-tuning
      • ▶️Fucntion calling
      • 🔎Embeddings
      • 🛡️Safety
      • 💻Code execution
    • ElevenLabs API
  • Legacy Documents
    • AI DevKit 1.0 - 2.0
      • AI DevKit 2.0
      • AI DevKit 1.0
      • Preperation
      • Event Handlers
      • Scriptable Toolkits
        • Chat Streamer
        • Image Generator
        • Voice Transcriber
        • Voice Generator
      • Editor Tools
Powered by GitBook
On this page
  • Fine-Tuning Operations Overview:
  • Sample Code for Fine-Tuning Requests:
  1. Advanced API Supports
  2. OpenAI API

Fine-tuning

PreviousModerationsNextGoogle API

Last updated 18 days ago

To enhance the capabilities of OpenAI's models within your Unity project, you can leverage the fine-tuning feature to tailor the models more closely to your specific needs or data. Fine-tuning allows you to train an existing OpenAI model on your own dataset, resulting in a custom model that can offer better performance for your particular application, whether it's generating more relevant text, recognizing specific styles in image generation, or understanding particular dialects in speech recognition.

For comprehensive details on the process, parameters, and management of fine-tuned models, refer to the .

Fine-Tuning Operations Overview:

  • Model Training: Adjust an existing OpenAI model by training it on a custom dataset to improve its relevance to your specific requirements.

  • Model Management: After fine-tuning, manage your custom models, including deployment, monitoring, and versioning, directly within your Unity project.

Sample Code for Fine-Tuning Requests:

1. Model Training Request:

Initiate the fine-tuning process by specifying your dataset and the base model to refine.

FineTuningRequest request = new FineTuningRequest.Builder()
    .SetTrainingFile("path/to/your/training/data.csv") // Specify the dataset
    .SetBaseModel(FineTuningModel.Gpt3_5Turbo) // Specify the base model for fine-tuning
    .Build();

FineTuningJob fineTuningJob = await request.ExecuteAsync();

Debug.Log($"Fine-tuning started: Job ID {fineTuningJob.Id}");

This example illustrates how to start a fine-tuning job. You'll need to prepare a dataset that the model will learn from, which typically involves creating a .csv file with examples of inputs and desired outputs.

2. Model Management Request:

After fine-tuning, you can list, retrieve, or delete your custom models, ensuring you have the right version deployed for your application's needs.

// List your fine-tuned models
ModelObject[] models = await OpenAiClient.DefaultInstance.ListModels();

foreach (var model in models)
{
    Debug.Log($"Model ID: {model.Id}, Status: {model.Status}");
}

// Retrieve a specific fine-tuned model
string modelId = "your-model-id";
ModelObject myModel = await OpenAiClient.DefaultInstance.RetrieveModel(modelId);

Debug.Log($"Retrieved Model: {myModel.Id}");

// Delete a fine-tuned model (if no longer needed)
bool deletionSuccess = await OpenAiClient.DefaultInstance.DeleteModel(modelId);

if (deletionSuccess)
{
    Debug.Log("Model deleted successfully.");
}

Implementing Fine-Tuning in Unity using OpenAI:

To utilize fine-tuning within your Unity project:

  1. Prepare Your Dataset: Create a dataset that represents the kind of output you expect from the model. This involves pairing input text with expected output text in a format understandable by the fine-tuning process.

  2. Initiate Fine-Tuning: Use the FineTuningRequest to configure and start the fine-tuning process with your dataset and chosen base model.

  3. Manage Custom Models: After fine-tuning, utilize the model management functionalities to deploy, monitor, and maintain your custom models within your Unity application.

By fine-tuning OpenAI models to better fit your specific use cases, you unlock enhanced performance and more relevant outputs from the AI, driving greater value and engagement in your Unity applications. Whether for generating unique game content, tailoring chatbot interactions, or improving image generation, fine-tuning provides a powerful tool for customizing AI behaviors to your needs.

⚙️
Fine-Tuning API Reference