GenerationOptions

data class GenerationOptions(val maxTokens: Int = 256, val temperature: Float = 0.8f, val topK: Int = 40, val topP: Float = 0.95f, val minP: Float = 0.05f, val repeatPenalty: Float = 1.0f, val repeatLastN: Int = 64, val seed: Long? = null, val grammar: LlamaGrammar? = null, val stopSequences: List<String> = emptyList(), val addSpecialTokens: Boolean = true, val parseSpecialTokens: Boolean = true, val renderSpecialTokens: Boolean = false, val reusePromptCache: Boolean = true)(source)

Options of one LlamaEngine.generate call.

Sampling runs [grammar] -> [repetition penalty] -> top-k -> top-p -> min-p -> temperature -> distribution, or greedy argmax when temperature is <= 0.

Constructors

Link copied to clipboard
constructor(maxTokens: Int = 256, temperature: Float = 0.8f, topK: Int = 40, topP: Float = 0.95f, minP: Float = 0.05f, repeatPenalty: Float = 1.0f, repeatLastN: Int = 64, seed: Long? = null, grammar: LlamaGrammar? = null, stopSequences: List<String> = emptyList(), addSpecialTokens: Boolean = true, parseSpecialTokens: Boolean = true, renderSpecialTokens: Boolean = false, reusePromptCache: Boolean = true)

Types

Link copied to clipboard
object Companion

Constants and factory functions of GenerationOptions.

Properties

Link copied to clipboard

add BOS/EOS to the prompt as the model's tokenizer requires.

Link copied to clipboard

constrains every sampled token (GBNF or JSON schema), null for unconstrained text.

Link copied to clipboard

true when temperature selects greedy decoding.

Link copied to clipboard

maximum number of generated tokens, or UNLIMITED (until end of generation or a full context).

Link copied to clipboard
val minP: Float

minimum probability relative to the most likely token, <= 0 disables.

Link copied to clipboard

parse control tokens written as text in the prompt (e.g. chat-template markers).

Link copied to clipboard
Link copied to clipboard

how many recent tokens the repetition penalty considers.

Link copied to clipboard

repetition penalty, 1 disables.

Link copied to clipboard

reuse the KV cache of the longest common token prefix between this prompt and the tokens already in the engine's session (previous prompts, generations, or a restored session), so only the new suffix is evaluated. false clears the session first.

Link copied to clipboard
val seed: Long?

RNG seed of the final distribution sampler (0..4294967294), null for a random seed.

Link copied to clipboard

generation stops with StopReason.STOP_SEQUENCE once the generated text contains one of these. The token that completed the stop sequence is still emitted.

Link copied to clipboard

sampling temperature; <= 0 selects greedy (deterministic) decoding.

Link copied to clipboard
val topK: Int

keep the k most likely tokens, <= 0 disables.

Link copied to clipboard
val topP: Float

nucleus sampling threshold, >= 1 disables.