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

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

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

# EncodeOptions

[common]\
data class [EncodeOptions](index.md)(val addSpecialTokens: [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) = true, val returnTensors: [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) = false, val varlen: [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) = false, val padId: [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)? = null, val device: [Placement](../Placement/index.md)? = null, val maxLength: [Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)? = null, val truncationSide: [TruncationSide](../TruncationSide/index.md) = TruncationSide.RIGHT, val paddingSide: [PaddingSide](../PaddingSide/index.md) = PaddingSide.RIGHT, val padToMultipleOf: [Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)? = null)

The per-call controls of the tensor-shaped encode entry points ([Tokenizer.encodeText](../Tokenizer/encodeText.md), [Tokenizer.encodeBatch](../Tokenizer/encodeBatch.md)).

## Constructors

| | |
|---|---|
| [EncodeOptions](EncodeOptions.md) | [common]<br>constructor(addSpecialTokens: [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) = true, returnTensors: [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) = false, varlen: [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) = false, padId: [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)? = null, device: [Placement](../Placement/index.md)? = null, maxLength: [Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)? = null, truncationSide: [TruncationSide](../TruncationSide/index.md) = TruncationSide.RIGHT, paddingSide: [PaddingSide](../PaddingSide/index.md) = PaddingSide.RIGHT, padToMultipleOf: [Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)? = null) |

## Properties

| Name | Summary |
|---|---|
| [addSpecialTokens](addSpecialTokens.md) | [common]<br>val [addSpecialTokens](addSpecialTokens.md): [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) = true<br>wrap the ids with the model's special tokens (bos, eos, ...). |
| [device](device.md) | [common]<br>val [device](device.md): [Placement](../Placement/index.md)? = null<br>where the tensors land: a [Device](../Device/index.md), or a [Stream](../Stream/index.md) so they land stream-ordered on it; null takes the tokenizer's default placement. |
| [maxLength](maxLength.md) | [common]<br>val [maxLength](maxLength.md): [Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)? = null<br>cap each sequence at this many tokens, trimming the text per [truncationSide](truncationSide.md) before the special tokens attach, so the total stays within the cap; null means no truncation. |
| [paddingSide](paddingSide.md) | [common]<br>val [paddingSide](paddingSide.md): [PaddingSide](../PaddingSide/index.md)<br>which end a padded batch fills; the lengths always carry the real counts. |
| [padId](padId.md) | [common]<br>val [padId](padId.md): [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)? = null<br>the pad id of a padded batch; null takes the tokenizer's own. |
| [padToMultipleOf](padToMultipleOf.md) | [common]<br>val [padToMultipleOf](padToMultipleOf.md): [Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)? = null<br>round the padded row length up to a multiple of this (padded layout only; refused with [varlen](varlen.md)). |
| [returnTensors](returnTensors.md) | [common]<br>val [returnTensors](returnTensors.md): [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) = false<br>build the tensor columns of [Encoded](../Encoded/index.md) beside the id rows. |
| [truncationSide](truncationSide.md) | [common]<br>val [truncationSide](truncationSide.md): [TruncationSide](../TruncationSide/index.md) |
| [varlen](varlen.md) | [common]<br>val [varlen](varlen.md): [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) = false<br>lay `inputIds` out as one flat row with a `cuSeqlens` offset table instead of a padded `[B, S]` matrix; varlen never pads. |