---
title: "TranslateModel"
sidebar_label: "TranslateModel"
description: "Kotlin binding reference: TranslateModel."
---

<!-- Generated by tools/api_reference/generate_api_docs.py. Do not edit. -->

//[clika-runtime](../../../index.md)/[io.clika.modelverse](../index.md)/[TranslateModel](index.md)

# TranslateModel

[common]\
class [TranslateModel](index.md) : [PreTrainedModel](../PreTrainedModel/index.md)

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](../Capabilities/languages.md)). A chat model that translates by instruction is a [GenerativeModel](../GenerativeModel/index.md), not this.

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

## Types

| Name | Summary |
|---|---|
| [Companion](Companion/index.md) | [common]<br>object [Companion](Companion/index.md) |

## Properties

| Name | Summary |
|---|---|
| [capabilities](capabilities.md) | [common]<br>val [capabilities](capabilities.md): [Capabilities](../Capabilities/index.md)<br>What the model takes and gives, read when it opened: [Capabilities.languages](../Capabilities/languages.md) are its codes. |
| [config](config.md) | [common]<br>open override val [config](config.md): [PretrainedConfig](../PretrainedConfig/index.md)<br>The checkpoint's identity, read when the model opened. |

## Functions

| Name | Summary |
|---|---|
| [close](close.md) | [common]<br>open fun [close](close.md)() |
| [residency](residency.md) | [common]<br>open override fun [residency](residency.md)(): [ResidencyReport](../ResidencyReport/index.md)<br>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](translate.md) | [common]<br>fun [translate](translate.md)(texts: [List](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html)&lt;[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)&gt;, sourceLanguage: [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)?, targetLanguage: [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html), options: [TranslateOptions](../TranslateOptions/index.md), listener: [TranslateListener](../TranslateListener/index.md)): [TranslateHandle](../TranslateHandle/index.md)<br>Translate [texts](translate.md) from [sourceLanguage](translate.md) (null keeps the model's default source) into [targetLanguage](translate.md), both codes from [Capabilities.languages](../Capabilities/languages.md), under [options](translate.md). Returns at once; the worker runs the batch and calls [listener](translate.md) on its thread: [TranslateListener.onTranslations](../TranslateListener/onTranslations.md) with one translation per text in order, then [TranslateListener.onDone](../TranslateListener/onDone.md). An empty list or a code the model does not name ends in [TranslateListener.onError](../TranslateListener/onError.md). |