Skip to main content

Module kimi_generate

Module kimi_generate 

Source
Expand description

Ties kimi_tokenizer::KimiTokenizer, kimi_decoder::kimi_forward_token, and sampling::Sampler into a real text-in/text-out generation loop for Kimi K3 – the piece that turns “a decoder that can run one forward pass given weights and a token id” into something a CLI or server can actually use for a prompt. Mirrors the shape of ferrox-server::generate’s loop (encode prompt, decode incrementally, sample each step, stop at max tokens or EOS, decode the output ids) but against kimi_decoder’s separate per-token state/forward-pass API rather than ferrox_core::cache::KvCache.

Functions§

kimi_generate
Encodes prompt, runs it through the decoder to prime KimiDecodeState, then samples up to max_new_tokens further tokens (greedy if sampling.temperature <= 0.0, matching Sampler::sample’s convention), stopping early if eos_id is produced. Returns the newly generated text (not including the prompt) and the raw generated token ids, since a caller may want both (e.g. to report finish_reason/token counts the way ferrox-server does for its GGUF path).