Qwen Sharper Chat Templates — generic line (v22.5.3-sharper)

Sharper is Sharp hardened: always-on tool isolation + verification tail, bounded tool args, terse system block, and thinking-sharp steering. This repo serves the generic line — chat_template.jinja here is v22.5.3-sharper, built on froggeric stock v22.5 for any Qwen3.5/3.8 on stock-compatible templates.

A sibling repo serves the Twin-Turbo-specific line: moeshawky/Qwen-Sharper-TwinTurbo-Chat-Templates (keeps that model's DAU modes verbatim). Pick by your model, never mix — the files are not interchangeable.

Note: This README measures what the template actually does, not what it aspires to. Every claim cites running code, executed tests, or captured output. See Verification to reproduce.

What it changes vs froggeric stock v22.5

Source: chat_template.jinja (30948 B, template_version = "qwen3.8-froggeric-v22.5.3-sharper") = v22.5.2-sharper + one assert-anchored hunk (A-4, build/patch_v22_5_3.py). Upstream stock re-checked 2026-09-17, still v22.5 — no rebase. Inherited from v22.5.2: always-on hardening (Isolation + Verify tail, survives terse=false), bounded tool args (max_tool_arg_chars=2000, max_tool_response_chars=8000, JSON-payload exempt), tightened terse leads + narration ban, thinking-sharp steering (xhigh five-pass gate-lines, medium 3-step priming), single-line tool layouts. Deliberate tradeoff: the LM-Studio [TOOL_REQUEST] suppress standoff is dropped in favor of always-on hardening.

Generic contract (preserved, probed): default effort medium; high-family→xhigh, minimal→low; unknown efforts fall back to medium silently (no strict raise — stock behavior kept). Steering gates on the single pre-scan state, so in-band <|think_*> tokens and kwargs can never disagree.

Measured performance

Render-verified only — no serving numbers exist for this variant. probe_v22_5_3 ALL PASS (contract spots × full/oneline, A-4 warn/precision, parity matrix) + Jinja compile-check invariant in the builder. Do NOT cite Twin-Turbo live results for this file.

Sibling evidence (Twin-Turbo line, same edit family, different base — directional only, not citable here): completion 193 vs 259 (−25%, leaner 15/20, capture-joined 20/20); prompt overhead ~309 vs 76 prompt tok (prefix-amortized); task-success parity 5/5 sampled pairs. Serve this file on your own target first; its numbers will be its own.

Inherited from Sharp (verified 2026-08-24, plates in plates/): Claweval answer +7.4 / overall +3.8 / answer tokens -59% (v22.4.0, medium); SWE-bench-Live 15/25 vs 16/25 stock at 2.7× faster median. Hardening is correctness, not speed.

  • Token cost of Sharper hardening+priming: narration ban ~10 tokens, Isolation + Verify ~12 tokens, medium 3-step priming ~45 tokens, xhigh 5-phase vocabulary ~65 tokens. Prefix-cache amortizes steady-state per-turn cost toward ~0 after warmup.
  • Override: truncation is per-call defeasible — pass {"max_tool_arg_chars": 0, "max_tool_response_chars": 0} via chat_template_kwargs to disable; JSON-payload responses ({/[-leading) are never truncated even when limits are on.
  • Budget discipline (measured on the sibling live server): deliberation spends from the same max_tokens budget as the answer — size budgets to effort and hardness, or send reasoning_effort: "low"/"medium" for capped clients.

Installation — drop-in

HF transformers / MLX / oMLX (reference dialect, ≥4.51 prefers chat_template.jinja file):

hf download moeshawky/Qwen-Sharper-Chat-Templates chat_template.jinja --local-dir /path/to/your-model
# OR for tokenizer_config.json: paste chat_template_oneline.txt as `chat_template` value
# Verify (see below):
python scripts/check_applied.py /path/to/your-model
# Expected: [chat_template.jinja] terseness yes, isolation yes, verify yes — both sources render SAME

GGUF (rewrite without requantize):

pip install gguf
gguf-new-metadata --chat-template-file chat_template.jinja input.gguf output.gguf
# Verify:
python scripts/check_applied.py output.gguf

llama.cpp / vLLM / SGLang at runtime (no file touch):

llama-server -m model.gguf --chat-template-file chat_template.jinja --jinja --reasoning-format deepseek -ngl 99
vllm serve /path/to/model --chat-template chat_template.jinja --trust-request-chat-template --default-chat-template-kwargs '{"terse": true}'

Verification

Last Verified: 2026-09-17 (probe_v22_5_3.py ALL PASS, full + oneline).

# 1. Delta + contract + parity probes:
python scripts/probe_v22_5_3.py
# Expected: ALL PROBES PASSED (generic contract spots, A-4 warn/precision, parity matrix)

# 2. Quick smoke (needs raise_exception global like engines provide):
python -c "
from jinja2 import Environment
import pathlib
src=pathlib.Path('chat_template.jinja').read_text()
env=Environment(); env.globals['raise_exception']=lambda m: (_ for _ in ()).throw(RuntimeError(m))
R=lambda m,kw={}: env.from_string(src).render(messages=m, add_generation_prompt=True, **kw)
p1=[{'role':'user','content':'hi'}]
assert 'Never: open with preamble' in R(p1), 'marker missing'
assert 'Isolation:' in R(p1, {'terse':False}), 'hardening must survive terse=false'
assert 'Reasoning effort is set to medium' in R(p1), 'generic default is medium'
assert 'set to xhigh' in R(p1, {'reasoning_effort':'high'}), 'high->xhigh must hold'
assert 'set to medium' in R(p1, {'reasoning_effort':'banana'}), 'unknown falls back silently'
print('probe PASS')
"
# Expected: probe PASS

# 3. Minifier round-trip is covered inside probe_v22_5_3.py (parity matrix).

If any check fails → reject deploy. Serve per target model only after this gate passes on that target's stack.

Cache impact (structural class): System-slot wording change → 100% prefix invalidation on rollout. Canary one instance before full rollout.

File map

moeshawky/Qwen-Sharper-Chat-Templates/
├── chat_template.jinja              # 30948 B, v22.5.3-sharper (generic line)
├── chat_template_oneline.txt        # 24138 B, minified generic v22.5.3
├── README.md                        # this file
├── plates/                          # measured plates (SWE, Claweval) from Sharp — retained
├── build/                           # reproducible builders (nothing lives only in /tmp)
│   ├── patch_v22_5_3.py             # builds v22.5.3 from the frozen v22.5.2 donor (assert-anchored)
│   ├── donor-v22.5.2-sharper.jinja  # donor input (sha256 dcbbb3b6…)
│   └── verify-v22.5.2.py            # donor-era verifier (provenance)
└── scripts/
    ├── check_applied.py             # reports effective_instance per dialect
    ├── minify_jinja.py              # preserves {% set %} newlines
    ├── fuzz_template.py             # 9-invariant fuzzer (500 cases)
    └── probe_v22_5_3.py             # generic v22.5.3 probes (ALL PASS 2026-09-17)

Push contents: the two chat_template* files + this README + scripts/ + build/ as above.

Changelog

  • v22.5.3-sharper (2026-09-17, BUILT + PROBED — unserved): v22.5.2 + A-4 detector full-scan only (strong-error signals scan the full truncation-bounded tool output; weak signals stay head-scoped). Not ported: in-band effort aliases (no such parser on stock), thinking-control reconciliation (stock steering already gates on the single pre-scan state). Generic contract preserved: default medium, silent-medium fallback. Upstream stock still v22.5, no rebase. Serve per target model only after its own re-verify.
  • v22.5.2-sharper (2026-09-15, SUPERSEDED): Thinking-sharp steering on froggeric stock (xhigh five-pass gate-lines, medium 3-step priming), always-on hardening, bounded tool args, terse tightening. Verified verify 75 PASS + fuzz 500 + parity.
  • v22.5.1-sharper (2026-09-15, pushed): Thinking-sharp steering first release (medium 3-step priming, xhigh gate-lines, narration ban). Verified verify 74 PASS + fuzz 500 + oneline parity.
  • v22.4.2-sharper (2026-08-27): Hardening always-on, bounded tool args (2000/8000), isolation as UNTRUSTED DATA, type-validating verify tail.
  • v22.4.1-sharper (2026-08-25): Fork from Sharp v22.4.0. Isolation + verification tail, thinking anchor, token tightening.

Citation

@misc{Qwen-Sharper-Chat-Template,
  title  = {Qwen Sharper Chat Templates — hardened froggeric line},
  author = {Moe Shawky (Sharper) + Saga Ishtardottir (Sharp) + Frédéric Guigand (froggeric)},
  year   = {2026},
  url    = {https://huggingface.co/moeshawky/Qwen-Sharper-Chat-Templates},
  note   = {v22.5.3-sharper generic, render-verified 2026-09-17}
}

License: Apache-2.0, matching upstream. No weights — prompt change only, not a fine-tune.

Update trigger: Re-verify on any chat_template.jinja edit, froggeric stock change, or engine upgrade. No serving numbers may be cited for this file until measured on a live deployment.

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for moeshawky/Qwen-Sharper-Chat-Templates

Finetuned
(12)
this model