Qwen3-4B with Ministral-3B-R, blue is the text ThinkFuse took from the auxiliary model. The project page replays it live.
News
- [2026-10-06] The paper is on arXiv.
- [2026-10-04] Code released. The paper is accepted to Findings of EMNLP 2026.
Overview
Small reasoning models solve hard problems by writing long chains of thought, but they rarely recover once the reasoning takes a wrong turn. Test-time fusion lets a second model step in. Existing fusion methods decide when to step in from local signals, so a brief fluctuation in uncertainty can trigger a fusion that overwrites a sound trajectory.
ThinkFuse is a training-free test-time fusion framework that intervenes only in unreliable reasoning segments. It rests on three parts.
- Segment-level uncertainty. Every
T tokens, ThinkFuse reads the top-k log-probabilities of the primary model, turns each position into a normalized entropy, and aggregates the segment with Exponentially Weighted Causal Aggregation (EWCA), which weights later tokens more and carries the uncertainty accumulated by earlier ones.
- Adaptive threshold with a soft budget. The segment uncertainty is compared with a threshold built from an exponential moving average of the trajectory's own mean and deviation. The threshold rises quadratically with the cumulative fusion ratio, which keeps fusion sparse.
- Trajectory compatibility scoring. When the threshold is reached, the auxiliary model writes an alternative segment. The primary model scores both candidates by perplexity under the current context, and the lower one is appended. No reward model is used.
Monitoring and fusion run only while the model is thinking. Once </think> is written, the primary model finishes the answer alone.
With Qwen3-4B as the primary model and Ministral-3B-R as the auxiliary, ThinkFuse improves over standalone Qwen3-4B on all five benchmarks, by 20.0 points on AIME24 and 10.6 on GPQA. On the same pair, Cool-Fusion falls below the standalone model on all five benchmarks and AdaFuse on four.
What it does in one picture
ThinkFuse monitors the segment-level uncertainty of the primary model MP with an adaptive threshold θ. When the uncertainty reaches the threshold, the auxiliary model MA writes an alternative segment, both candidates are scored by the perplexity of MP, and the more compatible one joins the context.
Quick start
pip install "git+https://github.com/js-lee-AI/ThinkFuse.git"
import math
from thinkfuse import AdaptiveThreshold, UncertaintyCalculator
def segment(p_top, length=8, k=5): # 8 tokens, each with its top-5 log-probabilities
rest = (1.0 - p_top) / (k - 1)
return [{i: math.log(p) for i, p in enumerate([p_top] + [rest] * (k - 1))}] * length
calc, threshold = UncertaintyCalculator(), AdaptiveThreshold()
for name, p_top in [("confident", 0.90), ("uncertain", 0.30)]:
u, _ = calc.compute(segment(p_top)) # EWCA over the normalized token entropies
theta = threshold.get_threshold(fusion_ratio=0.0)
print(f"{name:9s} U {u:.2f} theta {theta:.2f} fuse {u >= theta}")
print(f"theta after fusing 10% of the segments {threshold.get_threshold(fusion_ratio=0.1):.2f}")
# confident U 0.29 theta 0.60 fuse False
# uncertain U 0.98 theta 0.60 fuse True
# theta after fusing 10% of the segments 0.90
A segment whose tokens are confident stays under the threshold and the primary model continues alone. A segment with flat token distributions reaches it and triggers fusion. Each fusion raises the threshold for the segments that follow.
This runs on a CPU in well under a second and downloads nothing. The full loop with two mock models is example.py, and CI runs it on every push.
git clone https://github.com/js-lee-AI/ThinkFuse.git && cd ThinkFuse
pip install -e ".[test]"
python example.py
| install |
adds |
enough for |
pip install "git+https://github.com/js-lee-AI/ThinkFuse.git" |
numpy |
the whole library and the mock client |
git clone and then pip install -e ".[test]" |
pytest |
example.py and tests/ |
Usage
Run the fusion loop
from thinkfuse import MockModelClient, ThinkFuse
primary = MockModelClient("qwen3-4b", script="<think> ... </think> answer")
auxiliary = MockModelClient("ministral-3b-reasoning")
engine = ThinkFuse(primary, auxiliary, preview_tokens=8)
result = engine.run("Question: ...\nAnswer:")
print(result.text)
print(result.total_segments, result.fused_segments, result.fusion_ratio)
MockModelClient is deterministic and needs no model weights, so the loop can be read and tested on a laptop. total_segments counts the segments monitored during the thinking phase, and fused_segments the ones where the auxiliary model was called.
Connect your own models
Implement ModelClient for your backend. The engine needs token-level generation with top-k log-probabilities and a perplexity call.
from thinkfuse import ModelClient
class MyClient(ModelClient):
name = "qwen3-4b"
def encode(self, text): ...
def decode(self, ids, skip_special=True): ...
def batch_decode(self, id_lists): ...
def generate(self, context_ids, n_tokens, top_k): ... # -> (new_ids, eos, token_logprobs)
def perplexity(self, context_ids, segment_text): ... # -> float
A typical implementation wraps a vLLM or Transformers server. generate requests n_tokens with logprobs=top_k and returns one dictionary of log-probabilities for each new token. perplexity scores a candidate continuation against the current context.
API at a glance
| call |
what it does |
ThinkFuse(primary, auxiliary, ...).run(prompt) |
the segment loop, returning FusionResult(text, total_segments, fused_segments, fusion_ratio) |
UncertaintyCalculator(...).compute(segment_logprobs) |
segment uncertainty by EWCA and the token uncertainties behind it |
AdaptiveThreshold(...).get_threshold(fusion_ratio) |
the threshold from the running mean, deviation and fusion ratio |
AdaptiveThreshold.should_fuse(u, fusion_ratio), .update(u) |
the trigger, and the moving-average update after each segment |
SoftFusionBudget() |
the cumulative fusion ratio |
select_aligned_prefix(base, others, new_token_ids, mode) |
the prefix of a segment that decodes identically under both tokenizers |
select_by_primary_ppl(client, context_ids, candidates) |
the candidate with the lowest primary-model perplexity |
normalize_think_tags, adapt_think_tags_for_model, PhaseDetector |
reasoning-tag normalization and the thinking or answer phase |
ModelClient, MockModelClient |
the backend interface and an offline mock |
Everything imports with NumPy alone.
Default hyperparameters
The defaults of ThinkFuse(...) are the settings of the paper.
| Parameter |
Symbol |
Argument |
Value |
| Segment length |
T |
preview_tokens |
8 |
| Top-k log-probabilities |
r |
top_k |
5 |
| EWCA position weight |
α |
ewca_alpha |
0.1 |
| EWCA accumulation |
β |
ewca_beta |
0.5 |
| Moving-average rate |
η |
ema_eta |
0.05 |
| Deviation margin |
τ |
tau |
1.0 |
| Soft-budget coefficient |
λ |
budget_lambda |
50 |
| Initial mean |
μ0 |
init_mu |
0.5 |
| Initial deviation |
σ0 |
init_sigma |
0.1 |
| Uncertainty signal |
|
uncertainty_method |
"entropy" |
Fusion is triggered when Uk ≥ θk, with θk = (μk−1 + τ σk−1)(1 + λ Rk−12) and R the share of monitored segments that were fused so far.
Results
Cool-Fusion fuses the most auxiliary tokens on every benchmark and ends with the shortest thinking stage on four of the five. ThinkFuse fuses far fewer auxiliary tokens, and on AIME24 it keeps the longest thinking stage of the three fusion methods.
Figure 2 of the paper. Top, average fused auxiliary tokens in log scale. Bottom, average thinking-stage tokens. All fusion configurations use Qwen3-4B as the primary model and Ministral-3B-R as the auxiliary model.
Main results (paper Table 2)
Accuracy (%) under a 16K-token budget. Parentheses give the difference from the standalone primary model in percentage points.
| Method |
MATH-500 |
GSM8K |
AIME24 |
GPQA |
NQ-Open |
| Standalone models |
|
|
|
|
|
| Qwen3-4B |
89.0 |
92.0 |
53.3 |
54.0 |
29.5 |
| Qwen3-1.7B‡ |
83.0 |
90.0 |
33.3 |
39.4 |
28.0 |
| Ministral-3B-R |
32.5 |
67.0 |
0.0† |
25.8 |
24.0 |
| EXAONE-4.0-1.2B |
57.0 |
85.0 |
3.3† |
38.9 |
22.0 |
| Test-time compute baseline, Qwen3-4B |
|
|
|
|
|
| Self-consistency (K=3) |
89.5 (+0.5) |
94.5 (+2.5) |
53.3 (+0.0) |
51.0 (−3.0) |
39.0 (+9.5) |
| Self-consistency (K=5) |
88.0 (−1.0) |
94.5 (+2.5) |
53.3 (+0.0) |
50.0 (−4.0) |
39.0 (+9.5) |
| Test-time fusion baselines, Qwen3-4B × Ministral-3B-R |
|
|
|
|
|
| Cool-Fusion |
31.0 (−58.0) |
66.0 (−26.0) |
0.0† (−53.3) |
11.6 (−42.4) |
0.5 (−29.0) |
| AdaFuse |
45.5 (−43.5) |
72.6 (−19.4) |
33.3 (−20.0) |
28.8 (−25.2) |
38.5 (+9.0) |
| ThinkFuse |
|
|
|
|
|
| Qwen3-4B × Ministral-3B-R |
90.0 (+1.0) |
96.9 (+4.9) |
73.3 (+20.0) |
64.6 (+10.6) |
39.5 (+10.0) |
| Qwen3-4B × Qwen3-1.7B |
91.0 (+2.0) |
94.0 (+2.0) |
70.0 (+16.7) |
55.1 (+1.1) |
37.0 (+7.5) |
| Qwen3-4B × Qwen3-4B |
75.0 (−14.0) |
90.0 (−2.0) |
40.0 (−13.3) |
28.3 (−25.7) |
38.0 (+8.5) |
| Qwen3-1.7B × EXAONE-4.0-1.2B |
85.0 (+2.0) |
90.5 (+0.5) |
30.0 (−3.3) |
53.5 (+14.1) |
28.0 (+0.0) |
† AIME24 results affected by length-limit or final-answer truncation. ‡ Standalone Qwen3-1.7B is evaluated with the Qwen3 recommended top-k of 20, and all other rows share one decoding setting.
Additional model pairs (paper Table 9)
| Method |
MATH-500 |
GSM8K |
AIME24 |
GPQA |
NQ-Open |
| Qwen3-4B |
89.0 |
92.0 |
53.3 |
54.0 |
29.5 |
| EXAONE-Deep-2.4B |
83.5 |
90.5 |
43.3 |
57.1 |
17.5 |
| DeepSeek-R1-Distill-Qwen-1.5B |
13.0 |
30.5 |
0.0† |
21.2 |
14.5 |
| ThinkFuse, Qwen3-4B × EXAONE-Deep-2.4B |
91.0 (+2.0) |
99.0 (+7.0) |
73.3 (+20.0) |
55.1 (+1.1) |
38.5 (+9.0) |