Package-level declarations

Types

Link copied to clipboard
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)

Options of one LlamaEngine.generate call.

Link copied to clipboard
data class GenerationResult(val text: String, val tokens: IntArray, val stopReason: StopReason)

The outcome of LlamaEngine.generateText.

Link copied to clipboard
data class LlamaContextConfig(val contextLength: Int = DEFAULT_CONTEXT_LENGTH, val batchSize: Int = DEFAULT_BATCH_SIZE, val microBatchSize: Int = 0, val embeddingPooling: LlamaPooling = LlamaPooling.MODEL_DEFAULT, val embeddingContextLength: Int = DEFAULT_EMBEDDING_CONTEXT_LENGTH)

KV-cache and batching configuration of a LlamaEngine, fixed at construction time.

Link copied to clipboard

llama.cpp text-generation engine: streaming generation, KV-cache sessions, grammar / JSON-schema constrained decoding and embeddings.

Link copied to clipboard
data class LlamaEngineOptions(val gpuDevice: Int = 0, val allowBackendFallback: Boolean = true, val useMlock: Boolean = false, val projectorPath: String? = null, val imageMinTokens: Int = 0, val imageMaxTokens: Int = 0)

LLM-specific construction options of a LlamaEngine.

Link copied to clipboard

A GBNF grammar constraining generation (llama.cpp llama_sampler_init_grammar).

Link copied to clipboard
sealed class LlamaImage

An image attached to a multimodal prompt (LlamaEngine.generate with images). Images live in memory only: the bytes are handed to libmtmd zero-copy (pinned for the duration of tokenization, never copied by Kotlin, never written to a temporary file) and must not be modified until the generate collection has started evaluating.

Link copied to clipboard
data class LlamaModelInfo(val description: String, val vocabularySize: Int, val trainContextLength: Int, val embeddingSize: Int, val layerCount: Int, val parameterCount: Long, val sizeBytes: Long, val bosToken: Int, val eosToken: Int, val hasEncoder: Boolean)

Static properties of the loaded model.

Link copied to clipboard
data class LlamaNativeInfo(val moduleVersion: String, val llamaCppVersion: String, val llamaCppCommit: String, val systemInfo: String)

Version information of the native llama library.

Link copied to clipboard

Pooling of token embeddings into a sequence embedding (llama_pooling_type).

Functions

Link copied to clipboard
suspend fun LlamaEngine(modelPath: String, backendConfig: BackendConfig = BackendConfig.DEFAULT, contextConfig: LlamaContextConfig = LlamaContextConfig.DEFAULT, options: LlamaEngineOptions = LlamaEngineOptions()): LlamaEngine

Loads a GGUF model with llama.cpp and returns a ready LlamaEngine.