Table of Contents

Constructor TextTranslation

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

TextTranslation(LM)

Initializes a new instance of the TextTranslation class with the specified language model.

public TextTranslation(LM model)

Parameters

model LM

The LM instance representing the language model to be used for translation and detection. This parameter must not be null.

Examples

using LMKit.Model;
using LMKit.Translation;
using LMKit.TextGeneration;
using System;

// Load the language model
LM model = LM.LoadFromModelID("llama-3.2-1b");

// Create the translator
TextTranslation translator = new TextTranslation(model);

Console.WriteLine($"Translator initialized with model: {translator.Model.Name}");

// Ready to translate or detect languages
string translated = translator.Translate("Hello world", Language.Spanish);
Console.WriteLine(translated);

Exceptions

ArgumentNullException

Thrown if model is null.

InvalidModelException

Thrown if the provided model is incompatible with text translation (e.g., if it is an embedding model or was loaded without weights).