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

## Abstract

Abstract Computationally intensive decoding procedures—including search, reranking, and self-critique—can improve the quality of language model (LM) outputs in problems spanning code generation, numerical reasoning, and dialog.
Existing work typically applies the same decoding procedure for every input to an LM. But not all inputs require the same amount of computation to process.
Can we allocate decoding computation adaptively , using more resources to answer questions whose answers will be harder to compute?
We present an approach that
predicts the distribution of rewards given an input and computation budget, then allocates additional computation to inputs for which it is predicted to be most useful.
We apply this approach in two decoding procedures: first, an adaptive best-of- k 𝑘 k italic_k procedure that dynamically selects the number of samples to generate as input to a reranker; second, a routing procedure that dynamically responds to a query using a decoding procedure that is expensive but accurate, or one that is cheaper but less capable.
Across a suite of programming, mathematics, and dialog tasks, we show that accurate computation-allocation procedures can be learned, and
reduce computation by up to 50% at no cost to response quality, or improve quality by up to 10% at a fixed computational budget.

## 1 Introduction

Figure: Figure 1: Overview of our approach. Given a set of input queries to a language model, we train a lightweight model to estimate the difficulty of these queries (more precisely, a model that estimates how much each query would benefit from a more computationally intensive decoding procedure.) We then allocate extra computation to those queries for which it would be most beneficial.
Refer to caption: x1.png

Recent improvements in language models (LMs) have dramatically enhanced their ability to tackle complex tasks in mathematics, coding, and reasoning.
However, as with natural and artificial intelligent agents of all kinds (Silver et al., ), LMs cannot solve all problems on the first try: they benefit from the ability to perform search (Yao et al., ), sampling (Brown et al., ), or more sophisticated decoding procedures like chain-of-thought (Wei et al., ) and self-critique (Wang et al., ).

Importantly, computationally intensive problem *domains*
may exhibit considerable variation in the difficulty of individual problem *instances*: not all problems are equally hard to solve.
For example, even a novice programmer can likely write code to to test if an integer is even. Balancing a binary tree might require multiple attempts, and finding a polynomial-time set cover algorithm is likely impossible, and not be worth attempting at all.
Maximally efficient use of computational resources thus requires identifying, a priori, the inputs for which additional computation will improve outputs.
In LMs, recent work has shown
that significant gains from adaptive choice of decoding procedures are theoretically achievable (Snell et al., ). However, past work has relied on measures of problem difficulty that could only be estimated *a posteriori*, using a sampling procedure significantly more expensive than the one used to generate model outputs.

In this paper, we show that it is possible to perform inference-time scaling of computation *before* responding to a set of user queries, by predicting how much computation will be required to respond successfully to each query, and allocating resources accordingly (Fig. 1).
Our approach has two parts.
First, we describe how to train a difficulty model that estimates the marginal improvement in response quality that would result from allocating an additional unit of computing power when responding to a query.
We show that effective difficulty models can be constructed by training lightweight “probes” on top of a pre-trained LM’s hidden representations, suggesting that LMs may already learn to encode problem difficulty as a result of pre-training.
Second, we describe an efficient allocation algorithm that, given a collection of queries and a computation budget, uses predictions from the difficulty model to allocate computation to individual queries.
We show how to perform this optimization online (exactly satisfying the budget for a batch of queries) or offline (computing a fixed mapping from queries to compute allocations so that constraints are satisfied on average).

This approach is flexible with regard to the choice of compute-scaling procedure, and we demonstrate its effectiveness with two different inference procedures.
In best-of-k experiments, we choose how many samples to generate from an LM before re-ranking with a reward model.
In routing experiments, we choose whether to respond to queries using a
computationally expensive but capable decoding procedure, or a less powerful but more cost-effective decoder.
For the best-of-$k$ setting, we present results across $3$ domains: Math, Code and Chat.
Adaptive sampling outperforms non-adaptive strategies on all three domains across a range of possible compute budgets.
On Math and Code, we achieve the same performance as non-adaptive methods using up to 50% less compute; on Chat, we are able to match reward using up to 10% less compute than base models.
For routing, we experiment with both a pair of models (Gemma-2B, Gemma-7B) and a pair of decoding procedures (ordinary sampling and value-augmented sampling; Han et al., ). In both cases, we match the performance of the more expensive decoder while calling it only 50–75% of the time.

In summary, this work presents
(1) a generally applicable framework for adaptively scaling test-time LM computation;
(2) a learned model for estimating the marginal benefit of additional computation in LM decoding;
(3) an efficient algorithm for allocating computation to queries; and
(4) experiments demonstrating significant improvements in LM efficiency and output quality.

## 2 Preliminaries

Suppose we have an LM-based agent that will interact with a large number of users in parallel. At any moment, each of a set of users has issued a query $x_{i}$, for which we wish to produce a response $y_{i}$. We have acccess to both a language model (LMs) $p(y\mid x)$, capable of generating candidate responses, as well as a reward model $r(x,y)$ capable of assessing the quality of candidate responses. In the absence of any computational constraints, we might wish to find the best response to every user query by optimizing
$\operatorname*{arg\,max}_{y}r(x_{i},y)$
independently for each query $x_{i}$.

In practice, however, we generally do not have the ability to perform exhaustive search over candidate responses $y$. Instead, we use a decoding procedure $f(x,b)$ that (stochastically) generates a response $y$ subject to some constrained computation budget $b$. (In general, increasing the budget to a query should increase the quality of the response.) Many such decoding procedures are in wide use; our experiments will focus on two of the most widely used.

In best-of-k, we generate a finite number of samples, then rerank them:

$$ $f(x,b)=\operatorname*{arg\,max}_{y_{i}\in\{y_{1},\ldots,y_{b}\}\sim p(\cdot \mid x)}r(x,y_{i})~{}.$ (1) $$

In routing, we have access to a strong but expensive decoding scheme $p^{S}$ (which could involve search, reasoning, or even just a larger model). For every query we can either use this decoding scheme or to fall back to a weak but cheaper decoding scheme $p^{W}$ (e.g. ordinary decoding or a smaller model). Then:

$$ $f(x,b)=\begin{cases}y\sim p^{W}(\cdot\mid x)&\textrm{if }b=b^{W}\\ y\sim p^{S\ \,}(\cdot\mid x)&\textrm{if }b=b^{S}\end{cases}~{}.$ (2) $$

Here $b^{W}$ and $b^{S}$ denote the cost of calling the weak and strong decoders respectively.
Decoding procedures including consensus (Jacob et al., ), chain-of-thought (Wei et al., ), self-critique (Luo et al., ) and debate (Du et al., ) may all be expressed in this form, with the budget $b$ controlling the number of generated samples, tokens, or rounds of revision.

In current practice, it is typical to set a *fixed* budget $B$, and allocate this uniformly for all queries—returning $y_{i}\sim f(x_{i},B)$ for each $x_{i}$. In this case, the expected reward for a set of queries is simply:

$$ $\sum_{i}\mathbb{E}_{y_{i}\sim f(x_{i},B)}[r(x_{i},y_{i})]$ (3) $$

But as noted in Section 1, different $x_{i}$ may in practice benefit differentially from increased budgets.
In this paper, we consider a more flexible version of the problem—if we are willing to set a fixed *average* computational cost per query, can we improve overall accuracy by allocating this computation adaptively?
In this case, responding to a collection of queries $\{x_{1},\ldots,x_{n}\}$ corresponds to solving:

$$ $\max_{b_{1},\ldots,b_{n}}\quad{\sum_{i}\mathbb{E}_{y_{i}\sim f(x_{i},b_{i})}[r (x_{i},y_{i})}]\quad\text{s.t.}\quad\sum_{i}b_{i}\leq B\cdot n$ (4) $$

Below, we develop a method for solving this adaptive comptuation scaling problem efficiently.

## 3 Method

In Eq. 4, we would like to allocate computation $b_{i}$ to queries $x_{i}$ to maximize expected reward, which we will denote
$q(x_{i},b_{i})=\mathbb{E}_{y_{i}\sim f(x_{i},b_{i})}[r(x_{i},y_{i})]$. But there is a problem: without querying the LM, we cannot know the value of $q(x_{i},b_{i})$ for some new $x_{i}$. To make matters worse, Monte Carlo estimation of $q(x_{i},b_{i})$ (as in Snell et al., ) may in general require more computation (e.g. more LM samples) than we eventually wish to allocate to $x_{i}$! To efficiently allocate computation, we need some way to *predict* $q(x_{i},b_{i})$ from $x_{i}$ alone, and then use these predictions to solve Eq. 4.

When estimating problem difficulty and allocating decoding budget, it will be useful to reason about the benefits of *incremental* changes in compute budgets.
Formally, let us define the marginal reward $\Delta_{ij}=q(x_{i},j)-q(x_{i},j-1)$ (with $\Delta(\cdot,0)=0$). Under this definition, $q(x_{i},b_{i})=\sum_{j=1}^{b_{i}}\Delta_{ij}$; intuitively, $\Delta_{ij}$ represents the expected gain from allocating one more “unit” of computation to $x_{i}$, given that we have already allocated $j-1$ units.
We may then re-write Eq. 4 as:

$$ $\displaystyle\begin{split}\max\quad&\sum_{i=1}^{n}\sum_{j=0}^{B_{\mathrm{max}} }c_{ij}\Delta_{ij}\quad\text{s.t.}\quad\sum_{i,j}c_{ij}\leq B\cdot n~{};\quad c _{ij}\leq c_{i,j-1}~{}\forall i,j\end{split}$ (5) $$

Here we have introduced auxiliary variables $c_{ij}\in\{0,1\}$ to represent budget increments: intuitively, setting $c_{ij}=1$ means we have allocated a $j$th unit of computation to $x_{i}$, and constraints enforce that these units are allocated in sequence, as shown in Figure 2. To determine how to allocate decoding computation across a set of queries $x_{i}$, it then suffices to predict the value of each term $\Delta_{ij}$ and then solve Eq. 5 to obtain $c$. Each of these steps is described in more detail below.

### 3.1 Estimating Problem Difficulty by Predicting Marginal Rewards

Given a training set of queries $x_{i}$, we collect empirical estimates of $\Delta_{ij}$ by decoding from $f(x,b)$ at values of $b$ up to some $B_{\mathrm{max}}$.
We then train a model $\hat{\mathbf{\Delta}}(x_{i};\theta)$ that predicts a vector of marginal rewards for all budgets $j$ simultaneously
by optimizing the mean squared error:

$$ $\operatorname*{arg\,min}_{\theta}~{}\sum_{x_{i},\Delta_{i}}~{}\|\mathbf{\Delta }_{i}-\hat{\mathbf{\Delta}}(x_{i};\theta)\|_{2}^{2}$ (6) $$

where $\mathbf{\Delta}_{i}=[\Delta_{i1},\ldots,\Delta_{iB_{\mathrm{max}}}]$ is the vector of empirical marginal rewards for the query $x_{i}$. While training this model requires sampling from the LM at many budgets to obtain supervision, it can be called during inference without generating any outputs at all.

We explore two simple parameterizations of $\hat{\mathbf{\Delta}}$: (1) a two-layer MLP that takes last the hidden state of the base LM $p$ (obtained by encoding the query) as input, and (2) parameter-efficient fine-tuning of the base LM with LoRA (Hu et al., ).
During inference, the MLP variant adds extremely little overhead as its input are hidden states that are already computed as part of decoding procedure.
The LoRA variant is slightly more expensive; however, its overhead is also negligible, as the primary bottleneck during inference occurs when decoding outputs rather than encoding queries.

### 3.2 Allocating Computation

Figure: Figure 2: Method overview. In the first step, the marginal reward predictor is used to estimate the marginal reward gains for a batch of queries. In the second step, the allocation algorithm uses these predictions to assign compute budgets to individual queries. The simple query what is your name? is allocated a budget of $1$, while the harder query balance a binary tree is allocated a budget of $2$.
Refer to caption: x2.png

Eq. 5 is an integer linear program, but in fact has a very special form that allows it to be solved in $O(B_{\mathrm{max}}\cdot n)$ time using a greedy algorithm that incrementally “turns on” $c_{ij}$ for which $\Delta_{ij}$ is largest. (Formally, the feasible sets of $c_{ij}$ form a matroid, Edmonds, , so this greedy procedure is guaranteed to find an optimum.) We exploit this property in two ways:

Online allocation: If queries $\{x_{i}\}$ are known *a priori*,
we simply replace each $\Delta_{ij}$ in Eq. 5 with the corresponding estimate from $\hat{\mathbf{\Delta}}(x_{i};\theta)$, solve for $c_{ij}$, then finally set each $b_{i}=\max_{j}c_{ij}$.

One drawback of this procedure is that responses must be processed in a batch. However, in some cases it is also possible to effectively set budgets independently for each $x_{i}$:

Offline allocation:
If allocations must be made without access to a full batch of samples, we construct a fixed allocation policy as follows:

(1) Hold out a subset of the data used for training the reward estimator $\hat{\mathbf{\Delta}}$, then use it to label queries in this held-out set (e.g. based on the first-sample prediction $\hat{\Delta}(x_{i})_{1}$). Divide these queries into a fixed set of bins according to their predicted marginal rewards.

(2) Solve the allocation problem for this held-out as in Eq. 5, with the additional constraint that all queries in a bin receive the same budget allocation.
For each bin, store the assigned budget.

(3) During deployment, compute a reward prediction for each $x_{i}$, map it to a bin, and return the budget associated with that bin.

During deployment, all queries can be processed independently
(at the risk of a budget violation if the distribution of queries is significantly different from those used to compute the allocation policy).

### 3.3 Interesting Special Cases

Binary Reward + Best-of-k:
In domains such as coding and math, rewards are often binary, indicating success or failure.
For instance, an outcome reward model can be used to assess correctness in math while unit tests indicate correctness in coding.
In such settings, the probability that a single sample from the model succeeds may be used to analytically compute all marginal rewards.

Let $\lambda=\mathbb{E}_{y\sim p(\cdot\mid x)}[r(x,y)]$ denote the probability of obtaining a successful result from a single sample (for $r(x,y)\in\{0,1\}$).
Then the reward estimate $q(x,b)$ is simply the probability of getting at least one success in $b$ attempts:
$q(x,b)=1-(1-\lambda)^{b}$.
Then $\Delta(x_{i},b_{i})=\lambda_{i}(1-\lambda_{i})^{b_{i}}$.

In this case, rather than training the reward predictor $\hat{\mathbf{\Delta}}$ using a squared loss as in Eq. 6, we obtain empirical estimates of $\lambda_{i}$ at training, then minimize the cross-entropy:

$$ $\sum_{x_{i},\lambda_{i}}\Big{[}\lambda_{i}\log(\hat{{\lambda}}(x_{i};\theta))+ (1-\lambda_{i})(\log(1-\hat{{\lambda}}(x_{i};\theta))\Big{]}$ (7) $$

with an appropriately parameterized $\hat{{\lambda}}(x;\theta)$.

Routing:
For the routing setting, we learn $\hat{\mathbf{\Delta}}$ in a special form that models the probability of outputs from the strong model $p^{S}$ being preferred over the weak model $p^{W}$ as:

$$ $\hat{\Delta}(x_{i};\theta)_{b^{S}}\approx p(p^{S}\succ p^{W}|x)=\mathbb{E}_{y_ {1}\sim p^{S},y_{2}\sim p^{W}}[\sigma(r(x,y_{1})-r(x,y_{2}))]$ (8) $$

## 4 Experiments

We apply our method to several adaptive decoding procedures: best-of-$k$ and routing (to either a large model or a sophisticated search algorithm). We evaluate improvements over standard decoding and procedures that allocate computation uniformly across problem instances, as well as performance relative to the theoretical upper bound. In addition, we provide *intrinsic* evaluations of the accuracy and calibration of reward predictors $\hat{\mathbf{\Delta}}$.

### 4.1 Adaptive Best-of-k

We use best-of-$k$ reranking with a reward model in three settings: Math, Code and Chat.

Methods:
We evaluate the following methods:

- 1.
Online Ada-BoK (ours): The online variant of our method that solves a joint optimization problem, as detailed in Section 2.
- 2.
Offline Ada-BoK (ours): The offline variant that solves the allocation problem on a held-out dataset, as detailed in Section 2. This method is only used in Math and Code domains.
- 3.
Best-of-$k$: This baseline allocates the same number of samples $k=B$ to every query.
- 4.
Oracle: Oracle is a non-implementable method that uses the ground truth marginal rewards to solve the allocation problem.
This method solves the allocation problem by plugging in the true marginal rewards.
It is unrealizable in practice, but provides an upper bound on the reward that could be obtained if the learned marginal reward predictor $\hat{\mathbf{\Delta}}$ were perfect.

Evaluation Metrics:
Our main evaluation metric for Math and Code is the expected success rate under an oracle verification procedure:

$$ $\textbf{Expected Success Rate}=\dfrac{1}{n}\sum_{i=1}^{n}\mathbb{E}_{y_{i}\sim f (x_{i},b_{i})}[\mathds{1}\text{\{$y_{i}$ is correct\}}]$ (9) $$

where $n$ is the number of queries.
Similarly, for Chat, it is the expected reward:

$$ $\textbf{Expected Reward}=\dfrac{1}{n}\sum_{i=1}^{N}\mathbb{E}_{y_{i}\sim f(x_{ i},b_{i})}[r(x,y_{i})]$ (10) $$

To estimate these in practice, we sample a large number of generations $B_{max}$ for each query and then use bootstrapping to approximate the expectation for different $b_{i}$ .

Figure: Figure 3: Results on Code and Math. The left column shows the distribution of LM success probabilities across queries. A significant number of problems on Code have $0\%$ success rate, while Math has a flatter distribution of difficulty. The middle column compares predicted marginal reward predictors to ground-truth values, alongside calibration curves (our predictors are well calibrated with the ground truth). Finally, the right column shows the performance curves for tested methods. Here, we observe that adaptive computation generally outperforms the best-of-$k$ baseline.
Refer to caption: x3.png

The compute budget $B$ is the average number of samples that may be drawn per query. Best-of-$k$ with $k=B$ uses the same number of total samples as our adaptive method.
We plot the performance of different methods for different compute budgets, where budgets are specified in terms of $B$.

Note that, in the binary reward-based Math and Code domains, it may be efficient to set $b_{i}=0$ for some queries, as many problems have a 0 0% success rate. In these cases, a default response such as I don’t know may be returned, allowing the sample budget to be allocated more effectively elsewhere. For chat experiments, we require all $b_{i}\geq 1$ .

#### Code

Setup: For the coding experiments, we adopt a subset of TACO, a dataset focused on algorithmic code generation with problems sourced from various programming contest platforms (Li et al., ).
We use a custom off-the-shelf Starcoder-15B model, which was released by the creators of the TACO dataset after fine-tuning on the dataset.
We use the official open-source evaluation framework released with TACO. A generation is classified as a success if it passes all test cases.
Finally, as unit tests serve as a verifier, a method is considered successful on a query if at least one of its $k$ generations passes all test cases.
We use the MLP variant to learn the marginal rewards.

Results:
Figure 3 present success rates for the code dataset.
We first observe that while our methods perform significantly better in the low-budget regime ($B<8$), the results in the moderate-to-high budget regime are mixed.
Counter-intuitively, while our offline variant always outperforms best-of-$k$, our online variant actually falls below the best-of-$k$ curve in the high-budget regime.
This is because small errors in the learned marginal reward predictor can hugely impact solutions to the allocation problem (if a problem has a true success rate of 0%, but its success rate is predicted to be 1%, it becomes an attractive candidate for a large budget).
50% of problems in the coding dataset have 0 success probability (for Math, this is only 5%).
The offline variant avoids this pathology by binning impossible and low-probability solutions together, effectively “regularizing” allocations.

In summary, the coding results bring to light the fact that prediction errors in marginal reward can adversely impact online allocation.
At the same time, the consistent outperformance of the offline variant over best-of-$k$ reinforces the value of adaptive compute budget allocation.

#### Math

Setup: We use a subset of the Numina-COT Dataset (Li et al., ), which contains Math problems obtained from diverse sources.
We use Mistral AI’s Mathstral-7B model, which is specialized for mathematical tasks, and is based on Mistral 7B (Jiang et al., ).
We use this model directly off-the-shelf and do not perform any fine-tuning.
We use an oracle verifier to select the best answer out of $k$.
This implies that if the model generates at least one correct answer out of $k$, it will be successful.
The verifier uses a $2$-stage pipeline that employs the evaluation framework of Hendrycks et al. in the first stage and a custom LLM-verifier in the second stage (Hendrycks et al., ). This pipeline is detailed in Appendix A.
We used the LoRa variant to learn the marginal rewards.

Results:
Figure 3 illustrates the success rate across different compute budgets.
Our online and offline methods consistently outperform best-of-$k$ for all compute budgets.
While the improvements are marginal in the low-budget regime ($B<8)$, adaptive computation shines in the moderate-to-high budget settings ($B\geq 8)$,
where they can achieve the same success rate as best-of-$k$ while using 25–50% less computation.
This efficiency likely stems from allocation of most of the compute resources to medium and hard problems, which require more samples, while easy problems need only a few to be solved optimally.
Both the online and offline variants perform nearly identically, indicating that solving the optimization problem offline does not lead to any performance degradation in this setting.
Finally, although we significantly outperform best-of-$k$, the oracle curve suggests that further improvements in the marginal reward predictor $\hat{\mathbf{\Delta}}$ could provide even greater gains.

Figure: Figure 4: Results of adaptive best-of-$k$ in the Chat domain. Our full variant achieves marginal improvements, enabling a 0-10% reduction in compute budget while maintaining equivalent reward levels. More notably, the tranches variant exhibits substantial gains, achieving the same reward levels with a 25-40% reduction in compute budget.
Refer to caption: x4.png

#### Chat

Setup: For chat, we use a subset of the LMSYS-Chat dataset, which contains real-world conversations with $25$ LLMs (Zheng et al., ).
We use the popular Gemma-7b-it model, which in an instruction-tuned model for chat (Team et al., ).
We use reward as our primary evaluation metric. We use an off-the-shelf reward model called NCSOFT/Llama-3-OffsetBias-RM-8B, which was ranked amongst the top $10$ on RewardBench at the time of writing.
We used the MLP variant to learn the marginal rewards.
Finally, we conduct evaluation on $2$ different subsets of the dataset-

- 1.
Full: The vanilla experiment uses the the entire test set.
- 2.
Tranches: The tranches experiment that uses a subset of $20\%$ from the full test set.
To create this subset, we first generated multiple responses for each query in the test set and labeled them using the reward model.
We then calculated the reward variance for each query and selected only those queries that fall in the lowest $10\%$ or highest $10\%$ of variance.
In essence, the tranches test set is composed of queries with the lowest and highest variance in rewards, representing the two extremes.

The main goal of the tranches experiment is to evaluate our method when the distribution of queries differs from typical datasets, which are often collected in somewhat controlled settings.
Such datasets may not fully capture the true diversity of user queries that are encountered by general chatbots. While understanding the true distribution of user queries is beyond the scope of this work, the tranches experiment simulates a more extreme distribution to provide performance insights.

Results:
Figure 4 present the results for the two subsets.
We focus on the small compute budget regime as chat requires much lesser search and we empirically observed rewards saturating quickly.
In the case of the full variant, the gains are relatively modest.
The Oracle curve shows a 15–25% reduction in compute budget while maintaining the same average reward.
Although our adaptive method consistently outperforms best-of-k everywhere, the reductions in compute budget are relatively small, ranging from 0–10%.
This indicates that while adaptive allocation can provide some benefit, an equitable allocation performs almost at par.
For the tranches variant, the results are notably different.
Our adaptive method achieves substantial gains, reducing the budget by 25–40% while matching the rewards of best-of-$k$.

### 4.2 Routing

Figure: Figure 5: Results for different routing procedures. The left column shows the distribution of ground-truth preference probabilities for model size and value-augmented sampling. The middle column compares our learned preference predictors to ground-truth values, alongside calibration curves (our predictors are well calibrated). Finally, the right column shows the performance curves for tested methods. We observe that adaptive routing outperforms the random routing baseline, demonstrating that our learned predictor is able to effectively route more challenging queries to the stronger model while leaving simpler queries to the weaker model.
Refer to caption: x5.png

Through this set of experiments, we aim to evaluate the effectiveness of our learned preference predictor in routing queries between a weak decoding procedure $p^{W}$ and a strong procedure $p^{S}$.

Settings: We present results for two different ($p^{W}$, $p^{S}$) pairs which are based on:

- 1.
Model Size: In this setting, $p^{W}$ and $p^{S}$ are models from the same family but with different model sizes. We use the instruction-tuned Gemma-2b-it and Gemma-7b-it models as $p^{W}$ and $p^{S}$. We use the full variant of the LMSYS dataset described in Section 4.1 .
- 2.
Value-Augmented Sampling: In this setting, $p^{W}$ and $p^{S}$ have the same base LLM model. During decoding, a value function is used to guide search, improving performance but with significant computational overhead. In this experiment we use Llama-2 7B for both the LLM and the value function. In each decoding step, we compute the value of 10 possible tokens, increasing the cost of decoding by a factor of 10.
We use the harmless subset of the popular Anthropic HH dataset (Bai et al., ).

Methods:
We present results for the following methods:

- 1.
Online Routing (ours): $\hat{\Delta}$ is used to predict the preference probabilities for a set of queries. These predictions are then routed using the online allocation procedure.
- 2.
Random: A simple baseline that randomly routes a fixed fraction of queries to $\pi^{S}$.
Any target $B$ may be obtained by changing this fraction.
- 3.
Oracle: As above, a non-realizable skyline that uses ground-truth information about the reward distribution of $p^{W}(\cdot\mid x_{i})$ and $p^{S}(\cdot\mid x_{i})$ for routing.

Setup:
We use expected reward, defined in Eq 10, as our main evaluation metric.
For reward prediction in experiments with variable model size, we use the smaller $p^{W}$ as the base LLM.
That is, we train using the hidden states of $p^{W}$ or perform LoRA fine-tuning of $p^{W}$.
This ensures that computational overhead during inference is minimal, and $p^{S}$ does not even have to be called at all for some queries.

Results:
Figure 5 shows that for both experiments, the learned predictor effectively routes the more challenging queries to the stronger model, while simpler queries are handled by the weaker model. This leads to substantial compute savings without a significant loss in overall performance. For example, in Value augmentation, we achieve up to a 25-40% reduction in calls to the more expensive decoding scheme while maintaining similar levels of reward.

Strikingly, in some cases our routing scheme actually outperforms the strong decoder—because the weak decoder sometimes outperforms the strong one, careful routing can achieve better overall performance. Our reward predictor learns and exploits this pattern.

### 4.3 Analysis

#### How do the learned marginal reward predictors perform?

So far, we have seen that our learned marginal reward predictors can be used effectively in adaptive compute allocation.
However, we also evaluate their performance independently of the adaptive compute allocation.
To this end, we introduce three evaluation metrics:

- 1.
Avg. (Average Loss): The empirical loss when the prediction for every query is the average marginal reward, i.e., $\bar{\Delta}=\frac{1}{N}\sum_{i}\Delta_{i}$. In this case, the model predicts the same marginal reward for each input. If the representations of the language model do not carry any meaningful information, we expect the performance to approximately equal this average loss.
- 2.
Opt.^∗ (Oracle Loss): The loss that a perfect predictor would achieve. Since we use soft labels rather than binary (0 0-$1$) labels, the minimum possible loss is a positive value.
- 3.
Acc. (Accuracy): The accuracy of predictions if the median of $\Delta$ values is used as a threshold. That is, if $\Delta_{i}>median$, the label for that query is $1$, and otherwise 0 0. The accuracy of a random predictor would $50\%$.

**Table 1: Learned predictors achieve lower loss than fixed baselines (Avg.), approach optimal values (Min.), and accurately discriminate queries of above- and below-median difficulty (Acc.).**
| Setting | Ours | Avg. | Opt.^∗ | Acc |
| --- | --- | --- | --- | --- |
| Code | 0.33 | 0.58 | 0.20 | 74% |
| Math | 0.48 | 0.69 | 0.34 | 84% |
| Chat (Model routing) | 0.64 | 0.67 | 0.58 | 72% |
| Chat (VAS routing) | 0.55 | 0.57 | 0.51 | 72% |

Table 1 summarizes the results.
In all cases, the achieved loss is lower than the baseline, indicating that the queries contain meaningful signals about the model’s response distributions.
In routing, the test loss is closer to the baseline, which can be attributed to the low entropy in the reward distribution, as shown in Figure 5.
Across all settings, accuracy exceeds 70%, showing that difficulty is predictable but highlighting potential scope for improvement.

Figure: Figure 6: Allocation of compute at different budgets. The “Easy”, “Medium”, and “Hard” categories are obtained by binning queries according to their predicted success probability. In the low-budget regime, the majority of the budget is allocated to easy and medium queries; as budget increases, it is primarily allocated to hard queries.
Refer to caption: x6.png

#### How does allocation vary with predicted difficulty?

Having established the performance benefits of adaptive allocation, we now explore what the distribution of compute budget for different marginal reward predictions looks like.
To investigate this, we focus on the Code and Math domains, where allocation is performed using $\lambda_{x}$, the success probability of a query.
We stratify the predicted success probabilities into three evenly-sized bins according to their predicted success probability.

Figure 6 illustrates how the compute allocation changes across bins as the budget increases.
At the lowest budget, the majority of the allocation goes to queries predicted to be easy or medium in difficulty.
At the highest compute budget, by contrast, most of the compute is allocated to the hard bin.
This shift can be understood intuitively: easy-to-moderate queries typically require only a few samples to solve, beyond which the marginal gain of additional samples decays rapidly. In contrast, for queries with low success probabilities, the marginal gain remains high even with a large number of samples and decays extremely slowly.
Finally, the distinct allocation patterns between Math and Code domains highlight how the underlying difficulty distributions of datasets significantly impact budget allocation strategies.

## 5 Related Work

Decoding Procedures in LLMs.
There has been extensive research into utilizing different decoding schemes to enhance LLM capabilities, usually by expending inference-time compute.
One of the most straightforward approaches is best-of-$k$ sampling, where $k$ different model responses are generated per user query, and the final model output is selected using a reward model (Gao et al., ; Beirami et al., ), majority voting (Wang et al., ), or verifiers (Li et al., ).
Another line of work has shown that allowing LLMs to generate intermediate “reasoning” steps, or “chain-of-thoughts” (CoTs) can significantly improve their final answer across various tasks (Wei et al., ; Nye et al., ; Zhou et al., ).
However, while this type of test-time search can boost performance, it incurs additional computational costs due to the need to decode (potentially many more) reasoning tokens.
LLM decoding can also be framed as sampling from a tree of possible sequences, inspiring research that uses inference-time compute to search through this tree more effectively (Yao et al., ; Liu et al., ; Han et al., ).

Adaptive Computation Time in NN. Several works explored the idea of learning how to adapt inference-time compute in neural networks (Graves, ; Dehghani et al., ; Banino et al., ). These works focus on networks with recurring components, where the decision is the number of times to pass the input through these components. Our work, however, is architecture-agnostic and focuses on adaptively selecting a decoding procedure.
Recently, Snell et al. () demonstrated that allocating inference-time compute optimally can outperform simply using a larger model. Here, we show how to realize these improvements in practice using learned difficulty predictors.

## 6 Conclusion

We have introduced an approach for adaptively scaling test-time computation by predicting which queries would benefit the most from additional computation.
We first showed that it is possible to learn lightweight models that predict marginal rewards on top of pre-trained LMs—indicating that LMs encode usable information about the reward distribution of their responses to inputs.
We then presented an allocation algorithm that adaptively allocates computation to queries.
Results in programming, mathematics, and chat show our approach gives significant reductions in computation at a target level of output quality, or improvements in quality given a fixed computation budget.

Limitations:
In this work, we assumed that we have access to a verifier in the Math experiments.
However, such verifiers will generally not be available, and using reward models specializing in Math might be the more practical implementation of our method.

Future Work:
The gap between our current performance and the oracle indicates that there is room for improvement in marginal reward prediction. This could be addressed by exploring more advanced prediction models or by developing techniques that allocate additional inference-time computation specifically to obtain better marginal reward estimates.

## Acknowledgments

This work was supported by Intel and the National Science Foundation under grants CCF-2217064 and IIS-2212310.

## Appendix A Experiment Details

### A.1 Math

Dataset:
We use a subset of the Numina-COT Dataset (Li et al., ),which contains math problems from various sources.
We filtered out multiple choice questions from the dataset.
Our final dataset contained 15K training samples, 2K validation samples and 3K test samples.

Model:
We use Mistral AI’s Mathstral-7B model, which is specialized for mathematical tasks, and is based on Mistral 7B (Jiang et al., ).
We use this model directly off-the-shelf and do not perform any fine-tuning.

Verification Pipeline:
We used a $2$ stage pipeline to verify the correctness of an answer.
The first stage used the evaluation framework of Hendrycks et al. ().
This framework expects the LM to enclose its answer within boxed {} and then runs an automated evaluation of the extracted answer against the ground truth answer.
However, we found that the automated evaluation had a high false negative rate for various reasons:

- 1.
Answer not enclosed within boxed {}: For some queries, the model had the right answer but did not enclose it inside boxed {}. This led to the responses being classified as incorrect.
- 2.
Errors in Checking: We found that due to errors in checking, many correct responses were marked incorrect. Some examples of false negatives are:
1. Model Response: frac{25}{2} ; Ground Truth Answer: 12.5
2. Model Response: x=2 ; Ground Truth Answer: 2
3. Model Response: -0.5 ; Ground Truth Answer: -frac{1}{2}
4. Model Response: 11.00 ; Ground Truth Answer: 11

These errors were particularly harmful for the training of our marginal reward predictors.
because queries predicted to be (and empirically) easy were being marked incorrect.
Furthermore, our online allocation exacerbated this issue, by assigning very few samples to such queries.

To address this issue, we introduced a second stage in the verification pipeline that used a LM as an evaluator.
Because stage $1$ does not have false positives, we only used stage $2$ for responses that were marked incorrect in stage $1$.
We used Llama-3.1-8B-Instruct with temperature set to 0.1 as our evaluation LM, and prompted it as follows:

Note that if the model’s response had an answer enclosed inside boxed {}, we only provided that extracted answer.
If this was not the case, then we provided the model’s entire response to the LLM evaluation agent.

The 2-stage pipeline helped us significantly improve the evaluation process, as well as stabilize the training process for our marginal reward predictors.
However, this pipeline is not without flaws, as we did notice examples a small number of false positives in the second stage.

Training:
We generate $128$ responses for every query (temperature=0.7) and label them using the verification pipeline.
We use the labels to compute the empirical mean success probabilities $\lambda_{i}$.
The estimated $\lambda_{i}$ are then used as targets to train $\hat{\mathbf{\Delta}}(x;\theta)$, the marginal reward predictor.

Evaluation:
Our adaptive allocation algorithms are assigned a maximum budget of $B_{max}=128$ samples per query (that is the allocation for any query is capped at 128 samples).

### A.2 Code

Dataset:
We use a subset of TACO, a dataset focused on algorithmic code generation with problems sourced from various programming contest platforms such as CodeChef, CodeForces and HackerRank.
Our primary reason for selecting TACO was the availability of test cases for most problems, which is required to train a predictor of success probability.
We filtered out problems that did not have a single unit test.
We also filtered out problems that were sourced from geeksforgeeks and aizu, as the official evaluation framework did not support those.
Our final dataset consisted of 10K training samples, 1K validation samples and 1K test samples.
Note that these three splits in our experiments were extracted from official TACO *training set*.
This is because the TACO test set has a very different distribution of problem difficulties, while our method aims to produce accurate *in-distribution* allocation of computation. We believe producing distributionally robust predictors is an important topic for future work.

Model:
We used the Starcoder-15B model, which was finetuned and open-sourced by the authors of Taco.

Training:
We generate $100$ responses for every query (temperature=0.7) and label them using the unit-test verifier to obtain the mean success probability $\lambda_{i}$.
The estimated $\lambda_{i}$ are then used as targets to train $\hat{\mathbf{\Delta}}(x;\theta)$, the marginal reward predictor.

Evaluation:
We used the official evaluation framework released by the creators of the TACO dataset. A response was considered a success if it passed all available test cases.
Our adaptive allocation algorithms are assigned a maximum budget of $B_{max}=100$ samples per query (that is the allocation for any query was capped at 100 samples).

### A.3 Chat

Dataset:
We use a subset of the LMSYS-Chat dataset, which contains one million real-world conversations with $25$ LLMs.
We filter the dataset to only select samples in English and with less than 10 turns.
We also filter out samples which were labelled redacted, as these were often artificially modified.
Our final dataset consisted of 50K training samples and 5K test samples.

Model:
We used the Gemma-2B-it model. We did not perform any fine-tuning.

Training:
We generate $8$ responses (temperature=0.7) for every query and label them using NCSOFT/Llama-3-OffsetBias-RM-8B, which was ranked amongst the top $10$ on RewardBench at the time of writing.
We then use bootstrapping to approximate $\mathbf{\Delta}_{i}$.
The approximated $\mathbf{\Delta}_{i}$ are then used as targets to train $\hat{\mathbf{\Delta}}(x;\theta)$, the marginal reward predictor.

Evaluation:
We evaluate using the same reward model as above.
Our adaptive allocation algorithm was assigned a maximum budget of $B_{max}=8$ samples per query.

### A.4 Routing: Model Size

Dataset:
We used the same LLMSYS-Chat dataset that we used for the best-of-$k$ chat experiments.

Model:
Our weak model was Gemma-2B-it.
Our strong model was Gemma-7B-it.
We did not perform any fine-tuning on either of these models.

Training:
We generate $8$ responses (at a temperature of 0.7) for every query with both the models.
We labelled them using NCSOFT/Llama-3-OffsetBias-RM-8B as the reward model.
Supervision for the reward model was then computed using a Monte Carlo estimate of:

$$ $(p^{S}\succ p^{W}|x)=\mathbb{E}_{y_{1}\sim p^{S},y_{2}\sim p^{W}}[\sigma(r(x,y _{1})-r(x,y_{2}))]$ (11) $$

Evaluation:
The adaptive allocation procedure uses the predictions of the marginal reward predictor to route the top $B^{th}$ percentile of queries to $p^{S}$.
We evaluated using the same reward model mentioned above.

### A.5 Routing: VAS

Dataset:
We use the harmless subset of the popular Anthropic-HH dataset.
We sampled 8K samples randomly from the train set, and 400 samples from the test set.

Model:
Our weak decoding procedure was a fine-tuned Llama-7B model.
Our strong decoding procedure used an additional value function that was also based on the Llama-7B model.

Training:
We generated $4$ responses per query.
The preference probability was then computed using a Monte Carlo estimate of:

$$ $p(p^{S}\succ p^{W}|x)=\mathbb{E}_{y_{1}\sim p^{S},y_{2}\sim p^{W}}[\sigma(r(x, y_{1})-r(x,y_{2}))]$ (12) $$

We labelled the responses using OpenAssistant/reward-model-deberta-v3-large-v2 as the reward model.

Evaluation:
Our adaptive allocation used the predictions of the marginal reward predictor to route the top $B^{th}$ percentile of queries to $p^{S}$.
We evaluated using the same reward model mentioned above.

## Peer Reviews

confidence: 3
contribution: 2
initial_rating: 5
presentation: 2
questions: - Typos:
    - Line 352: "which in an" should be "which is an".
    - "LoRa" should be changed to "LoRA".
    - In Figure 1, "Large LM" should be changed to "large LM" for consistency.
- What's the definition of "N" in equation (10)?
soundness: 3
strengths: - The paper adeptly formulates the "adaptive computation scaling allocation" in the context of LM decoding, addressing a topic that is both timely and relevant.
- The proposed computation-allocation framework is comprehensive, covering various cases and scenarios, including binary reward, pairwise optimization in routing, and both online and offline design considerations.
- The experiments conducted on three diverse and representative domains demonstrate the efficiency and efficacy of the proposed computation-allocation strategies.
summary: This paper presents an approach to adaptively allocate computational resources for language model (LM) decoding based on input difficulty. The authors propose a framework that predicts the marginal benefit of additional computation for each query, enabling dynamic adjustment of decoding procedures to maximize efficiency without sacrificing output quality. They demonstrate their method across tasks in math, code generation, and dialogue, achieving up to 50% reduction in compute usage in some cases. The paper also introduces two adaptive procedures—best-of-k sampling and routing between models of varying complexity—and provides a thorough evaluation using both online and offline allocation strategies.
weaknesses: - The main concern is that the current computation-allocation solution is only evaluated in scenarios with identical distributions (i.e., the training data used to train the difficulty model comes from the same distribution as the test set). It is unclear whether the trained difficulty model generalizes to other distributions. The generalizability of the difficulty model is crucial for determining the practicality of the proposed computation-allocation framework.
- Following from the above, since the choice of LLMs does not seem to affect the evaluation of the proposed method’s efficacy, why not select a single fixed LLM, such as Llama3-7b-Instruct? By doing so, it might be easier to assess the generalizability of the method. (Please correct me if there is an issue with my understanding.)
- The implementation of the baselines is weak, with only one effective but not particularly practical baseline (best-of-k and random) in each scenario. Between the proposed method and these baselines, there are likely other reasonable approaches that could better demonstrate the effectiveness of the proposed framework.
- The related work section is too concise and lacks comprehensiveness, especially in the discussion of relevant adaptive computing research. Only one recently published paper is mentioned, which undermines the paper's completeness and contextual grounding.

---

confidence: 4
contribution: 3
initial_rating: 8
presentation: 3
questions: Drawing inspiration from the online secretary problem, it would be interesting to see how online estimation of pass rates for coding can aid utility estimation. For example, one could increase the total computation budget and, for each problem, reserving some of that budget to utility estimation. This would alleviate some of the burden from the prediction model.
soundness: 3
strengths: The paper tackles a novel and timely problem, and offers a reasonable approach. The paper is clearly written.
summary: Presents an input-adaptive method for test-time compute-allocation. Decoding methods apply either sequential (eg weak vs strong model) or parallel compute (eg more samples in best-of-n). For a given method, this paper proposes to predict the marginal utility of every unit of computation, then use these predictions to optimize compute allocation. The paper proposes to predict these utilities given only the input.

The resource allocation problem can be solved in an offline manner given a fully observed dataset, referred to as online allocation in the paper, or solved via online access to only a partially observed dataset, referred to as offline allocation in the paper.

Experimental results across coding, math, and chat indicate that utility prediction is difficult at the extremes, and allocation decisions are sensitive to utility errors. Overall, adaptive allocation outperforms uniform or random allocations. The partially-observed strategy empirically often does better than the fully-observed case, possibly due to coarsening effects that hide errors in utility prediction.
weaknesses: A small criticism is the naming convention of online versus offline. Online optimization refers to "optimization problems having no or incomplete knowledge of the future (online)," which is not how online is used in this paper.

Other than that, this paper is a good step in improving adaptive test-time compute, identifying the importance of accurate utility estimation in problems with very low success rates.

---

confidence: 4
contribution: 3
initial_rating: 5
presentation: 3
questions: 1. Though I understand using a query only to predict the reward should incur less latency, will $y$ be more informative and easier to train the predictor?

2. Could you please report the Spearman Correlation in Figure 3 (b, middle column)?  

3. Could you provide more clarification on the computing budget? Is it based on the inference calls?

I will be happy to raise my score if the author could address the aforementioned limitations and concerns.
soundness: 2
strengths: 1. Scaling the test-time compute is effective but costly, this work contributes to a timely direction with a smart input-adaptive allocation scheme improving test-time efficiency.

2. The empirical improvement in efficiency is noticeable, and this work has covered adaptive allocation in representative popular subdomains: sampling, model size, and decoding method.

3. The presented analysis in Figure 6 is intuitive.
summary: This work proposes an input-adaptive computation allocation mechanism for improving the efficiency of test-time computation. The core idea is to train a model that predicts the distribution of rewards given a query and a budget. It incorporates training an MLP LM head and LoRA as the reward predictor that estimates the difficulty of a batch of queries. The proposed adaptive best-of-k outperforms the efficiency of standard best-of-k baselines in math, code, and chat domains. In addition, the author demonstrates the improvement in routing in terms of different model sizes and decoding schemes. The additional case study in inspecting the allocation of computation at different budgets is intriguing.
weaknesses: 1. The selection of datasets and backbone language models may be questionable. I suspect this method should be ideally generalizable across tasks, however, only a single data in each domain is selected. I expect to see more tasks like HumanEval, MBPP for coding, Hendrycks MATH, and GSM for math. Meanwhile, for each domain, the author selects a specific backbone LM rather than the same choice across all tasks. This may raise concerns about the generalization of the proposed method.

2. The underlying difficulty of this method is to actually train a very good difficulty estimator. However, the training difficulty, and the heavy training data resource requirement for learning a good reward predictor have not been explicitly discussed in the context. Moreover, it is highly dependent on the task, and I suspect the difficulty of some tasks will not be easy to predict. 

3. The proposed method only considers the query for training the reward predictor. However, though there is a latency for querying the model, I suspect introducing $y$ will be more informative to reflect the difficulty of a task. 

4. In Figure 3 (middle), besides the left bottom and right top clusters, the rest correlation appears to be relatively poor. Therefore, I suspect the efficiency gain could be mostly coming from predicting “unanswerable” for the queries in the left bottom regions and putting 0 costs there, also assigning a minimum budget to always correct questions. However, the middle region is actually the region that should benefit from a smart computation allocation scheme, and the correlation is not convincing here.

---

confidence: 4
contribution: 2
initial_rating: 5
presentation: 3
questions: 1. Please explain the choice of benchmarks and how they compare to HumanEval and MATH in terms of difficulty distribution. Or please add more benchmarks like HumanEval and MATH. 

2. If a more complex decoding method, such as MCTS, is employed, would it necessitate retraining the probe? This could suggest a mismatch between the model's capabilities when using more advanced decoding methods and the probe's predictions. Additionally, it raises the question of whether the probe's prediction accuracy may be affected by factors such as varying prompts or decoding methods, and whether the probe demonstrates robustness under these conditions. Please explain the discuss the generalizability of the probe.
soundness: 3
strengths: 1. This paper achieves efficient decoding from a different perspective, showing clear improvements over the original BoK method.
2. The authors apply their method across three distinct domains—code, math, and chat—demonstrating generalizability of their method.
summary: This paper proposes a method for the adaptive allocation of decoding computation. By employing an LLM-based probe to predict the difficulty of a given query, the approach dynamically adjusts the allocation of decoding resources. The authors validate the method’s effectiveness across coding, math, and chat tasks. Results demonstrate that, under computational constraints, this approach outperforms the baseline BoK method.
weaknesses: 1. In the experiments for code and math, the authors employ less-used benchmarks rather than widely adopted ones like HumanEval and MATH, raising concerns about the method’s applicability to broader tasks.

2. The paper's baseline comparison is limited to the BoK method, lacking comparative experiments with other stronger efficient decoding methods, such as Speculative Decoding.

Meta-review: The paper presents an adaptive computation allocation approach for LM decoding that predicts input difficulty to optimize resource usage. Key strengths include: comprehensive evaluation across diverse domains (code, math, chat), significant compute reduction (up to 50%) without quality loss, and strong generalization results on standard benchmarks (MATH, GSM8K). Main weaknesses are: initial limitation to same-distribution evaluation, use of different LLMs across experiments, and moderate prediction accuracy for medium-difficulty cases. However, authors adequately addressed these through additional experiments showing cross-dataset/model generalization. The paper makes a valuable contribution to efficient LM deployment and is recommended for acceptance.

Decision: Accept (Poster)