r/MachineLearning • • 11d ago

Project Training-free early exit for reasoning models: a linear probe folded into the </think> row of the output layer [p]

Reasoning models often reach the right answer early and then keep double-checking it for thousands of tokens. I got the model to stop at that point by changing a single row of weights..There's no training and no extra code at inference time; the edited model is an ordinary weights file that runs anywhere.

![img](5yk991rjlt1i1)

Background,

  • Reasoning models (DeepSeek, Qwen, and so on) "think" in a scratchpad before answering. The scratchpad ends when the model writes a special token, </think>.
  • To pick each next token, the model first computes a summary of everything so far: a long list of numbers called the hidden state. The last layer, the output layer, has one row of weights per word in the vocabulary. Each word's score is its row multiplied by the hidden state, and the highest-scoring words are the likeliest next words.
  • So the score for "stop thinking now" (</think>) comes from exactly one row of that layer.

What I did

  1. Ran the model on 24 maths problems and recorded its hidden state at every token of its thinking.
  2. Marked the points where the right answer had already appeared and the model was only re-checking (specifically, the ends of paragraphs after that point), and treated everything else as "still working".
  3. Found the direction in the hidden state that best separates those two groups. This is a probe: a simple linear classifier (linear discriminant analysis), computed directly with linear algebra, with no gradient training.
  4. Added that direction, times a strength of 14, to the </think> row. The "stop" score now rises only when the model's state looks like "done, just re-checking". While it's still solving, nothing measurable changes.

A useful side effect: because only one token's score changes, I can compute exactly what the edited model would do from recordings of the original, without rerunning it. That's how I picked the strength and searched for cases where it would stop too early.

![img](0r3nr3xrlt1i1)

On a problem it never saw: the answer appears at token 567, the original keeps thinking until token 7,415, and the edited model stops by token ~2,000 with 98% probability.

Results (small samples, one run per setting)

![img](psaikkt6lt1i1)

  • Qwen3.5-4B (runs in stock llama.cpp): same accuracy on 8 unseen MATH-500 problems with 54% fewer tokens. On 3 AIME 2025 problems with a 32k-token limit, the original ran out of tokens on all three while re-checking answers it already had; the edited model solved 2.
  • DeepSeek V4.1 Flash (763B parameters, 2-bit, on my laptop with an 8 GB GPU, streaming weights from the SSD): 7/7 maths problems vs 6/7, with 40% fewer tokens.
  • As a coding agent building a small website: 84% less thinking. It still thinks after an error or anything unexpected, and skips thinking after routine steps. Page quality held up; an LLM rating put it highest, and the screenshots are below so you can judge for yourself.

![img](3q1n1yp8lt1i1)

What isn't new: using a probe on the hidden state to stop reasoning early is published (e.g. Zhang et al. 2025, arXiv 2504.05419). What's new is putting the probe inside that one row of weights, so nothing extra runs, plus these measurements.

Limitations: small sample sizes; the probe was fitted on maths only (the agent results are transfer); the AIME comparison uses a 32k budget, below the 81,920 Qwen recommends for competition maths.

Write-up: https://think-graft.vercel.app Code and all logs: https://github.com/nextgen-user/think-graft Model (GGUF): https://huggingface.co/vaibhavrpi/Qwen3.5-4B-think-graft-GGUF

[edit]

Based on community feedback,
I am running the following technique on qwen3 0.8B on the full 3 benchmarks - just like rikiyaT did for the weight space programming .
Same config and seed.(but only 1 sample / 4 for faster results)
For this I Prepared another graft for qwen3 0.8B on another set (not taken from benchmark) of 80 separate MATH-training problems - should automatically transfer to other domains as well based on my observations.
Above is the interim result and how it compares to rikiyaT's weight space edited qwen model.

![img](pkalap6m6z1i1 "the best part is that it matches and even exceeds the weight edited qwen till now and the graft works on large models as well (weight editing on deepseek failed to stop overthinking for me)")

5 Upvotes

4 comments sorted by

6

u/jake_1001001 10d ago

This is not enough evaluations to tell me anything about if your method is actually working.

  1. How do you know this is beyond sampling/serving configuration noise? The results in your few examples can be a simple re-draw or you developed on the same serving configuration as you evaluated on. What is the p-value?
  2. Dataset bias, if you fitted your probe to the same sets you validated, there will be bias. I have found GPQA and AIME show entirely different thinking internals. For example AIME works on a lower avg. entropy compared with GPQA. Also, with logit lens we see AIME intermediate layers propose termination like tokens (example. therefore or paragraph breaks) and GPQA is more continuation like tokens (like 'wait'). GPQA appears to wanders more than it loops compared with AIME. How did you pick these problems, i have concerns they are cherry picked. Why not test with whole BeyondAIME, AIME2024, AIME2026, etc if unseen.
  3. Have you tried cheap methods like repetition or presence penalty? These can be effective for stopping thinking loops. I would want to see penalty strengths calibrated with your probing 'training' sets. Again over a much larger set of problems and serving configurations (example batch size, Tensor Parrallel)

I mean this in a constructive way to improve your analysis and tell me if this is woking at all, and quite frankly is missing in a vast majority of top conference papers and wastes other researchers time failing to reproduce works, especially if there are cheaper and just as effective methods available. Keep it up though, this is a problem i have worked on in academia, and it would benefit from more understanding how to prevent or recover overthinking.

1

u/Good-Presentation-23 10d ago

Yes , i have not tested repetition or presence penalty .. I did test against different levels of thinking though. Will test now.. However , I did not cherry pick the problems - problems were selected randomly from each domain on AIME. Why? Simply because I could conclude the results by the few problems and I was short on time. I have run 10-20 problems(mixed,not just aime) on both deepseek , and qwen (1 sample - both unedited and graft edited ) and on almost all of the problems thinking has been reduced by 50% or more with the same correct answers

But you are absolutely correct so I am running the entire set on qwen 3 0.8B and the fitting done on a set of problems different from the benchmark. Also running a set with high presence penalty.

The two sided p-value as per the wilcoxon test was 0.0078

3

u/jake_1001001 10d ago

Ok, thank you for considering expanding your evaluation. I have started working on reasoning research a few months ago and current research is tremendously lacking in quality, so Im sorry, but I got triggered by your post.

Another note, on cheap loop signals used to terminate thinking

  1. simple n-gram (usually 8-gram is enough) repatitions over a large enough token window can catch a lot of loops
  2. Loops cause the following behavior: Entropy drops to near zero and cossim between steps hidden states approaches 1. With a simple threshold and token window, loops can also be detected cheaply. What is the precision and recall here comparing your classifier vs more simple ones?

For intervention, did you check sampling? Sampling is very good at preventing loops. Don't use pass@K, use expectation or avg@K and K should be large, like 8, some papers use 16 or 32, and you would have to beat the expectation.

As with too high of presence penalty strength, these can sometimes not always translate terminating thinking traces into improved accuracy. Presence penalty of 2.0 (max) may hurt and you may see 0.5, 1.0, or 1.5 close loops but not hurt accuracy.

With these boxed score verifiers, they can also parse correct scores from non-terminating thinking traces. Also, you method could also close traces prematurely, loosing out on correct samples that would have otherwised finished.

I understand this is a lot, but there are 1000s of methods out there, and you need to convince others that it is worth a serious look. Showing your method works on a very few sampled problems on select benchmarks doesn't tell me anything and not accounting for other confounders like batch size, sampling, etc. Be aware that in non-batch-invarient serving stacks, closing a trace early will affect other thinking traces in the same batch and will add to your valudation noise.

1

u/Good-Presentation-23 11d ago

This is similar to the recently trending post: "Sparks of Weight-Space Programming" and its counter argument that a linear program can do equivalently well:
https://nathan.rs/posts/weight-space-lp/
(both are linear, training-free edit fitted from the model's own traces)

However, unlike that edit, which nudges the model by the same amount per token (pushing away from looping), this one is opposite : state-dependent and firing only when the model's state says the answer is settled.(early stopping)