Method AddSample
- Namespace
- LMKit.TextAnalysis.Training
- Assembly
- LM-Kit.NET.dll
AddSample(string, IList<string>, IList<string>, int)
Adds a training sample from raw text using the engine’s preferred modality.
public void AddSample(string content, IList<string> categories, IList<string> categoryDescriptions, int resultIndex)
Parameters
content
stringThe textual content to classify.
categories
IList<string>The list of category labels. The item at
resultIndex
is treated as the correct label for this sample.categoryDescriptions
IList<string>Optional human-readable descriptions aligned 1:1 with
categories
.resultIndex
intThe zero-based index into
categories
indicating the expected class.
Examples
dataset.AddSample(
"The battery lasts two days on a single charge.",
new[] { "Positive", "Neutral", "Negative" },
new[] { "Favorable tone", "Objective tone", "Unfavorable tone" },
resultIndex: 0);
Remarks
The content
is wrapped as a text Attachment and
forwarded to
AddSample(InferenceModality, Attachment, IList<string>, IList<string>, int).
AddSample(Attachment, IList<string>, IList<string>, int)
Adds a training sample from an Attachment using the engine’s preferred modality.
public void AddSample(Attachment content, IList<string> categories, IList<string> categoryDescriptions, int resultIndex)
Parameters
content
AttachmentThe input attachment (e.g., text, image, or multimodal source) to classify.
categories
IList<string>The list of category labels. The item at
resultIndex
is treated as the correct label for this sample.categoryDescriptions
IList<string>Optional human-readable descriptions aligned 1:1 with
categories
.resultIndex
intThe zero-based index into
categories
indicating the expected class.
Remarks
For text inputs, prefer CreateFromText(string, string). This overload delegates to the modality-explicit overload.
AddSample(InferenceModality, Attachment, IList<string>, IList<string>, int)
Adds a training sample with an explicit InferenceModality.
public void AddSample(InferenceModality modality, Attachment content, IList<string> categories, IList<string> categoryDescriptions, int resultIndex)
Parameters
modality
InferenceModalityThe inference modality to use for prompt generation.
content
AttachmentThe content attachment to classify.
categories
IList<string>The list of category labels. The item at
resultIndex
is the expected label for this sample.categoryDescriptions
IList<string>Optional human-readable descriptions aligned 1:1 with
categories
.resultIndex
intThe zero-based index of the correct label within
categories
.
Examples
var attachment = Attachment.CreateFromText(reviewText, "text");
var labels = new[] { "Positive", "Neutral", "Negative" };
var desc = new[] { "Favorable tone", "Objective tone", "Unfavorable tone" };
dataset.AddSample(
InferenceModality.Text,
attachment,
labels,
desc,
resultIndex: 2);
Remarks
This method calls Categorization.CreateSamplingClassificationTrainingSample
to synthesize a chat-based training example using
Classification.CategorizationEngine.NormalizationLevel.All
. The resulting
sample is wrapped in ChatTrainingSample with the resolved
inferenceModality
.
If EnableModalityAugmentation is true and the resolved
inferenceModality
is Multimodal, two additional
samples are automatically added using Text and
Vision.
The lengths of categories
and categoryDescriptions
should match (when descriptions are provided), and resultIndex
must be
a valid index into categories
.