AIDevKit - AI Suite for Unity
API ReferencesDiscordGlitch9
  • Introduction
    • AI Dev Kit 3.7.0
    • Troubleshooting
    • FAQ
    • Update Logs
      • AI Dev Kit v2
      • AI Dev Kit v1
  • Quick Start
    • API Key Setup
      • OpenAI
      • Google Gemini
      • ElevenLabs
      • OpenRouter
    • Adding Models & Voices
      • Quick Add Guide
      • Creating Snippets
    • Self-Hosting with Ollama
  • Editor Tools
    • Editor Chat
    • Asset Generators
    • Asset Managers
      • Prompt History
      • File Manager
      • Chatbot Manager
      • Assistant Manager
  • GEN Tasks
    • Overview
      • Prefixes
      • Sequence
    • Response
    • Image
    • Video
    • SoundFX
    • Speech
    • Transcript
    • Voice Change
    • Audio Isolation
  • Components
    • Chatbot
    • Chatbot (Assistants API)
    • Realtime Assistant
    • Modules
    • Event Receivers
  • Platform API
    • OpenAI
      • 💬Chat completions
      • 🖼️Image operations
      • 🗣️Text to speech
      • 🎙️Speech to text
        • Recording real-time in Unity
      • 💾Files
      • 🔎Embeddings
      • 🛡️Moderations
      • ⚙️Fine-tuning
      • Assistants API
        • How it works
        • Creating custom functions
        • Creating assistants API
    • Google Gemini
      • 📝System instructions
      • 💬Text generation
      • ⚙️Fine-tuning
      • ▶️Fucntion calling
      • 🔎Embeddings
      • 🛡️Safety
      • 💻Code execution
  • Legacy Documents
    • AI Dev Kit 1.0
      • Preperation
      • Scriptable Toolkits
        • Chat Streamer
        • Image Generator
        • Voice Transcriber
        • Voice Generator
      • Editor Tools
      • Troubleshooting (Legacy)
        • ❗Build Error: The name 'UnityMenu' does not exist in the current context
        • ❗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
      • Code Generators
        • C# Script Generator
        • Unity Component Generator
    • AI Dev Kit 2.0
      • Event Handlers
      • 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
Powered by GitBook
On this page
  • Fine-Tuning Operations Overview:
  • Sample Code for Fine-Tuning Requests:
  1. Platform API
  2. OpenAI

Fine-tuning

PreviousModerationsNextAssistants API

Last updated 1 month 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