public class LocalLLMProvider implements LLMProvider, AutoClosable
Local token-level Qwen3.5 text inference on CPU or NVIDIA GPU. Parameters stay packed on the selected device. Activations, KV caches and gated delta states accumulate in FP32. No Python, CUDA Toolkit or external model runtime is invoked. Implements LLMProvider for LLMChatSession; the session owns conversation history, while this provider owns model resources. Close the provider explicitly to release parameter storage.
Supports original F32/F16/BF16 Safetensors, local Klyn Q8 checkpoints and GGUF F32/F16/BF16/Q8_0/Q4_K/Q5_K/Q6_K tensors, including mixed K-quantization variants. Text chat uses the embedded Qwen35 tokenizer and pinned text/tool template. Native typed tool_calls are returned to the caller; this provider never executes tools. Generation is deterministic greedy decoding with sequential prefill, not continuous batching or sampling. Optional exact system/schema-prefix checkpoints avoid repeating that prefill; every request receives independent sequence storage. Unsupported variants are rejected. Concurrent use is unsupported.
try provider = LocalLLMProvider.load("bartowski/Qwen_Qwen3.5-9B-GGUF"): session = LLMChatSession(provider).withSystem("You are a helpful assistant.") print(session.ask("Hello"))
| Modifier and Type | Member | Description |
|---|---|---|
| public | contextCacheMinTokenscontextCacheMinTokens as Long = 128l |
Minimum input tokens beyond the static frame before retaining a cache. |
| public | contextCacheScopecontextCacheScope as String = "" |
Optional client/conversation identity for one additional message cache. |
| public | maxNewTokensmaxNewTokens as Long = 128l |
Maximum generated tokens per complete() request, including a terminating EOS token. |
| public | prefixCachingprefixCaching as Boolean = false |
Opt-in reuse of the exact initial system/tool-schema frame only. |
| Modifier and Type | Member | Description |
|---|---|---|
| public readonly property | cachedContextTokenscachedContextTokens as Long |
Retained complete message-frame tokens in the current scope. |
| public readonly property | cachedPrefixTokenscachedPrefixTokens as Long |
Number of resident initial-frame tokens, not a generation speed estimate. |
| public readonly property | devicedevice as Device |
Concrete device, fixed for this provider's lifetime. |
| public readonly property | maxContextmaxContext as Long |
Maximum prompt plus generated sequence length. |
| public readonly property | parameterBytesparameterBytes as ULong |
Packed device parameter bytes, counting shared embeddings only once and excluding caches/activation buffers. |
| public readonly property | vocabularySizevocabularySize as Long |
Vocabulary size, including reserved IDs. |
| Modifier and Type | Member | Description |
|---|---|---|
| public | LocalLLMProviderLocalLLMProvider(path as Path, device as Device = Device.auto, maxContext as Long = 2048l, verbose as Boolean = false) |
Loads a local indexed Q8 model, validating its supported text architecture. |
| Modifier and Type | Member | Description |
|---|---|---|
| public static | availableQuantizationsavailableQuantizations(repository as String, revision as String = "main") as ArrayList<ModelQuantization> |
Lists published GGUF variants without downloading weights. |
| public | chat | Generates a textual assistant response from a text-only Qwen conversation. |
| public | clearContextCacheclearContextCache() as Void |
Erases the conversation checkpoint while retaining model/system state. |
| public | clearPrefixCacheclearPrefixCache() as Void |
Releases the optional sequence checkpoint without unloading weights. |
| public override | closeclose() as Void |
Releases all packed parameter allocations, idempotently. |
| public override | completecomplete(request as LLMRequest) as LLMResponse throws Exception |
Completes a typed text conversation using resident model weights. |
| public | completeStreamingcompleteStreaming(request as LLMRequest, observer as LocalGenerationObserver) as LLMResponse throws Exception |
Generates incrementally on the calling thread, with cooperative stopping. |
| public | generateTokens | Generates new token IDs by finite-logit argmax, without decoding text. |
| public static | loadload(repository as String, quantization as ModelQuantization = ModelQuantization.AUTO, device as Device = Device.auto, maxContext as Long = 2048l, revision as String = "main", offline as Boolean = false, verbose as Boolean = false, token as String = "", format as ModelFormat = ModelFormat.AUTO) as LocalLLMProvider |
Downloads the requested Hub variant if necessary, verifies it and loads it on the selected CPU/GPU. |
| public | primePrefixprimePrefix(request as LLMRequest, observer as LocalGenerationObserver) as Long |
Precomputes the initial system/schema frame without generating text. |
| public | promptTokenCountpromptTokenCount(request as LLMRequest) as Long |
Counts the exact rendered prompt, including template markers, without allocating inference states. |
| public static | supportedQuantizationssupportedQuantizations(repository as String, device as Device, revision as String = "main") as ArrayList<ModelQuantization> |
Lists published weight formats executable by this provider on the selected device. |