Spaces:
Running
Running
reasoning-parser advisor
Browse files- README.md +43 -5
- app.js +107 -0
- assert-logo.png +0 -0
- index.html +201 -17
- parser_advice.js +106 -0
README.md
CHANGED
|
@@ -1,10 +1,48 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: static
|
|
|
|
| 7 |
pinned: false
|
|
|
|
|
|
|
| 8 |
---
|
| 9 |
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
title: Does this model need a reasoning parser?
|
| 3 |
+
emoji: 🧩
|
| 4 |
+
colorFrom: indigo
|
| 5 |
+
colorTo: gray
|
| 6 |
sdk: static
|
| 7 |
+
app_file: index.html
|
| 8 |
pinned: false
|
| 9 |
+
license: apache-2.0
|
| 10 |
+
short_description: Decide --reasoning-parser from a model's own chat template
|
| 11 |
---
|
| 12 |
|
| 13 |
+
# Reasoning-parser advisor
|
| 14 |
+
|
| 15 |
+
A model that thinks needs vLLM's `--reasoning-parser` to split that
|
| 16 |
+
thinking out of the answer, and the two ways of getting it wrong are not
|
| 17 |
+
symmetric.
|
| 18 |
+
|
| 19 |
+
A **missing** parser is visible: the user sees the model's reasoning in
|
| 20 |
+
the reply. A **wrong** one is not — it claims the entire output, the
|
| 21 |
+
request finishes with `stop`, and `content` comes back **empty**.
|
| 22 |
+
Nothing errors, and nothing in the logs says so.
|
| 23 |
+
|
| 24 |
+
The family name cannot decide it. `Qwen3.6-35B-A3B` emits `<think>` and
|
| 25 |
+
needs the `qwen3` parser; `Qwen3-VL-30B` emits nothing of the sort and
|
| 26 |
+
is broken by it. A quantized pack inherits its source's template, so the
|
| 27 |
+
same split runs through every repack.
|
| 28 |
+
|
| 29 |
+
Everything runs **in the visitor's browser**. There is no backend and
|
| 30 |
+
nothing is uploaded: the page fetches the repo's chat template — a few
|
| 31 |
+
kilobytes — and asks whether the assistant's turn carries a marker some
|
| 32 |
+
parser closes on.
|
| 33 |
+
|
| 34 |
+
## How the rules are kept honest
|
| 35 |
+
|
| 36 |
+
Markers are read out of vLLM's own `vllm/reasoning/` modules rather than
|
| 37 |
+
from documentation, because a parser matches what its code matches. Only
|
| 38 |
+
markers that *discriminate a reasoning section* are listed: an earlier
|
| 39 |
+
version of the table included `<|end|>`, gpt-oss's turn terminator, and
|
| 40 |
+
recommended a parser for a model that does no thinking at all.
|
| 41 |
+
|
| 42 |
+
The rules exist twice — once in Python for development, once in
|
| 43 |
+
JavaScript for this page — and a parity gate runs the same fixtures
|
| 44 |
+
through both and refuses to deploy on any disagreement.
|
| 45 |
+
|
| 46 |
+
Built from the tooling behind the [aleada](https://huggingface.co/aleada)
|
| 47 |
+
W4A16 packs. See also the
|
| 48 |
+
[pack integrity checker](https://huggingface.co/spaces/aleada/pack-integrity-check).
|
app.js
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* The page: one repo id in, one serving decision out.
|
| 3 |
+
*
|
| 4 |
+
* All rules live in parser_advice.js, which the parity gate holds to the
|
| 5 |
+
* Python implementation. Nothing here decides anything — it fetches,
|
| 6 |
+
* calls, and renders, so a rule can never be quietly different in the UI
|
| 7 |
+
* from the one that was tested.
|
| 8 |
+
*/
|
| 9 |
+
import { ALL_MARKERS, advise, fetchTemplate } from './parser_advice.js';
|
| 10 |
+
|
| 11 |
+
const $ = (id) => document.getElementById(id);
|
| 12 |
+
const out = $('out');
|
| 13 |
+
const esc = (s) => String(s).replace(/[&<>"]/g, (c) =>
|
| 14 |
+
({ '&': '&', '<': '<', '>': '>', '"': '"' }[c]));
|
| 15 |
+
|
| 16 |
+
function renderRules() {
|
| 17 |
+
const seen = new Map();
|
| 18 |
+
for (const [parser, marks] of Object.entries(ALL_MARKERS)) {
|
| 19 |
+
const key = marks.join(' ');
|
| 20 |
+
if (!seen.has(key)) seen.set(key, []);
|
| 21 |
+
seen.get(key).push(parser);
|
| 22 |
+
}
|
| 23 |
+
$('rules').innerHTML = [...seen.entries()].map(([marks, parsers]) =>
|
| 24 |
+
`<tr><td><code>${parsers.map(esc).join('</code>, <code>')}</code></td>` +
|
| 25 |
+
`<td><code>${marks.split(' ').map(esc).join('</code> <code>')}</code></td></tr>`
|
| 26 |
+
).join('');
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
function card(cls, title, body) {
|
| 30 |
+
return `<div class="card ${cls}"><h3>${title}</h3>${body}</div>`;
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
function render(repo, source, result) {
|
| 34 |
+
const meta = `<div class="meta">
|
| 35 |
+
<span>repo <code>${esc(repo)}</code></span>
|
| 36 |
+
<span>template from <code>${esc(source)}</code></span>
|
| 37 |
+
</div>`;
|
| 38 |
+
|
| 39 |
+
if (result.verdict === 'unknown') {
|
| 40 |
+
return meta + card('check', 'No chat template published',
|
| 41 |
+
`<p>Nothing here can be decided from metadata. The repo publishes neither
|
| 42 |
+
<code>chat_template.jinja</code> nor a <code>chat_template</code> in
|
| 43 |
+
<code>tokenizer_config.json</code>, so there is no assistant turn to read.
|
| 44 |
+
Serving it will still work — the decision just has to come from somewhere
|
| 45 |
+
else.</p>`);
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
if (result.verdict === 'none') {
|
| 49 |
+
return meta + card('clear', 'Serve it without a reasoning parser',
|
| 50 |
+
`<div class="flag">vllm serve ${esc(repo)}</div>
|
| 51 |
+
<p>The template carries no marker any parser closes on. Adding
|
| 52 |
+
<code>--reasoning-parser</code> here is the silent failure: the parser
|
| 53 |
+
would claim the whole answer, the request would finish with
|
| 54 |
+
<code>stop</code>, and <code>content</code> would come back empty.</p>`);
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
const parsers = Object.keys(result.candidates).sort();
|
| 58 |
+
// Parsers sharing one marker set are interchangeable for this model.
|
| 59 |
+
// Naming the family one first is a convenience, not a rule the data
|
| 60 |
+
// supports, so it is offered as a preference rather than a verdict.
|
| 61 |
+
const preferred = parsers.find((p) => repo.toLowerCase().includes(p.split('_')[0]))
|
| 62 |
+
|| parsers[0];
|
| 63 |
+
const marks = result.candidates[preferred];
|
| 64 |
+
|
| 65 |
+
const others = parsers.filter((p) => p !== preferred);
|
| 66 |
+
const alt = others.length
|
| 67 |
+
? `<p>Interchangeable for this model, because they close on the same marker:
|
| 68 |
+
<code>${others.map(esc).join('</code>, <code>')}</code>. Pick the one named
|
| 69 |
+
for the model's family if there is one.</p>`
|
| 70 |
+
: '';
|
| 71 |
+
|
| 72 |
+
return meta + card('check', 'This model thinks — it needs a parser',
|
| 73 |
+
`<div class="flag">vllm serve ${esc(repo)} --reasoning-parser ${esc(preferred)}</div>
|
| 74 |
+
<p>Its template emits ${marks.map((m) => `<code>${esc(m)}</code>`).join(' and ')},
|
| 75 |
+
which <code>${esc(preferred)}</code> closes on.</p>
|
| 76 |
+
${alt}
|
| 77 |
+
<p>Without the flag that section reaches the user as the answer.</p>`);
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
async function run(repo) {
|
| 81 |
+
const go = $('go');
|
| 82 |
+
go.disabled = true;
|
| 83 |
+
out.innerHTML = `<p class="spin">reading ${esc(repo)}…</p>`;
|
| 84 |
+
try {
|
| 85 |
+
const { template, source } = await fetchTemplate(repo);
|
| 86 |
+
out.innerHTML = render(repo, source, advise(template));
|
| 87 |
+
} catch (e) {
|
| 88 |
+
out.innerHTML = card('problem', 'Could not read the repo',
|
| 89 |
+
`<p>${esc(e.message || e)}</p>
|
| 90 |
+
<p>Gated and private repos cannot be read from the browser.</p>`);
|
| 91 |
+
} finally {
|
| 92 |
+
go.disabled = false;
|
| 93 |
+
}
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
$('form').addEventListener('submit', (e) => {
|
| 97 |
+
e.preventDefault();
|
| 98 |
+
const v = $('repo').value.trim();
|
| 99 |
+
if (v) run(v);
|
| 100 |
+
});
|
| 101 |
+
document.querySelectorAll('[data-ex]').forEach((b) =>
|
| 102 |
+
b.addEventListener('click', () => {
|
| 103 |
+
$('repo').value = b.dataset.ex;
|
| 104 |
+
run(b.dataset.ex);
|
| 105 |
+
}));
|
| 106 |
+
|
| 107 |
+
renderRules();
|
assert-logo.png
ADDED
|
index.html
CHANGED
|
@@ -1,19 +1,203 @@
|
|
| 1 |
<!doctype html>
|
| 2 |
-
<html>
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
</html>
|
|
|
|
| 1 |
<!doctype html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="utf-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
| 6 |
+
<title>Does this model need a reasoning parser?</title>
|
| 7 |
+
<!-- The Space renders inside an iframe and huggingface.co sends
|
| 8 |
+
x-frame-options: DENY, so any link without a target tries to load a
|
| 9 |
+
refused page in the frame and reads as broken. -->
|
| 10 |
+
<base target="_blank">
|
| 11 |
+
<style>
|
| 12 |
+
:root {
|
| 13 |
+
--bg: #fbfbfa; --panel: #ffffff; --ink: #1a1a19; --muted: #6b6b66;
|
| 14 |
+
--line: #e4e3df; --accent: #3d5a80;
|
| 15 |
+
--problem: #a03030; --problem-bg: #fdf3f2;
|
| 16 |
+
--check: #8a6212; --check-bg: #fdf9ee;
|
| 17 |
+
--clear: #2f6b45; --clear-bg: #f1f8f3;
|
| 18 |
+
--mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, monospace;
|
| 19 |
+
}
|
| 20 |
+
@media (prefers-color-scheme: dark) {
|
| 21 |
+
:root {
|
| 22 |
+
--bg: #16171a; --panel: #1d1f23; --ink: #e8e6e3; --muted: #9a978f;
|
| 23 |
+
--line: #2e3137; --accent: #8ab0d9;
|
| 24 |
+
--problem: #e08a86; --problem-bg: #2a1e1e;
|
| 25 |
+
--check: #d9b76a; --check-bg: #29241a;
|
| 26 |
+
--clear: #8fc9a6; --clear-bg: #1b2620;
|
| 27 |
+
}
|
| 28 |
+
}
|
| 29 |
+
* { box-sizing: border-box; }
|
| 30 |
+
body {
|
| 31 |
+
margin: 0; background: var(--bg); color: var(--ink);
|
| 32 |
+
font: 16px/1.65 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
|
| 33 |
+
-webkit-font-smoothing: antialiased;
|
| 34 |
+
}
|
| 35 |
+
.wrap { max-width: 50rem; margin: 0 auto; padding: 3.5rem 1.25rem 5rem; }
|
| 36 |
+
.brand { display: inline-block; margin-bottom: 1.75rem; }
|
| 37 |
+
.brand img { height: 1.5rem; width: auto; display: block; filter: invert(1); opacity: .78; }
|
| 38 |
+
@media (prefers-color-scheme: dark) { .brand img { filter: none; opacity: .9; } }
|
| 39 |
+
|
| 40 |
+
header h1 {
|
| 41 |
+
font-size: clamp(1.6rem, 4.5vw, 2.2rem); line-height: 1.2;
|
| 42 |
+
letter-spacing: -0.02em; margin: 0 0 .75rem; font-weight: 620;
|
| 43 |
+
}
|
| 44 |
+
header p { color: var(--muted); margin: 0 0 .5rem; max-width: 42rem; }
|
| 45 |
+
|
| 46 |
+
form { display: flex; gap: .5rem; flex-wrap: wrap; margin: 2rem 0 .75rem; }
|
| 47 |
+
input[type=text] {
|
| 48 |
+
flex: 1 1 20rem; min-width: 0; padding: .7rem .85rem;
|
| 49 |
+
border: 1px solid var(--line); border-radius: .5rem;
|
| 50 |
+
background: var(--panel); color: var(--ink);
|
| 51 |
+
font: inherit; font-family: var(--mono); font-size: .92rem;
|
| 52 |
+
}
|
| 53 |
+
input[type=text]:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
|
| 54 |
+
button {
|
| 55 |
+
padding: .7rem 1.4rem; border: 0; border-radius: .5rem;
|
| 56 |
+
background: var(--accent); color: #fff; font: inherit; font-weight: 560; cursor: pointer;
|
| 57 |
+
}
|
| 58 |
+
button:hover { filter: brightness(1.08); }
|
| 59 |
+
button:disabled { opacity: .55; cursor: progress; }
|
| 60 |
+
|
| 61 |
+
.examples { font-size: .86rem; color: var(--muted); margin-bottom: 2.5rem; line-height: 2; }
|
| 62 |
+
.examples .group { display: inline-block; min-width: 6.5rem; }
|
| 63 |
+
.examples button {
|
| 64 |
+
background: none; color: var(--accent); padding: 0 .15rem; font-size: .86rem;
|
| 65 |
+
font-family: var(--mono); text-decoration: underline; text-underline-offset: 2px; font-weight: 400;
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
.card {
|
| 69 |
+
background: var(--panel); border: 1px solid var(--line);
|
| 70 |
+
border-radius: .7rem; padding: 1.1rem 1.3rem; margin: .85rem 0;
|
| 71 |
+
}
|
| 72 |
+
.card h3 { margin: 0 0 .5rem; font-size: 1.02rem; font-weight: 600; }
|
| 73 |
+
.card p { margin: .5rem 0; }
|
| 74 |
+
.flag {
|
| 75 |
+
font-family: var(--mono); font-size: .95rem; background: var(--bg);
|
| 76 |
+
border: 1px solid var(--line); border-radius: .4rem;
|
| 77 |
+
padding: .55rem .8rem; margin: .6rem 0; overflow-x: auto; white-space: nowrap;
|
| 78 |
+
}
|
| 79 |
+
.problem { border-left: 3px solid var(--problem); background: var(--problem-bg); }
|
| 80 |
+
.problem h3 { color: var(--problem); }
|
| 81 |
+
.check { border-left: 3px solid var(--check); background: var(--check-bg); }
|
| 82 |
+
.check h3 { color: var(--check); }
|
| 83 |
+
.clear { border-left: 3px solid var(--clear); background: var(--clear-bg); }
|
| 84 |
+
.clear h3 { color: var(--clear); }
|
| 85 |
+
|
| 86 |
+
.meta {
|
| 87 |
+
display: flex; flex-wrap: wrap; gap: .35rem 1.5rem; font-size: .86rem;
|
| 88 |
+
color: var(--muted); padding-bottom: .9rem; margin-bottom: .3rem;
|
| 89 |
+
border-bottom: 1px solid var(--line);
|
| 90 |
+
}
|
| 91 |
+
.meta code { color: var(--ink); }
|
| 92 |
+
code { font-family: var(--mono); font-size: .86em; }
|
| 93 |
+
ul { margin: .5rem 0; padding-left: 1.1rem; }
|
| 94 |
+
li { margin: .2rem 0; }
|
| 95 |
+
li code { font-size: .84rem; }
|
| 96 |
+
|
| 97 |
+
h2 { font-size: 1.05rem; font-weight: 600; letter-spacing: -0.01em; margin: 3rem 0 .75rem; }
|
| 98 |
+
table { border-collapse: collapse; width: 100%; font-size: .87rem; }
|
| 99 |
+
th, td { text-align: left; padding: .45rem .7rem .45rem 0; border-bottom: 1px solid var(--line); vertical-align: top; }
|
| 100 |
+
th { font-weight: 600; color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
|
| 101 |
+
.scroll { overflow-x: auto; }
|
| 102 |
+
footer { margin-top: 3.5rem; padding-top: 1.5rem; border-top: 1px solid var(--line); font-size: .87rem; color: var(--muted); }
|
| 103 |
+
footer a { color: var(--accent); }
|
| 104 |
+
.spin { color: var(--muted); font-size: .9rem; }
|
| 105 |
+
</style>
|
| 106 |
+
</head>
|
| 107 |
+
<body>
|
| 108 |
+
<div class="wrap">
|
| 109 |
+
|
| 110 |
+
<header>
|
| 111 |
+
<a class="brand" href="https://assert.gr" rel="noopener">
|
| 112 |
+
<img src="./assert-logo.png" alt="ASSERT" width="420" height="87">
|
| 113 |
+
</a>
|
| 114 |
+
<h1>Does this model need a reasoning parser?</h1>
|
| 115 |
+
<p>
|
| 116 |
+
A model that thinks needs vLLM's <code>--reasoning-parser</code> to split that
|
| 117 |
+
thinking out of the answer. Getting it wrong fails in two ways, and only one
|
| 118 |
+
of them is visible.
|
| 119 |
+
</p>
|
| 120 |
+
<p>
|
| 121 |
+
<strong>Missing</strong> parser: the user sees the model's thinking in the
|
| 122 |
+
reply — obvious, and quickly fixed. <strong>Wrong</strong> parser: it claims
|
| 123 |
+
the entire output, the request finishes with <code>stop</code>, and
|
| 124 |
+
<code>content</code> comes back <strong>empty</strong>. Nothing errors.
|
| 125 |
+
</p>
|
| 126 |
+
<p>
|
| 127 |
+
This reads the repo's <strong>chat template only</strong> — a few kilobytes,
|
| 128 |
+
fetched from your browser — and asks the one question that decides it: does
|
| 129 |
+
the assistant's turn carry a marker some parser closes on?
|
| 130 |
+
</p>
|
| 131 |
+
</header>
|
| 132 |
+
|
| 133 |
+
<form id="form">
|
| 134 |
+
<input type="text" id="repo" value="google/gemma-4-12B-it"
|
| 135 |
+
placeholder="owner/model" autocomplete="off" spellcheck="false"
|
| 136 |
+
aria-label="Model repo id">
|
| 137 |
+
<button type="submit" id="go">Check</button>
|
| 138 |
+
</form>
|
| 139 |
+
<div class="examples">
|
| 140 |
+
<span class="group">Siblings that differ:</span>
|
| 141 |
+
<button type="button" data-ex="Qwen/Qwen3.6-35B-A3B">Qwen3.6-35B needs one</button> ·
|
| 142 |
+
<button type="button" data-ex="Qwen/Qwen3-VL-30B-A3B-Instruct">Qwen3-VL-30B must not have one</button>
|
| 143 |
+
<br>
|
| 144 |
+
<span class="group">Other shapes:</span>
|
| 145 |
+
<button type="button" data-ex="google/gemma-4-12B-it">gemma channel</button> ·
|
| 146 |
+
<button type="button" data-ex="openai/gpt-oss-20b">gpt-oss analysis</button> ·
|
| 147 |
+
<button type="button" data-ex="microsoft/Phi-4-mini-instruct">no thinking at all</button>
|
| 148 |
+
<br>
|
| 149 |
+
<span class="group">Our packs:</span>
|
| 150 |
+
<button type="button" data-ex="aleada/Nemotron-3.5-Lightning-30B-A3B-W4A16">Nemotron-3.5</button> ·
|
| 151 |
+
<button type="button" data-ex="aleada/Qwen3.8-27B-W4A16">Qwen3.8-27B</button>
|
| 152 |
+
</div>
|
| 153 |
+
|
| 154 |
+
<div id="out"></div>
|
| 155 |
+
|
| 156 |
+
<h2>Why the family name cannot decide it</h2>
|
| 157 |
+
<p>
|
| 158 |
+
Two models from one family, one release apart, answer differently:
|
| 159 |
+
<code>Qwen3.6-35B-A3B</code> emits <code><think></code> and needs the
|
| 160 |
+
<code>qwen3</code> parser; <code>Qwen3-VL-30B</code> emits nothing of the sort
|
| 161 |
+
and is <em>broken</em> by it. A quantized pack inherits its source's template,
|
| 162 |
+
so the same split runs through every repack of them.
|
| 163 |
+
</p>
|
| 164 |
+
<p>
|
| 165 |
+
The markers below were read out of vLLM's <code>vllm/reasoning/</code> modules,
|
| 166 |
+
not from documentation — a parser matches what its code matches. Only markers
|
| 167 |
+
that <strong>discriminate a reasoning section</strong> are listed: an earlier
|
| 168 |
+
version of this table included <code><|end|></code>, gpt-oss's turn
|
| 169 |
+
terminator, and recommended a parser for a model that does no thinking at all.
|
| 170 |
+
</p>
|
| 171 |
+
<div class="scroll">
|
| 172 |
+
<table>
|
| 173 |
+
<thead><tr><th>Parser</th><th>Closes on</th></tr></thead>
|
| 174 |
+
<tbody id="rules"></tbody>
|
| 175 |
+
</table>
|
| 176 |
+
</div>
|
| 177 |
+
|
| 178 |
+
<footer>
|
| 179 |
+
<p>
|
| 180 |
+
<strong>A verdict of "none" is an answer, not an absence.</strong> It means
|
| 181 |
+
the template carries no reasoning marker, so the model should be served
|
| 182 |
+
<em>without</em> the flag — adding one is the silent failure described above.
|
| 183 |
+
</p>
|
| 184 |
+
<p>
|
| 185 |
+
Markers extracted from vLLM <code>0.23.1rc1.dev552+g4559c43a9</code>; they are
|
| 186 |
+
not a stable public API upstream. Parsers that hold their markers as token ids
|
| 187 |
+
rather than strings cannot be matched this way — <code>qwen3</code> is listed
|
| 188 |
+
because it closes on the same pair as the DeepSeek family, and that is stated
|
| 189 |
+
rather than inferred. Gated and private repos cannot be read. This never loads
|
| 190 |
+
the model and never runs it.
|
| 191 |
+
</p>
|
| 192 |
+
<p>
|
| 193 |
+
Built from the tooling behind the
|
| 194 |
+
<a href="https://huggingface.co/aleada" rel="noopener">aleada</a> W4A16 packs.
|
| 195 |
+
See also the
|
| 196 |
+
<a href="https://huggingface.co/spaces/aleada/pack-integrity-check" rel="noopener">pack integrity checker</a>.
|
| 197 |
+
</p>
|
| 198 |
+
</footer>
|
| 199 |
+
|
| 200 |
+
</div>
|
| 201 |
+
<script type="module" src="./app.js"></script>
|
| 202 |
+
</body>
|
| 203 |
</html>
|
parser_advice.js
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* Which `--reasoning-parser` a model needs, decided from its chat template.
|
| 3 |
+
*
|
| 4 |
+
* The JavaScript half of `tools/quantize/parser_advice.py`. Both are kept
|
| 5 |
+
* honest by `parity.mjs`, which runs the same fixtures through each and
|
| 6 |
+
* diffs — the rules took a false positive to get right, and a port that
|
| 7 |
+
* drifts from them would reintroduce it silently.
|
| 8 |
+
*/
|
| 9 |
+
|
| 10 |
+
/**
|
| 11 |
+
* Markers read out of vLLM's own reasoning parsers, not from documentation.
|
| 12 |
+
*
|
| 13 |
+
* Only markers that DISCRIMINATE a reasoning section are listed. The first
|
| 14 |
+
* version of this table carried every literal each parser mentions, and
|
| 15 |
+
* recommended gpt_oss for Phi-4-mini — not a reasoning model at all —
|
| 16 |
+
* because Phi's template contains `<|end|>`, which is gpt_oss's turn
|
| 17 |
+
* terminator. That recommendation would have cost the reader empty
|
| 18 |
+
* answers, which is the exact failure this tool exists to prevent.
|
| 19 |
+
*/
|
| 20 |
+
export const PARSER_MARKERS = {
|
| 21 |
+
deepseek_r1: ['<think>', '</think>'],
|
| 22 |
+
hunyuan_v3: ['<think>', '</think>'],
|
| 23 |
+
kimi_k2: ['<think>', '</think>'],
|
| 24 |
+
minimax_m2: ['<think>', '</think>'],
|
| 25 |
+
olmo3: ['<think>', '</think>'],
|
| 26 |
+
step3: ['<think>', '</think>'],
|
| 27 |
+
ernie45: ['<think>', '</think>'],
|
| 28 |
+
minimax_m3: ['<mm:think>', '</mm:think>'],
|
| 29 |
+
gemma4: ['<|channel>', '<channel|>'],
|
| 30 |
+
// gptoss_reasoning_parser.py triggers on this exact phrase, not on
|
| 31 |
+
// `<|message|>` or `<|end|>` alone.
|
| 32 |
+
gpt_oss: ['<|channel|>analysis'],
|
| 33 |
+
cohere_command: ['<|START_THINKING|>', '<|END_THINKING|>'],
|
| 34 |
+
};
|
| 35 |
+
|
| 36 |
+
/**
|
| 37 |
+
* `qwen3` is registered in vLLM but holds its markers as token ids, so it
|
| 38 |
+
* never appears in a scan for string literals. It closes on the same
|
| 39 |
+
* `<think>` pair as the deepseek family — stated here rather than
|
| 40 |
+
* inferred, because an unstated special case is how a checker starts
|
| 41 |
+
* lying.
|
| 42 |
+
*/
|
| 43 |
+
export const TOKEN_ID_PARSERS = { qwen3: ['<think>', '</think>'] };
|
| 44 |
+
|
| 45 |
+
export const ALL_MARKERS = { ...PARSER_MARKERS, ...TOKEN_ID_PARSERS };
|
| 46 |
+
|
| 47 |
+
/** Every parser whose discriminating markers appear in this template. */
|
| 48 |
+
export function candidates(template) {
|
| 49 |
+
const hits = {};
|
| 50 |
+
for (const [parser, marks] of Object.entries(ALL_MARKERS)) {
|
| 51 |
+
const found = marks.filter((m) => template.includes(m));
|
| 52 |
+
if (found.length) hits[parser] = found;
|
| 53 |
+
}
|
| 54 |
+
return hits;
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
/**
|
| 58 |
+
* The verdict for one template.
|
| 59 |
+
*
|
| 60 |
+
* `none` is a real answer, not an absence of one: a template with no
|
| 61 |
+
* reasoning marker must be served WITHOUT a parser, because adding one
|
| 62 |
+
* claims the whole answer and returns empty content.
|
| 63 |
+
*/
|
| 64 |
+
export function advise(template) {
|
| 65 |
+
if (template === null || template === undefined) {
|
| 66 |
+
return { verdict: 'unknown', candidates: {} };
|
| 67 |
+
}
|
| 68 |
+
const hits = candidates(template);
|
| 69 |
+
return {
|
| 70 |
+
verdict: Object.keys(hits).length ? 'candidates' : 'none',
|
| 71 |
+
candidates: hits,
|
| 72 |
+
};
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
/**
|
| 76 |
+
* Pull a repo's chat template, and say which file it came from.
|
| 77 |
+
*
|
| 78 |
+
* Repos publish it in either place and sometimes both. Which one was read
|
| 79 |
+
* matters: a `chat_template.jinja` added later can disagree with the copy
|
| 80 |
+
* embedded in `tokenizer_config.json`, and someone debugging an empty
|
| 81 |
+
* answer needs to know which one this advice is about.
|
| 82 |
+
*/
|
| 83 |
+
export async function fetchTemplate(repoId) {
|
| 84 |
+
const base = `https://huggingface.co/${repoId}/raw/main`;
|
| 85 |
+
|
| 86 |
+
const jinja = await fetch(`${base}/chat_template.jinja`);
|
| 87 |
+
if (jinja.ok) return { template: await jinja.text(), source: 'chat_template.jinja' };
|
| 88 |
+
|
| 89 |
+
const cfg = await fetch(`${base}/tokenizer_config.json`);
|
| 90 |
+
if (cfg.ok) {
|
| 91 |
+
let data;
|
| 92 |
+
try {
|
| 93 |
+
data = await cfg.json();
|
| 94 |
+
} catch {
|
| 95 |
+
return { template: null, source: 'tokenizer_config.json (unparseable)' };
|
| 96 |
+
}
|
| 97 |
+
let tpl = data.chat_template;
|
| 98 |
+
if (Array.isArray(tpl)) tpl = tpl.map((t) => t.template || '').join('\n');
|
| 99 |
+
if (tpl) return { template: tpl, source: 'tokenizer_config.json' };
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
if (jinja.status === 401 || jinja.status === 403 || cfg.status === 401 || cfg.status === 403) {
|
| 103 |
+
return { template: null, source: 'gated or private' };
|
| 104 |
+
}
|
| 105 |
+
return { template: null, source: 'not published' };
|
| 106 |
+
}
|