Table of Contents

Method AddSample

Namespace
LMKit.Translation.Training
Assembly
LM-Kit.NET.dll

AddSample(string, Language)

Adds a training sample from raw text, using BestModality.

public void AddSample(string content, Language language)

Parameters

content string

The textual content whose language is labeled.

language Language

The expected language label for this sample.

Examples

dataset.AddSample("今日はいい天気ですね。", TextGeneration.Language.Japanese);

Remarks

Wraps the text into an Attachment and forwards to AddSample(Attachment, Language, InferenceModality).

AddSample(Attachment, Language, InferenceModality)

Adds a training sample with an explicit InferenceModality.

public void AddSample(Attachment content, Language language, InferenceModality modality)

Parameters

content Attachment

The input attachment (text, image, or multimodal) to label.

language Language

The expected language label for this sample.

modality InferenceModality

The preferred inference modality for prompt generation (e.g., Text, Vision, Multimodal, or BestModality).

Examples

var img = /* image attachment with embedded text */;
dataset.AddSample(img, TextGeneration.Language.English, InferenceModality.Multimodal);

Remarks

This method calls CreateLanguageDetectionTrainingSample(Prompt, Language, InferenceModality, out InferenceModality) to synthesize a chat-based training example and resolves the effective inferenceModality. The result is wrapped in ChatTrainingSample and added to the dataset.

If EnableModalityAugmentation is true and modality is Multimodal or BestModality, a complementary modality sample may be added automatically, subject to content capabilities:

  • Resolved inferenceModality == Text and content.SupportsRasterization ⇒ add a Vision sample.
  • Resolved inferenceModality == Vision, content.HasText, and ParsingUtils.HasMinimumLetters(content.GetText(), ModalityUtils.MinTextLettersForTextModality) ⇒ add a Text sample.