r/LocalLLaMA • u/am17an • Sep 27 '26
Discussion Adding logit penalty for "wait", "maybe" and "perhaps" to Qwen models improves their accuracy
Meta came out with a banger paper https://arxiv.org/pdf/2606.00206, but it did not look at various quantizations supported in llama.cpp. So I did a run on 50 random MATH-500 questions (https://huggingface.co/datasets/HuggingFaceH4/MATH-500) and ran it on various quantizations of https://huggingface.co/bartowski/Qwen_Qwen3.5-4B-GGUF and tried
--logit-bias 466-2 --logit-bias 694-2 --logit-bias 1362-2 \
--logit-bias 1412-2 --logit-bias 1921-2 --logit-bias 1990-2 \
--logit-bias 2086-2 --logit-bias 2361-2 --logit-bias 2441-2 \
--logit-bias 2493-2 --logit-bias 2892-2 --logit-bias 3222-2 \
--logit-bias 3315-2 --logit-bias 3384-2 --logit-bias 3404-2 \
--logit-bias 3482-2 --logit-bias 3655-2 --logit-bias 4213-2 \
--logit-bias 4370-2 --logit-bias 4598-2 --logit-bias 4611-2 \
--logit-bias 4808-2 --logit-bias 5752-2 --logit-bias 6970-2 \
--logit-bias 7014-2 --logit-bias 7643-2 --logit-bias 8106-2 \
--logit-bias 10179-2 --logit-bias 10451-2 --logit-bias 11746-2 \
--logit-bias 13264-2 --logit-bias 13428-2 --logit-bias 14673-2 \
--logit-bias 15029-2 --logit-bias 16036-2 --logit-bias 21143-2 \
--logit-bias 21979-2 --logit-bias 33955-2 --logit-bias 35999-2 \
--logit-bias 36563-2 --logit-bias 37201-2 --logit-bias 37781-2 \
--logit-bias 41484-2 --logit-bias 62586-2 --logit-bias 66073-2 \
--logit-bias 73071-2 --logit-bias 84485-2 --logit-bias 85152-2 \
--logit-bias 95500-2
these correspond to the paper's overthinking markers:
[
" perhaps", " maybe", " wait", " Wait", " actually",
" hold", " Hmm", " hmm", " Alternatively", " alternatively",
" However", " however", " instead", " Instead", " But",
" but", " though", " although", " yet", " rather",
" unless", " otherwise", " nonetheless", " nevertheless", " regardless",
" still", " anyway", " Or", " or", " either",
" whether", " uncertain", " unsure", " possibly", " might",
" could", " another", " different", " reconsider", " rethink",
" backtrack", " retry", " revisit", " doubt", " confused",
" wrong", " mistake", " error", " incorrect"
]
Here are the results, surprisingly even BF16 leads to better accuracy. Caveats being this is one test on one model. Try it out and see it helps!
| Format | Accuracy: baseline → penalty | Reasoning tokens |
|---|---|---|
| BF16 | 74% → 84% | −19.4% |
| Q8_0 | 76% → 80% | −11.0% |
| Q4_K_M | 60% → 66% | −14.8% |
| Q3_K_M | 52% → 66% | −17.5% |
| Q2_K | 12% → 24% | −11.5% |
•
u/WithoutReason1729 Sep 27 '26 edited Oct 22 '26
Your post is getting popular and we just featured it on our Discord! Come check it out!
You've also been given a special flair for your contribution. We appreciate your post!
Stylome classified this post's text as human-written. View analysis
I am a bot and this action was performed automatically.
4
u/shaxsy Sep 27 '26
How do you add penalties for those words?
189
u/brainExploded99 🥔 hardware Sep 27 '26 edited Sep 27 '26
big if true (and replicatable across many benchmarks and doesn't lead to some silent degredation under non benchmark tasks)
87
u/EitherMarch1255 Sep 27 '26
I’d be interested to know how this works on 3.8 27b
77
u/_sqrkl Sep 27 '26
We identified this a few months ago and made an article and tool for training the model so it's fixed permanently.
The increase in scores is because these tokens are responsible for the model's doom looping propensity. Suppress them, and you get more responses running to completion and producing a parseable answer.
23
u/chortly2 Sep 27 '26
Also, this list of over-thinking markers is fairly crudely generated, with a fairly arbitrary cut-off and a fixed penalty. All of that makes sense for the paper -- the simplicity in theory shows it should be a fairly robust approach -- but I can imagine it could be improved by another factor of 2 with some further exploration, even assuming that they did some unreported optimization in choosing their list, cut-off, and penalty value.
10
u/chessoculars Sep 27 '26
I noticed you left out " recheck" from the paper's list, probably because that tokenizes to 2 tokens (311 + 1960) for Qwen 3.5-4B?
In general if people are curious, you can check the tokens for this list with a command like:
Or regex it together to create command-line options specifically for the currently running model:
Although of course that risks ignoring issues like " recheck" tokenizing to two tokens, so probably not smart.
15
u/crusaderky Sep 27 '26
-16% accuracy from q8 to q4_k_m? That's very surprising and concerning if true.
[EDIT] Ah it's 4b. Makes more sense now
7
u/DonMoralez Sep 27 '26
Check your console for `DEPRECATED: argument '--logit-bias' specified multiple times, use comma-separated values instead (only last value will be used)` just to be sure your tests were correct.
26
u/ibringthehotpockets Sep 27 '26
An actual useful and interesting reddit post not fully written by ai for karma. Beautiful
Seriously though that’s pretty cool. The benchmarks are a good lead and I wonder how it generalizes to other uses
4
u/FoxiPanda Sep 27 '26
This is ... absolutely fascinating. I'll have to go read that paper but this is the sort of surgical behavior alteration that I'm all for in managing local models. Great find.
4
u/gofiend Sep 27 '26 edited Sep 27 '26
Honestly I think I prefer this approach (maybe even raise salience of tokens like “in conclusion” while reducing “wait a min”). You could tweak llama.cpp to kick these in only after the first X tokens so we don’t rush the model and increase the penalty as thinking extends.
I prefer this to the finetuning approach (don’t get me wrong I love finetuning and Swift etc as bold projects but) because fine tuning without the OG traces skews models towards the biases of the fine tuning dataset. Makes sense for specializing models but perhaps a tiny bit less so for tweaking general behaviors.
Finally model trainers please just give us a token <|playing_off_music|> we can inject to tell the model to start wrapping up 😂
4
u/mrepop Sep 27 '26 edited Sep 27 '26
Oh my god, I’m thinking about ditching qwen-3.8 27b for pretty much these exact phrases after putting in penalties wasn’t enough. No matter how harsh the penalties were every one of these phrases seemed like the beginning of a loop.
The over thinking can be extremely frustrating.
It seems almost like a regression outside of benchmark tasks where the model intentionally goes into these loops. The odd thing is that taking the exact same model and running it through benchmarks doesn’t do any of this.
This could just be biasing from training the model to score well on benchmarks, but it seems a little deeper than that, at least much worse than previous qwen models.
Makes me wonder…
4
u/According_Air_3815 Sep 28 '26
Then I'm curious why did Qwen team didn't do this while there RL ?
4
u/repepeper Sep 28 '26
Late to the party, aren't you?
https://huggingface.co/ukisai/Swift-1.5-Qwen3.8-27b
3
u/silenceimpaired Sep 27 '26
Can Model.ini take this I wonder. I’ll have to try.
3
u/fiery_prometheus Sep 27 '26
It even worked on the bf16 model, interesting, as one of the markers of quantization damage was more overthinking, but this works despite no quantization damage.
3
u/jinnyjuice vLLM Sep 27 '26
Very interesting!
I think this approach makes more sense compared to modifying the weights of the parameters like bottlecapai's ThinkingCap.
I wonder if PLE/n-gram of penalising combo words works better. I feel precision would improve.
It would also be nice if these logit biases can be applied to reasoning streams only.
3
u/Kmic68 Sep 27 '26
cutting 20% of tokens would be a big deal if this scales to larger models. But doesn't swift kinda already do this for 27B?
3
u/Express_Quail_1493 Sep 27 '26
A standard abliterted version already reduces this. I suspect its doing so many “wait” and “actually” wasting tokens to see if the user’s request is allowed
3
u/Foreign_Risk_2031 Sep 27 '26
Can we punish “\nwait “
3
u/aboutthednm llama.cpp Sep 28 '26
But wait... Interesting.
3
u/mlhher Sep 28 '26
Natively supported by late with a minimal default overthinking word list, can be extended with any logits you want (and since the harness does it can be used independent of llama.cpp itself and separately for any app/instance of the harness). The (older, original) paper is also attached there, this is relatively old https://arxiv.org/abs/2506.08343
https://github.com/mlhher/late-cli (yes im the dev)
4
u/Negative-Web8619 Sep 27 '26
wtf
4
u/Bakoro Sep 27 '26
For math specifically, I want to know how turning the temperature all the way down affects accuracy. High level mathematics does need some abstract thinking and exploration, but for arithmetic, algebra, calculus, that kind of number crunchy stuff, there is a correct process and any deviation from that process risks a cascade that isn't caught by a later part of the chain of thought.
Penalizing hedge words seems like a roundabout way to push down the likelihood of anything that's not the target process.
2
u/magicduck Sep 27 '26
Decent on math but how does it fare on scripting, large codebases, toolcalling, research, creative writing?
2
u/ghgi_ Sep 27 '26
this is pretty sick, been messing around with it after doing a custom vllm patch and my qwen 3.8 next flash setup so far seeing good results from these tweaks. depending on what its doing, 18-30% less thinking, it only applies it while its in the think block section so outputs remain the same, the model actually seems more proactive but could be placebo, no visible regressions though, tokens are less, quality up in the air right now, so far "looks" on par or better
2
u/Baccano101 Sep 27 '26
Sounds really promising. Just tried with Swift-1.5-Qwen3.8-27B-GSQ-RCO-IQ3_XXS.
For 3 prompts it did not change the output (No or little overthinking in the first place). On a fourth problem it reduced token usage from 828 to 233 Tokens while still returning the right answer.
The token IDs in the first post appear to also be valid for Qwen 3.8 27B (and probably other Qwen 3 models).
To make it work with other models recalculating the IDs via the llama-tokenizer would be required.
3
u/eightone-81 Sep 28 '26
Checked the "overthinking markers" idea against ~2.2M tokens of real Qwen3.8-Flash-Next agent thinking: only 3 words look worth penalizing, and the ceiling is small
Disclosure: I asked the questions. The study itself (log mining, judging, spot-checks, numbers) and this write-up were done by Claude Opus 5.5 working as my agent. It's an observational analysis of logs, not an A/B test with the penalty turned on.
TL;DR
Only three words (with their capitalised and line-start forms) look worth penalizing for Flash-Next in agent/coding work. At best they save a few percent of thinking, mostly inside long, looping blocks:
Setup
Findings
1. The waste is real, but it isn't where the markers are.
2. Hesitation density rises with block length. Strong markers per 1,000 characters go from 0.68 in short blocks to 1.08 in blocks over 10k characters. The overthinking sits in the long blocks, not spread evenly.
3. The two judges disagree a lot, and the model is lenient on itself.
4. What the agreed-waste cases look like (17 of 280 hesitations), in three types:
<h2 class="as-title">…*? Line 9 showed*<h2 class="as-title">…*. OK, applied.*"The loops are the only case worth much, and they are exactly where a flat per-token penalty is weakest. The model can keep looping with words that aren't on the list.
5. The paper's list is tuned for math, not agents.
Practical notes if you want to try it on vLLM
logit_biasis refused under speculative decoding: requests carrying it are rejected when spec decoding (MTP/ngram) is on. See vLLM issue #42744.Ideas I'd test before a flat penalty (all untested):
Limitations
Happy to answer questions about the method.
2
u/Dabalam Sep 27 '26
This is presumably a different approach to the recent models released like Swift and Thinking Cap? Is it something that could be added to those models? Also I suppose it would need to be tested for effects in other domains.
1
u/Dany0 Sep 27 '26
You could bake this into a simple PR. Read quant level -> output overthinking logits reduction. As these things generally go, there must be a simple relationship between the quant level & how much you should bias it
1
u/shing3232 Sep 27 '26
i guess you can make one list for every model of differ size
1
u/Cradawx Sep 27 '26
Interesting. I believe the logit bias range goes from -100 to +100. I wonder what impact larger a bias will have.
1
u/AbeIndoria Sep 27 '26
hm, I have the hardware to test it on Qwen3.8-27B on Q6KL (or even Q8). Perhaps I should.
1
u/Elouakili_Flexy Sep 27 '26
Q2_K going 12 → 24 says more than the BF16 row. It went from random to slightly less random with one command line.
1
u/krumpstead Sep 27 '26
Thanks for sharing this, OP. I had not seen this paper. I slopped together a quick auto-discover OpenCode plugin that can be placed in a project's
.opencodesubdir to test this out. It actually works great with Qwen 3.8 27B. The plugin injects the logit bias values into thechat.params. I couldn't get it to work effectively without adding values which didn't have leading spaces so I ended up adding values for that and also capitalized versions of all words which didn't already have a pair. A bias of 3 really drives the icepick deep into 27B's brain. Coding was pretty much worthless, but I think it may be perfect for structured agentic workflows. Your chosen bias of 2 seems like a good balance. If anyone is interested I may throw the plugin up on github, after I test it some more.Here's the 116 token values I'm using, just more variants of the same words from the paper:
1
u/Educational-Care7867 Sep 27 '26
I'm just gonna try this on my ImaJev model here which got #1 on the JevBench Score above Jev itself..
Will let you know if this approach helps in System 1 models as well.
1
u/Zeikos Sep 28 '26
Makes me wonder which logits if tuned up would increase performance.
1
u/BS_BlackScout Sep 28 '26
This doesn't surprise me. I was doing it for the "consider" token and didn't think " reconsider" could've been one so I thought it wasn't effective. I'm trying again lol.
1
u/segmond Sep 28 '26
Anyone try it on code yet?
1
u/FlawlessIndividual Sep 28 '26
"But wait, maybe I shouldn't actually launch the warhead"
lol
1
u/AlabamaResearcher Sep 28 '26
there are more implications for this. logit-bias can be set per-request. which means it can act like a reasoning-effort control for models don't have native reasoning-effort.
even for qwen3.8-27b,changing reasoning-effort mid-session will cause kv-cache recompute (because the template changed injected text) while this will not.
1
u/jacek2023 llama.cpp Sep 28 '26
very good idea
1
u/dtfinch llama.cpp Sep 28 '26
Now I want to try setting that per-request, to vary the strength in proportion to the context usage, once I get around to building my own harness.
1
u/PraiseThePidgey Sep 28 '26
Just added those to my system-prompt and it kind of makes Qwen 3.8 27B thinking more consistent and straightforward instead of doubting at least 2-3 times during each new prompt
1
u/Stunning-Sherbet1853 Oct 03 '26
love that you tested across quants, the Q3 jump is wild. and −19% reasoning tokens is honestly the part I'm most jealous of, overthinking eats a huge chunk of our budget in agent runs.
one thing I'm wondering for agent use: the bias applies to the whole output, right? "or", "error", "retry" show up in code and tool calls, and "unsure" / "wrong" are exactly the words I want my agent to keep when it can't verify something. I'd hate to trade "wait, maybe" for a model that confidently says "done" lol
did you try applying it to the reasoning part only? thinking of testing that with a trimmed list.
1
u/brahh85 Sep 27 '26
this is the reason why some Q8 work better than BF16 , or give better perplexity, the original model had some data in the weights that screwed the performance of the BF16 , and the Q8 crushed it. Back in time, i got a llama3 that was fully uncensored in Q4_KM , the BF16 and the rest of the quants were all censored , so the quantization just broke a "memory" that made the model work better , well, uncensored
1
u/KingArthas94 Sep 27 '26 edited Sep 27 '26
I noticed in my first week of playing with local LMM models (this one!) so it's good that they were able to prove it mathematically.
This is why I love my little models that allow me to set a reasoning budget (I just choose 1000 tokens).
Now let's hope the available software and models get updated to stop wasting our time by getting in useless thinking loops...
0
u/Former-Ad-5757 Llama 3 Sep 29 '26
The problem is this is basically what qwen reasoning is, you reduce the reasoning and thus the quality of more complex outputs.
in the jina template the xhigh format is literally :
{%- 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.' %}
So it should validate everything it considers key, it should consider plausible alternatives. It should detect errors to prioritise correctness, consistency etc.
Now if you put a chat message like 'hello' towards xhigh then you are forcing it to overthink.
Basically you have a reasoning instruction that explicitly says it should do those things and you are setting negative temps on exactly those things, the result can be good on small tasks, but on real tasks it will be chaos and you should just have used a different reasoning level.