Method CreateTrainingObject
- Namespace
- LMKit.TextAnalysis
- Assembly
- LM-Kit.NET.dll
CreateTrainingObject(IList<string>, IList<(string, string)>, int)
Creates an object for fine-tuning a categorization model using provided training data.
public LoraFinetuning CreateTrainingObject(IList<string> categories, IList<(string, string)> trainingData, int maxSamples = 1000)
Parameters
categories
IList<string>A list of predefined categories. Each category should be a unique, non-null string.
trainingData
IList<(string, string)>A list of tuples where each tuple contains a text and its corresponding category.
maxSamples
intThe maximum number of training samples to use. The default value is 1000.
Returns
- LoraFinetuning
A LoraFinetuning object for fine-tuning the categorization model.
Examples
using LMKit.Model;
using LMKit.TextAnalysis;
using LMKit.Finetuning;
using System;
using System.Collections.Generic;
class Example
{
static void Main()
{
Uri modelUri = new Uri("https://your-model-link-here");
LM model = new LM(modelUri);
Categorization categorization = new Categorization(model);
var categories = new List<string> { "food", "technology", "travel" };
var trainingData = new List<(string, string)>
{
("Pizza is delicious.", "food"),
("Quantum computing can change the world.", "technology"),
("Visiting Tokyo next year!", "travel")
};
try
{
LoraFinetuning fineTuner = categorization.CreateTrainingObject(categories, trainingData);
Console.WriteLine("Training object created successfully. Ready for fine-tuning steps.");
}
catch (Exception ex)
{
Console.WriteLine($"Error: {ex.Message}");
}
}
}
Exceptions
- ArgumentNullException
Thrown if the
categories
ortrainingData
arguments are null.- ArgumentException
Thrown if the
trainingData
list is empty, or if an entry is associated with an undefined category.- InvalidModelException
Thrown if fine-tuning is not supported for Embedding classification mode.