Learning How Hard to Think: Input-Adaptive Allocation of LM Computation

Mehul Damani, Idan Shenfeld, Andi Peng, Andreea Bobu, Jacob Andreas · DOI

Introduction

Large Language Models (LLMs) typically process every query with a uniform amount of computational effort. Whether a user asks for a simple greeting or a complex mathematical proof, the model consumes the same resources. However, techniques that improve performance—such as generating multiple samples (best-of-$k$), tree-of-thought searching, or self-critique—are computationally expensive. Applying these methods indiscriminately is inefficient; simple queries don't need them, and impossible queries won't benefit from them.

The core concept of input-adaptive computation: identifying 'hard-but-solvable' queries to optimize resource allocation.

This paper introduces a framework for Input-Adaptive Allocation, which identifies "hard-but-solvable" queries before generation begins. By predicting which queries will benefit most from additional computation, the system can cut compute costs by up to 50% while maintaining or even improving output quality.

Methodology

The proposed framework operates in two distinct stages: Difficulty Estimation and Computation Allocation.

The two-step workflow: first estimating marginal rewards for different compute levels, then greedily allocating the budget across a batch of queries.

1. Difficulty Estimation

Rather than a binary "hard" or "easy" classification, the system trains a lightweight "difficulty model"—either a small MLP probe or a LoRA fine-tune—on the base LM’s internal hidden states. This model predicts the marginal reward: the expected improvement in answer quality for each additional unit of computation.

2. Computation Allocation

With predictions in hand for a batch of queries, a greedy algorithm distributes the total compute budget. Resources are allocated to queries with the highest predicted "return on investment" (ROI) until the budget is exhausted. This ensures that extra "thinking time" is spent where it is most likely to yield a correct or better answer.

The framework was evaluated in two primary settings:

  • Adaptive Best-of-$k$: Dynamically determining the number of samples to generate for a reranker.
  • Model Routing: Deciding whether to route a query to a small, efficient model (e.g., Gemma-2B) or a larger, more capable one (e.g., Gemma-7B).

Experimental Setup and Datasets

The researchers evaluated the framework across four diverse domains to ensure broad applicability:

  • Code Generation: Using a subset of the TACO dataset for algorithmic problems.
  • Mathematical Reasoning: Utilizing the Numina-COT dataset.
  • General Chat: Testing on real-world user interactions from LMSYS-Chat.
  • Safety and Routing: Evaluating on the "harmless" subset of the Anthropic HH dataset.

Key Insights

  • Internal Signals of Difficulty: LLMs exhibit internal awareness of a problem's difficulty early in the processing stage. Hidden states contain sufficient information for a simple MLP to accurately predict the necessary compute.
  • The Efficiency of the "Middle Ground": The highest utility for extra computation is found in moderately complex tasks. Easy tasks are solved with minimal effort, while truly impossible tasks remain unsolved regardless of the budget.
  • Regularization via Binning: In high-budget scenarios, grouping queries into difficulty "bins" (offline allocation) proved more robust than pure online greedy allocation, preventing the system from over-allocating to single, deceptively difficult queries.

Results

The adaptive approach consistently outperformed uniform allocation strategies:

  • Resource Efficiency: On Math and Code tasks, the system achieved the same success rates as standard best-of-$k$ while reducing total computation by 50%.
  • Performance Gains: At a fixed budget, the adaptive method improved response quality by up to 10%.
  • Effective Routing: The system matched the performance of a 7B model while routing 25–50% of queries to a much smaller 2B model.
  • High Predictive Accuracy: The difficulty predictors achieved over 70% accuracy in identifying queries that required more than median effort.

Conclusion and Future Directions

While highly effective, the current framework has limitations. The Math experiments relied on an "oracle verifier" for training, suggesting a need for more robust, automated reward models in production. Additionally, future work should focus on making these predictors robust against out-of-distribution or adversarial inputs. Bridging the "Oracle Gap"—the difference between current predictors and a theoretical perfect difficulty estimator—remains a key challenge for maximizing LLM efficiency.

Summary updated

BibTeX
@inproceedings{damani2025learning,
  author = {Mehul Damani and Idan Shenfeld and Andi Peng and Andreea Bobu and Jacob Andreas},
  title = {{Learning How Hard to Think: Input-Adaptive Allocation of LM Computation}},
  booktitle = {International Conference on Learning Representations},
  year = {2025},
  url = {https://openreview.net/forum?id=6qUUgw9bAZ},
}
Figure