The Dataset Viewer has been disabled on this dataset.

Overthinking penalty logit bias for llama.cpp

Logit bias lists and a script to apply the overthinking penalty of Lotfi et al., "Quantized Reasoning Models Think They Need to Think Longer, but They Do Not" (arXiv:2606.00206) with llama.cpp's llama-server.

The method subtracts a fixed λ from the logits of 50 overthinking markers (Appendix C, Table 8: " Wait", " But", " Alternatively", " perhaps", ...) at every decoding step. It needs no extra forward pass, so llama.cpp's logit bias is all it takes.

For Ornith-1.5 and models built from it (e.g. Tiel-Coder), there is also a paragraph-start list (--paragraph-start, bias/ornith-1.5-35b-a3b/paragraph-start-lambda-*). These models open a new line of reasoning at the start of a paragraph ("\n\nWait,", "\n\nActually,"), where the word has no leading space and is a different token from the paper's " Wait". This variant is not in the paper.

In coding-agent runs with a thinking budget on these models (see REPORT.md), neither list was shown to be clearly better than no bias. Neither clearly reduced the replies that reasoned up to the budget or that went in circles, the changes in output length were smaller than single runs vary, and the passed tasks moved in no consistent direction. If reasoning loops are the problem, reconsidering the quantization (the paper reports that aggressive quantization lengthens the reasoning) or setting a thinking budget is the more direct remedy; see the report's conclusion for what was and was not measured.

Files

Path Content
make_logit_bias.py Builds the list for any GGUF (Python standard library only)
REPORT.md How the lists were verified, on Ornith-1.5 and Tiel-Coder
tasks/ Texts and hidden tests of the three hard coding tasks used in the report
reasoning_loops.py Counts the budget hits and looping replies of a pi run, as used in the report
paragraph_openers.py Counts the words that open the paragraphs of the reasoning in pi runs, as used in the report
bias/qwen3.8-27b/lambda-2.0.json λ = 2.0 as [[token_id, bias], ...], for the logit_bias request field
bias/qwen3.8-27b/lambda-2.0.args The same as llama-server options (-l ID-BIAS ...)
bias/ornith-1.5-35b-a3b/lambda-2.0.{json,args} The same for Ornith-1.5-35B-A3B
bias/*/paragraph-start-lambda-4.0.{json,args} Paragraph-start markers (--paragraph-start), λ = 4.0: in the report, fewer tasks passed than without bias
bias/*/paragraph-start-lambda-2.0.{json,args} The same at λ = 2.0: in the report, the shortest mean output on Ornith-1.5, by less than single runs vary

Token IDs depend on the vocabulary, not on the model weights or the quantization. The Qwen3.8-27B family, the Qwen3.5-35B-A3B family and the Ornith family derived from them share one tokenizer (248,320 tokens, sha256:f307bf31f9c6130c as printed by the script), so the lists here are identical and fit any of these models.

For any other model, build the list yourself (below); it takes a second. 49 of the 50 markers are single tokens in this vocabulary; " recheck" is two tokens and is skipped.

1. Build the list

# Local GGUF (the first shard of a split model)
python3 make_logit_bias.py model.gguf -p 2.0 -o bias.json

# GGUF on the Hub: only the header is downloaded (a few MB)
python3 make_logit_bias.py hf://OWNER/REPO/model-Q4_K_M.gguf -p 2.0 -o bias.json

# llama-server options instead of JSON
python3 make_logit_bias.py model.gguf -p 2.0 -f cli

# Paragraph-start markers instead of the paper's list
python3 make_logit_bias.py model.gguf --paragraph-start -p 4.0 -o bias.json

-p is λ (> 0). The paper sweeps 0.5–4.0 and reports the best λ per configuration; it gives no single value for all models. The script prints the token ID of each marker and the vocabulary hash to stderr. Set HF_TOKEN for gated repos. Supported tokenizers: byte-level BPE (gpt2, e.g. Qwen, Llama 3) and SentencePiece (llama).

Paragraph-start markers (--paragraph-start)

--paragraph-start replaces the paper's 50 leading-space markers with 10 capitalized markers spelled without a leading space, the form a word takes at the start of a paragraph:

Wait, Hmm, Actually, But, However, Alternatively, Instead, Or, Maybe, Perhaps

These are the words Ornith-1.5 opens its reasoning branches with, plus the capitalized hedges of the paper's list. "Actually" is not in the paper (only " actually" is), but when it was left out, the model opened its paragraphs with "Actually" instead (see REPORT.md). Lower-case forms without a space are left out: they are mostly word pieces ("thres|hold", "Iterat|or"). The --also-no-space option adds the no-space form of all 50 markers (83 tokens) to the paper's list, word pieces included.

2. Use it with llama-server

Per request

llama-server accepts logit_bias as an array of [token_id, bias] pairs on /completion and the OpenAI-compatible /v1/chat/completions:

jq -n --slurpfile lb bias.json '{
  messages: [{role: "user", content: "How many primes are below 100?"}],
  logit_bias: $lb[0]
}' | curl -s http://127.0.0.1:8080/v1/chat/completions \
       -H 'Content-Type: application/json' -d @-

With the OpenAI Python client:

import json
from openai import OpenAI

client = OpenAI(base_url="http://127.0.0.1:8080/v1", api_key="none")
bias = json.load(open("bias.json"))
resp = client.chat.completions.create(
    model="local",
    messages=[{"role": "user", "content": "How many primes are below 100?"}],
    extra_body={"logit_bias": bias},  # a list of pairs, so pass it in extra_body
)

Many agents and clients have an "extra body" setting where the same {"logit_bias": [...]} can go.

Server-wide

llama-server -m model.gguf $(cat bias/qwen3.8-27b/lambda-2.0.args)

Caveats

  • A request's logit_bias replaces the server's -l list rather than adding to it.
  • --models-preset (INI) cannot hold the list: a preset keeps one value per key and --logit-bias takes one token, so only the last entry would apply. Use the per-request form with router mode.
  • The penalty applies to the whole output, not only to the reasoning: the answer, code and comments also see fewer " or", " but", " error", " could", and so on. Only the leading-space forms are penalized, so e.g. error at the start of a line or after ( is not affected. With --paragraph-start it is the other way round: only the no-space forms (start of a line, after (, ", **, ...) are penalized, so a sentence or a bullet that starts with "But" or "However" becomes less likely, while the same words mid-sentence are unaffected. Identifiers such as Or or Maybe in code are affected too.
  • The reasoning does not always get shorter: in the report it did only on some models, and single runs vary a lot (see REPORT.md).
  • Penalizing one form moves the hesitation to the others: with the paper's list, the models opened more paragraphs with "Wait" or "Actually"; without "Actually" in --paragraph-start, Ornith opened its paragraphs with "Actually" instead.
  • The IDs are only valid for the vocabulary they were built from. A list for another vocabulary silently penalizes unrelated tokens.

Verification

See REPORT.md for the setup and the results on Ornith-1.5-35B-A3B and Tiel-Coder-35B-A3B, in a coding agent with a thinking budget. Evaluate on your own tasks before relying on the penalty.

  • Scope. The report measures only whether the penalty curbs overlong reasoning: three coding tasks in a coding agent, judged by hidden tests, with the output tokens and the hesitation markers counted. The effect on the benchmarks reported in the paper was not measured here.

Citation

@misc{lotfi2026quantized,
  title         = {Quantized Reasoning Models Think They Need to Think Longer, but They Do Not},
  author        = {Lotfi, Sanae and Kirichenko, Polina and Li, Steven and Liu, Zechun},
  year          = {2026},
  eprint        = {2606.00206},
  archivePrefix = {arXiv},
  url           = {https://arxiv.org/abs/2606.00206}
}

The marker list is taken from Table 8 of the paper. This repository is not affiliated with the authors.

License

The script and the lists are released under the Apache License 2.0 (see LICENSE).

Downloads last month
338

Paper for na0x2c6/overthinking-logit-bias