Skip to content

Kyojin: open-source engine that runs 100 GB-class open models (GLM-5.3, Qwen3.8, DeepSeek V4.1) on one desktop machine. AMD Strix Halo, NVIDIA RTX and Apple Mac. OpenAI API, built on ExLlamaV3.

Medium effort: plain native effort format by default; guidance text opt-in (KYOJIN_EFFORT_GUIDANCE=1 / effort_guidance kwarg)

YanissAmz501501e571fe
diff --git a/tests/test_qwen_prefix_cache.py b/tests/test_qwen_prefix_cache.py
index 89038f7..f923a18 100644
--- a/tests/test_qwen_prefix_cache.py
+++ b/tests/test_qwen_prefix_cache.py
@@ -63,3 +63,12 @@ def test_thinking_off_without_effort_renders_as_before(body):
kw = serve.resolve_template_kwargs(body, DEFAULTS)
assert "reasoning_effort" not in kw
assert render(TEMPLATE, **kw) == render(LEGACY_TEMPLATE, **kw)
+
+
+def test_medium_effort_guidance_is_opt_in(monkeypatch):
+ monkeypatch.delenv("KYOJIN_EFFORT_GUIDANCE", raising=False)
+ plain = render(TEMPLATE, **serve.resolve_template_kwargs({"reasoning_effort": "medium"}, DEFAULTS))
+ assert "Reasoning effort is set to medium." in plain and "Match the depth" not in plain
+ on = render(TEMPLATE, **serve.resolve_template_kwargs(
+ {"reasoning_effort": "medium", "chat_template_kwargs": {"effort_guidance": True}}, DEFAULTS))
+ assert "Reasoning effort is set to medium. Match the depth" in on and "think only about the next step" in on
diff --git a/tools/glm/serve.py b/tools/glm/serve.py
index 41faa4e..7d0db0a 100644
--- a/tools/glm/serve.py
+++ b/tools/glm/serve.py
@@ -401,6 +401,8 @@ def template_kwargs(body: dict[str, Any]) -> dict[str, Any]:
effort = pick("reasoning_effort", SERVE_DEFAULTS["reasoning_effort"])
if effort is not None:
kw["reasoning_effort"] = effort
+ if pick("effort_guidance", os.environ.get("KYOJIN_EFFORT_GUIDANCE") == "1"): # opt-in medium guidance text
+ kw["effort_guidance"] = True
return kw
diff --git a/tools/lanes/README.md b/tools/lanes/README.md
index 2d313a3..349ffec 100644
--- a/tools/lanes/README.md
+++ b/tools/lanes/README.md
@@ -11,4 +11,4 @@ Common: `EXL3_VENV` (ROCm torch venv, default `<root>/.venv`), `EXL3_HSA_LIB` (H
The runtime uncensor hook (`EXL3_ABLIT_RUNTIME`) is off unless a spec is given. Three ways to enable it: (1) the model directory contains `uncensor_spec.json` (uncensored repos: applied automatically, the log prints `-- ablit runtime: spec <path> active (bundled ...)`); (2) set `GLM_ABLIT` / `MIMO_ABLIT` to an edit spec; (3) export `EXL3_ABLIT_RUNTIME=<spec>`. Precedence: explicit path, then bundled file. `EXL3_ABLIT_RUNTIME=off` or `--no-uncensor` switches it off (the launcher prints `hook=` accordingly). Presets are not part of this tree.
-`assets/glm53-template-medium.jinja` is the GLM chat template of the lane. `assets/tune_seed.txt` seeds the dense-GEMM tune cache (`EXL3_DENSE_GEMM_TUNE_FILE`) so the first start skips the autotune.
+`assets/glm53-template-medium.jinja` is the GLM chat template of the lane. Medium effort is the plain level line; the optional guidance text is opt-in (`KYOJIN_EFFORT_GUIDANCE=1` or `chat_template_kwargs.effort_guidance=true`, also for the Qwen template). `assets/tune_seed.txt` seeds the dense-GEMM tune cache (`EXL3_DENSE_GEMM_TUNE_FILE`) so the first start skips the autotune.
diff --git a/tools/lanes/assets/glm53-template-medium.jinja b/tools/lanes/assets/glm53-template-medium.jinja
index dd545c3..f60d782 100644
--- a/tools/lanes/assets/glm53-template-medium.jinja
+++ b/tools/lanes/assets/glm53-template-medium.jinja
@@ -5,7 +5,7 @@
{%- set effort_head = (effort_placement is defined and effort_placement == 'head') -%}
{%- if effort_head -%}
{%- if effective_reasoning_effort is not none -%}<|system|>Reasoning Effort: {{ effective_reasoning_effort | capitalize }}{%- endif -%}
-{%- if glm_medium -%}<|system|>Match the depth of your work to the difficulty of the task: spend it on the points that decide the answer, not on alternatives the task does not call for. Plan in your reasoning, but do not draft the answer there: write code and long text once, in the answer. When you have settled a point, keep it and move on.{%- endif -%}
+{%- if glm_medium and effort_guidance is defined and effort_guidance -%}<|system|>Match the depth of your work to the difficulty of the task: spend it on the points that decide the answer, not on alternatives the task does not call for. Between tool calls, think only about the next step. Check facts with the tools rather than in your head. Plan in your reasoning, but do not draft the answer there: write code and long text once, in the answer. When you have settled a point, keep it and move on.{%- endif -%}
{%- endif -%}
{%- set clear_thinking = clear_thinking if clear_thinking is defined else false -%}
{%- if tools -%}
@@ -265,7 +265,7 @@ For each function call, output the function name and arguments within the follow
{%- if add_generation_prompt -%}
{%- if not effort_head -%}
{%- if effective_reasoning_effort is not none -%}<|system|>Reasoning Effort: {{ effective_reasoning_effort | capitalize }}{%- endif -%}
-{%- if glm_medium -%}<|system|>Match the depth of your work to the difficulty of the task: spend it on the points that decide the answer, not on alternatives the task does not call for. Plan in your reasoning, but do not draft the answer there: write code and long text once, in the answer. When you have settled a point, keep it and move on.{%- endif -%}
+{%- if glm_medium and effort_guidance is defined and effort_guidance -%}<|system|>Match the depth of your work to the difficulty of the task: spend it on the points that decide the answer, not on alternatives the task does not call for. Between tool calls, think only about the next step. Check facts with the tools rather than in your head. Plan in your reasoning, but do not draft the answer there: write code and long text once, in the answer. When you have settled a point, keep it and move on.{%- endif -%}
{%- endif -%}
<|assistant|>{{- '<think>' -}}
{%- endif -%}
diff --git a/tools/qwen/chat_template.jinja b/tools/qwen/chat_template.jinja
index 40a58cb..2140bfd 100644
--- a/tools/qwen/chat_template.jinja
+++ b/tools/qwen/chat_template.jinja
@@ -51,7 +51,7 @@
{%- if resolved_reasoning_effort == 'xhigh' %}
{%- set reasoning_instructions = 'Reasoning effort is set to xhigh. Please think carefully through the task, validate key assumptions, consider plausible alternatives, and prioritize correctness, consistency, and clarity in the final answer.' %}
{%- elif resolved_reasoning_effort == 'medium' %}
- {%- set reasoning_instructions = 'Reasoning effort is set to medium. Match the depth of your work to the difficulty of the task: spend it on the points that decide the answer, not on alternatives the task does not call for. Plan in your reasoning, but do not draft the answer there: write code and long text once, in the answer. When you have settled a point, keep it and move on.' %}
+ {%- set reasoning_instructions = 'Reasoning effort is set to medium.' ~ (' Match the depth of your work to the difficulty of the task: spend it on the points that decide the answer, not on alternatives the task does not call for. Between tool calls, think only about the next step. Check facts with the tools rather than in your head. Plan in your reasoning, but do not draft the answer there: write code and long text once, in the answer. When you have settled a point, keep it and move on.' if (effort_guidance is defined and effort_guidance) else '') %}
{%- elif resolved_reasoning_effort == 'low' %}
{%- set reasoning_instructions = 'Reasoning effort is set to low. Keep your thinking brief and focused, moving directly to the conclusion without unnecessary elaboration.' %}
{%- endif %}
diff --git a/tools/qwen/serve.py b/tools/qwen/serve.py
index 56ff3d4..928db79 100644
--- a/tools/qwen/serve.py
+++ b/tools/qwen/serve.py
@@ -293,6 +293,8 @@ def resolve_template_kwargs(body: dict[str, Any], defaults: dict[str, Any]) -> d
ctk = body.get("chat_template_kwargs") or {}
if not isinstance(ctk, dict):
raise BadRequest("chat_template_kwargs must be an object")
+ if ctk.get("effort_guidance") or (ctk.get("effort_guidance") is None and os.environ.get("KYOJIN_EFFORT_GUIDANCE") == "1"):
+ kw["effort_guidance"] = True # opt-in medium guidance text (off by default)
for key in ("enable_thinking", "reasoning_effort"):
for src in (ctk, body, defaults):
if src.get(key) is not None: