Think Right: Learning Adaptive Reasoning Allocation
This work addresses overthinking and underthinking in reasoning models through difficulty-adaptive budget allocation. By learning which problems need extensive reasoning versus quick answers, models achieve both efficiency gains (36.8% length reduction) and accuracy improvements (8.4%).
Core Architecture
- Difficulty estimation: Attention-based features predict task complexity
- Adaptive compression: Prune unnecessary reasoning steps based on estimated difficulty
- Reward structure: Bonus for efficiency on easy problems, bonus for accuracy on hard problems
- Attention-guided selection: Use self-attention patterns to identify important reasoning steps
Implementation Steps
Setup difficulty-adaptive reasoning allocation system:
# Initialize TRAAC (Task-Difficulty-Responsive Adaptive Compression)
from traac import AdaptiveReasoningModel, DifficultyEstimator
difficulty_estimator = DifficultyEstimator(
features=["token_uncertainty", "attention_entropy", "problem_type"],
num_difficulty_tiers=3 # easy, medium, hard
)
adapter = AdaptiveReasoningModel(
base_model=your_reasoning_llm,
difficulty_estimator=difficulty_estimator,
compression_strategy="attention_guided"
)
# Configure per-tier reasoning budgets
budget_config = {
"easy": {"max_thinking_length": 200, "compression_ratio": 0.7},
"medium": {"max_thinking_length": 500, "compression_ratio": 0.5},
"hard": {"max_thinking_length": 1000, "compression_ratio": 0.3}
}
Execute RL training with difficulty-aware rewards:
# Training loop with adaptive budget allocation
for step, batch in enumerate(training_dataloader):
problems = batch["problem"]
ground_truth = batch["solution"]
# Stage 1: Generate reasoning with full budget
reasoning_full = model.generate_reasoning(
problem=problems,
max_length=1000,
temperature=0.7
)
# Stage 2: Estimate difficulty from reasoning
difficulty_scores = difficulty_estimator.estimate(
reasoning=reasoning_full,
problem=problems
)
difficulty_tiers = torch.argmax(difficulty_scores, dim=1) # 0=easy, 1=med, 2=hard
# Stage 3: Adaptive compression by difficulty tier
compressed_reasoning = []
for i, (reasoning, tier) in enumerate(zip(reasoning_full, difficulty_tiers)):
budget = budget_config[["easy", "medium", "hard"][tier]]
compressed = adapter.compress(
reasoning=reasoning,
target_length=int(len(reasoning) * (1 - budget["compression_ratio"])),
important_tokens_selector="attention_guided"
)
compressed_reasoning.append(compressed)
# Stage 4: Generate answers from compressed reasoning
predictions = model.generate_answer(
problem=problems,
reasoning=compressed_reasoning,
temperature=0.5
)
# Stage 5: Compute difficulty-aware rewards
rewards = []
for i, (pred, truth, tier) in enumerate(zip(predictions, ground_truth, difficulty_tiers)):
is_correct = verify_answer(pred, truth)
if tier == 0: # easy problem
# Bonus for efficiency
reasoning_length = len(compressed_reasoning[i])
efficiency_bonus = max(0, 1.0 - (reasoning_length / 200.0))
reward = (1.0 if is_correct else 0.0) + 0.2 * efficiency_bonus
elif tier == 1: # medium problem
# Balanced reward
reward = 1.0 if is_correct else 0.0
else: # hard problem
# Bonus for accuracy
reward = 1.2 if is_correct else -0.1
rewards.append(reward)
rewards = torch.tensor(rewards)
# Stage 6: RLVR update
loss = adapter.compute_rl_loss(
reasoning_lengths=[len(r) for r in compressed_reasoning],
answers=predictions,
rewards=rewards,
kl_coefficient=0.05
)
loss.backward()
optimizer.step()
optimizer.zero_grad()
Practical Guidance
When to use adaptive reasoning allocation:
- Mixed-difficulty problem sets where some problems need extensive reasoning
- Cost-sensitive deployments where efficiency matters
- Scenarios where model calibration affects user experience
- Tasks with clear difficulty variation (math, logic, reading comprehension)
When NOT to use:
- Uniform difficulty problems (fixed budget more efficient)
- Tasks where difficulty estimation is unreliable
- Real-time systems requiring sub-millisecond overhead (estimation adds latency)
- Domains without clear correctness verification
Hyperparameters:
- Num difficulty tiers (3): Test 2 tiers (easy/hard) for faster decision; 4 tiers for finer control
- Easy tier budget (200 tokens): Adjust based on problem complexity; reduce to 100 for very simple domains
- Medium tier budget (500 tokens): Standard setting; test 400-600 range
- Hard tier budget (1000 tokens): Increase to 1500 for extremely complex problems
- Efficiency bonus weight (0.2): Adjust tradeoff between accuracy and efficiency
- Hard tier penalty (-0.1): Penalize incorrect answers on hard problems to discourage guessing
Compression Strategy
Attention-guided selection preserves important reasoning:
- Identify: High-attention tokens in self-attention patterns
- Rank: Weight tokens by attention strength and position
- Prune: Remove low-ranked tokens up to compression target
- Preserve: Maintain final answer and key decision points
Performance Results
Across mathematical reasoning benchmarks:
- Length reduction: 36.8% fewer tokens in thinking traces
- Accuracy improvement: +8.4% on AIME dataset
- Out-of-distribution transfer: +3% on GPQA-D, BBEH (unseen problem types)
- Generalization: Works across problem families when trained on specific domain
Difficulty Estimation Features
The model learns to estimate difficulty using:
- Token uncertainty: Entropy of token prediction logits
- Attention entropy: Sharpness of attention weight distributions
- Problem type: Recognizing mathematical structure, domain signals
- Token patterns: Keywords and structural elements predictive of complexity
Architecture Notes
Key insight: "Overthinking on easy problems wastes tokens; underthinking on hard problems misses solutions." Adaptive allocation addresses both extremes by learning per-problem appropriate reasoning depth.
Computational Overhead
- Difficulty estimation: <5% overhead vs. base model
- Compression: <2% overhead (attention-guided selection is efficient)
- Total latency increase: ~3-5% despite potential accuracy improvements
References
Builds on dynamic inference, early-exit networks, and difficulty-aware curriculum learning.