How to disable thinking?

#9
by Hansi2024 - opened

Hi there,
I'm struggeling to disable thinking. I'm using Q4_X and tried different settings.
At the end of the start process there is "srv init: init: chat template, thinking = 0"
But it is still thinking, and it is thinking much.

Latest start batch :

export CUDA_VISIBLE_DEVICES=0
/home/user/LLMDATA/llama/ik_llama.cpp/build/bin/llama-server
--alias kimi-k26-q4-vis-nt
--model /home/user/LLMMODELS/llm_gguf/Kimi-K2.6-Q4_X-00001-of-00014.gguf
--mmproj /home/user/LLMMODELS/llm_gguf/mmproj-Kimi-K2.6-F16.gguf
-muge
--merge-qkv
--ctx-size 131072
-ctk f16
-mla 3
-amb 512
--fit
--parallel 1
-ub 4096 -b 4096
--threads 16
--threads-batch 16
--no-mmap
--jinja
--chat-template-file /home/user/LLMMODELS/llm_gguf/Kimi-k26nt.jinja
--chat-template-kwargs '{"enable_thinking":false}'
--reasoning-budget 0
--host 0.0.0.0
--port 8888
--no-mmap

results in:

...
djust batch size for mtmd: u_batch = 4096, batch = 4096
llama_init_from_model: n_ctx = 131072
llama_init_from_model: n_batch = 4096
llama_init_from_model: n_ubatch = 4096
llama_init_from_model: flash_attn = 1
llama_init_from_model: mla_attn = 3
llama_init_from_model: attn_max_b = 512
llama_init_from_model: fused_moe = 1
llama_init_from_model: grouped er = 0
llama_init_from_model: fused_up_gate = 1
llama_init_from_model: fused_mmad = 1
llama_init_from_model: rope_cache = 0
llama_init_from_model: graph_reuse = 1
llama_init_from_model: k_cache_hadam = 0
llama_init_from_model: v_cache_hadam = 0
llama_init_from_model: split_mode_graph_scheduling = 0
llama_init_from_model: reduce_type = f16
llama_init_from_model: sched_async = 0
llama_init_from_model: ser = -1, 0
llama_init_from_model: freq_base = 50000.0
llama_init_from_model: freq_scale = 0.015625
llama_kv_cache_init: CUDA0 KV buffer size = 8784.00 MiB
llama_init_from_model: KV self size = 8784.00 MiB, c^KV (f16): 8784.00 MiB, kv^T: not used
llama_init_from_model: CUDA_Host output buffer size = 0.62 MiB
llama_repack_up_gate_exps: repacking up/gate experts weight in layer 1
...
llama_repack_up_gate_exps: repacking up/gate experts weight in layer 60
llama_init_from_model: CUDA0 compute buffer size = 7570.02 MiB
llama_init_from_model: CUDA_Host compute buffer size = 1136.05 MiB
llama_init_from_model: graph nodes = 13408
llama_init_from_model: graph splits = 122
llama_init_from_model: enabling only_active_experts scheduling
clip_model_loader: model name: Kimi K2.6
clip_model_loader: description:
clip_model_loader: GGUF version: 3
clip_model_loader: alignment: 32
clip_model_loader: n_tensors: 335
clip_model_loader: n_kv: 28

clip_model_loader: has vision encoder
clip_ctx: have 2 back-ends:
0: CPU
1: CUDA0
ggml_backend_cuda_context: a context for device 0 already exists?
clip_ctx: CLIP using CUDA0 backend
load_hparams: projector: kimik25
load_hparams: n_embd: 1152
load_hparams: n_head: 16
load_hparams: n_ff: 4304
load_hparams: n_layer: 27
load_hparams: ffn_op: gelu
load_hparams: projection_dim: 7168

--- vision hparams ---
load_hparams: image_size: 896
load_hparams: patch_size: 14
load_hparams: has_llava_proj: 0
load_hparams: minicpmv_version: 0
load_hparams: n_merge: 2
load_hparams: n_wa_pattern: 0
load_hparams: image_min_pixels: 1568
load_hparams: image_max_pixels: 3211264

load_hparams: model size: 908.42 MiB
load_hparams: metadata size: 0.12 MiB
warmup: warmup with image size = 448 x 448
alloc_compute_meta: CUDA0 compute buffer size = 102.30 MiB
alloc_compute_meta: CPU compute buffer size = 2.30 MiB
alloc_compute_meta: graph splits = 1, nodes = 1088
warmup: flash attention is disabled
INFO [ load_model] loaded multimodal model, '%s'
| ="/home/user/LLMMODELS/llm_gguf/mmproj-Kimi-K2.6-F16.gguf"
INFO [ init] initializing slots | tid="140621012520960" timestamp=1776921886 n_slots=1
INFO [ init] new slot | tid="140621012520960" timestamp=1776921886 id_slot=0 n_ctx_slot=131072
srv init: Exclude reasoning tokens when selecting slot based on similarity: start: , end:
use --reasoning-tokens none to disable.
no implementations specified for speculative decoding
slot init: id 0 | task -1 | speculative decoding context not initialized
prompt cache is enabled, size limit: 8192 MiB
use --cache-ram 0 to disable the prompt cache
init: chat template, example_format: '<|im_system|>system<|im_middle|>You are a helpful assistant<|im_end|><|im_user|>user<|im_middle|>Hello<|im_end|><|im_assistant|>assistant<|im_middle|>Hi there<|im_end|><|im_user|>user<|im_middle|>How are you?<|im_end|><|im_assistant|>assistant<|im_middle|>'
INFO [ main] model loaded | tid="140621012520960" timestamp=1776921886
srv init: init: chat template, thinking = 0
INFO [ main] HTTP server listening | tid="140621012520960" timestamp=1776921886 n_threads_http="31" port="8888" hostname="0.0.0.0"
INFO [ slots_idle] all slots are idle | tid="140621012520960" timestamp=1776921886

Yeah for Kimi it's different from GLM:

--chat-template-kwargs '{"thinking": false}'

is it good or bad to disable thinking? i think thinking is good right? in my experience it always produces better results.

@mtcl

you can decide at runtime on the client as well.. instead of passing it to llama-server --chat-template-kwargs ... to turn it off always on the server, you can pass extra paramters in the API body e.g.:

here are a few possibilities:

to prevent thinking there are a few ways sure:

  1. on startup with llama-server --chat-template-kwargs '{"thinking": false}' as mentioned by @gghfez
  2. if you're using --jinja and a chat template (like i have on the modelcard linked to a discussion now) you can do it dynamically per API request, read some here: https://github.com/ggml-org/llama.cpp/issues/20182#issuecomment-4230494838
  3. there may be other ways with "reasoning" stuff to coax it into more or less, not sure if that works on this model
  4. if you're using ST and text endpoint you can pre-fill a think block on behalf of the assistant sayin "okay that's good let's answer" or whatever

Thank you all,
working now. with the wrong kwargs it could not work. Next I'll check the API and hints for ST.
@mtcl : of course the quality is better with active reasoning, but if the "quality" is not needed it speeds up the response massively as I only get 9t/s from my setup and Kimi is thinking very long.

Sign up or log in to comment