Skip to main content

//clika-runtime/io.clika.modelverse/TranslateModel

TranslateModel

[common]
class TranslateModel : PreTrainedModel

A translation model loaded from its files on disk, on the CPU: an encoder-decoder model that translates between the languages it names (Capabilities.languages). A chat model that translates by instruction is a GenerativeModel, not this.

Open it with open from a snapshot directory. Hand it texts with translate; the translations arrive through the listener on the model's own worker thread, one request at a time per model. close frees the weights.

Types​

NameSummary
Companion[common]
object Companion

Properties​

NameSummary
capabilities[common]
val capabilities: Capabilities
What the model takes and gives, read when it opened: Capabilities.languages are its codes.
config[common]
open override val config: PretrainedConfig
The checkpoint's identity, read when the model opened.

Functions​

NameSummary
close[common]
open fun close()
residency[common]
open override fun residency(): ResidencyReport
Free the model. A running request is canceled first and the call waits for it to return; called from inside a listener callback, the free runs right after that callback's request ends instead. Idempotent.
translate[common]
fun translate(texts: List<String>, sourceLanguage: String?, targetLanguage: String, options: TranslateOptions, listener: TranslateListener): TranslateHandle
Translate texts from sourceLanguage (null keeps the model's default source) into targetLanguage, both codes from Capabilities.languages, under options. Returns at once; the worker runs the batch and calls listener on its thread: TranslateListener.onTranslations with one translation per text in order, then TranslateListener.onDone. An empty list or a code the model does not name ends in TranslateListener.onError.