Skip to main content
Version: Next

Function: createLLMTranslator()

createLLMTranslator(config, runtime?): Promise<Translator>

Defined in: extensions/llm/tasks/llmTranslation.ts:100

Creates a translator on top of an instruction-tuned LLM such as EuroLLM or Hy-MT2.

Every line is sent as its own single-turn chat with the model card's translation prompt, from an empty KV cache, and decoded greedily. One model translates between any two of its languages, so the pair can change per call.

Parameters​

config​

LLMTranslatorModel

Model, tokenizer and tokenizer config paths. See LLMTranslatorModel.

runtime?​

any

Optional worklet runtime thread on which to run the model execution.

Returns​

Promise<Translator>

A promise resolving to the instantiated LLMTranslator.

Throws​

With code LOAD_FAILED if the model or tokenizer fails to load, or SCHEMA_MISMATCH if the model schema does not match a text LLM.