Method CreateTrainingObject
- Namespace
- LMKit.TextAnalysis
- Assembly
- LM-Kit.NET.dll
CreateTrainingObject(IList<(string, bool)>, int)
Creates a LoraFinetuning object for fine-tuning a sarcasm detection model using the provided training data.
public LoraFinetuning CreateTrainingObject(IList<(string, bool)> trainingData, int maxSamples = 1000)
Parameters
trainingData
IList<(string, bool)>A list of tuples where each tuple contains a text (string) and a bool indicating sarcasm. The text represents the input data, and the boolean represents the expected output (sarcastic or not).
maxSamples
intThe maximum number of training samples to use. The default value is
1000
. If the number of samples intrainingData
exceeds this value, only the firstmaxSamples
samples will be used.
Returns
- LoraFinetuning
A LoraFinetuning object configured for fine-tuning the sarcasm detection model with the provided training data.
Examples
// Prepare training data
var trainingData = new List<(string, bool)>
{
("Oh sure, I'd love to work overtime again.", true),
("Thank you so much for your help.", false),
// Add more samples...
};
// Create training object
LoraFinetuning finetuning = sarcasmDetector.CreateTrainingObject(trainingData);
// Proceed with fine-tuning...
Remarks
This method allows you to fine-tune the model with custom data to improve sarcasm detection accuracy.
Exceptions
- ArgumentNullException
Thrown if the
trainingData
argument isnull
.- ArgumentException
Thrown if the
trainingData
list is empty or contains invalid entries.- InvalidModelException
Thrown if fine-tuning is not supported for the current model configuration.
CreateTrainingObject(TrainingDataset, int, bool, int?)
Creates a LoraFinetuning object for fine-tuning a sarcasm detection model using a specified dataset.
public LoraFinetuning CreateTrainingObject(SarcasmDetection.TrainingDataset dataset, int maxSamples = 1000, bool shuffle = true, int? seed = null)
Parameters
dataset
SarcasmDetection.TrainingDatasetThe dataset to be used for training.
maxSamples
intThe maximum number of samples to use from the dataset. Default is
1000
.shuffle
boolIndicates whether to shuffle the dataset before selecting samples. Default is
true
.seed
int?An optional seed for the random number generator used when shuffling. If
null
, the shuffle operation will not be seeded.
Returns
- LoraFinetuning
A LoraFinetuning object configured with the training data.
Examples
// Create training object using a predefined dataset
LoraFinetuning finetuning = sarcasmDetector.CreateTrainingObject(
SarcasmDetection.TrainingDataset.OpenAIEvalsSarcasm,
maxSamples: 500,
shuffle: true,
seed: 42);
// Proceed with fine-tuning...
Remarks
This method simplifies the process of creating a training object by directly using one of the predefined datasets.
Exceptions
- ArgumentException
Thrown if the dataset is not recognized.
- InvalidModelException
Thrown if fine-tuning is not supported for the current model configuration.