Authors: Chloe H. Su, Zhe Ye, Samuel Tenka, Aidan Yang, Soonho Kong, Udaya Ghai
Organizations: Department of Computer Science, Harvard University, Boston, USA · Kempner Institute, Harvard University, Cambridge, MA, USA · UC Berkeley, CA, USA · Amazon, Boston, MA 02210, USA
Decoding from large language models (LLMs) typically relies on fixed sampling hyperparameters (e.g., temperature, top-p), despite substantial variation in task difficulty and uncertainty across prompts and individual decoding steps. We propose to learn adaptive decoding policies that dynamically select sampling strategies at inference time, conditioned on available compute resources. Rather than fine-tuning the language model itself, we introduce lightweight decoding adapters trained with reinforcement learning and verifiable terminal rewards (e.g. correctness on math and coding tasks). At the sequence level, we frame decoding as a contextual bandit problem: a policy selects a decoding strategy (e.g. greedy, top-k, min-p) for each prompt, conditioned on the prompt embedding and a parallel sampling budget. At the token level, we model decoding as a partially observable Markov decision process (POMDP), where a policy selects sampling actions at each token step based on internal model features and the remaining token budget. Experiments on the MATH and CodeContests benchmarks show that the learned adapters improve the accuracy-budget tradeoff: on MATH, the token-level adapter improves Pass@1 accuracy by up to 10.2% over the best static baseline under a fixed token budget, while the sequence-level adapter yields 2-3% gains under fixed parallel sampling. Ablation analyses support the contribution of both sequence- and token-level adaptation.
Figures & tables
Figure 1: Overview of the proposed decoding adapter (DA) for a frozen language model (LM). Blue blocks denote input tokens xi ; green blocks denote generated tokens yi .
Static sampling
Sequence-level adapter
Metric
Setting
Best
Mixed
w/o budget
w/ budget
Pass@1
TURN ( Du et al., 2025 )
72.72
w/o CoT
71.70 ± 1.25
71.20 ± 1.26
72.60 ± 1.24
72.90 ± 1.23
Δ Abs. (Rel.)
↑ 0.90 (+1.26%)
↑ 1.20 (+1.67%)
mix CoT
72.10 ± 1.24
71.93 ± 1.25
73.60 ± 1.22
74.20 ± 1.21
Δ Abs. (Rel.)
↑ 1.50 (+2.08%)
↑ 2.10 (+2.91%)
Table 1: MATH. Comparison of static sampling baselines and the sequence-level adapter under different settings. For CoT mix , we apply CoT prompting to 30% of prompts (ratio =0.3 ). Static sampling reports the best single strategy ( Best ) and a fixed mixture ( Mixed ). The adapter is evaluated with a budget provided in feature set and without. Values are percentages (mean ± confidence interval).
Static sampling
Sequence-level adapter
Metric
Setting
Best
Mixed
w/o budget
w/ budget
Pass@1
w/o CoT
11.43 ± 2.28
10.53 ± 2.19
14.53 ± 2.52
14.50 ± 2.52
Δ Abs. (Rel.)
↑ 3.10 (+27.12%)
↑ 3.07 (+26.85%)
mix CoT
13.97 ± 2.48
14.80 ± 2.54
17.06 ± 2.69
19.70 ± 2.85
Δ Abs. (Rel.)
↑ 2.26 (+15.27%)
↑ 4.90 (+33.11%)
Pass@8
w/o CoT
22.80 ± 3.00
22.23 ± 2.97
26.08 ± 3.14
23.10 ± 3.02
Table 2: CodeContests : comparison of static sampling strategies vs. the sequence -level sampling adapter under different settings.
Metric
Setting
Reported
Adapter (w/ budget)
Pass@1
non-thinking
19.1
20.1 ± 2.62
thinking
65.6
71.1 ± 2.96
Table 3: AIME’25 performance comparison of a sequence -level adapter trained on MATH-train vs. numbers reported in the Qwen3-4B technical report ( Team, 2025a ) .
Static sampling
Sequence-level adapter
Metric
Setting
Best
Mixed
w/o budget
w/ budget
MATH
Code
MATH
Code
MATH
Code
MATH
Code
Pass@1
w/o CoT
72.00 ± 3.18
11.80 ± 2.39
71.10 ± 3.17
10.30 ± 2.18
73.55 ± 3.12
13.70 ± 2.46
74.20 ± 3.13
13.70 ± 2.46
Δ Abs. (Rel.)
↑ 1.55 (2.15%)
↑ 1.90 (16.10%)
↑ 2.20 (3.06%)
↑ 1.90 (16.10%)
mix CoT
73.80 ± 3.15
17.10 ± 2.69
73.30 ± 3.17
14.50 ± 2.52
74.80 ± 3.11
18.50 ± 2.89
74.70 ± 3.11
18.20 ± 2.76
Δ Abs. (Rel.)
↑ 1.00 (1.36%)
↑ 1.40 (8.19%)
↑ 0.90 (1.22%)
↑ 1.10 (6.43%)
Table 4: Mixed training of math and coding: comparison of static sampling strategies vs. the sequence -level sampling adapter. We use Code to refer to CodeContests in this table.
Figure 2: Action distributions and validation reward on MATH for sequence-level adapter strategies. Actions are defined in table 11 . The x-axis denotes training progress; the left y-axis reports action probability; the right y-axis reports validation reward.
Static sampling
Adapter
Metric
Setting
Greedy
Mixed
w/o budget
Δ
budget
Δ
Pass@1
w/o CoT
71.33 ± 1.25
71.60 ± 1.25
78.28 ± 1.14
+6.68
80.82 ± 1.07
+9.49
mix CoT
72.10 ± 1.24
72.67 ± 1.24
78.52 ± 1.14
+5.85
82.33 ± 1.03
+10.23
Table 5: Comparison of sampling strategies on Math : performance comparison of token -level sampling adapter versus static sampling strategies. Here budget is the remaining token budget within a sequence. Values are percentages.
Appendix figures & tables16 assets
Supplementary material from the paper’s appendix.
Appendix
Static sampling
Sequence-level adapter
Metric
Setting
Best
Mixed
w/o budget
w/ budget
Pass@1
w/o CoT
72.86 ± 1.23
72.38 ± 1.24
73.20 ± 1.23
73.67 ± 1.22
mix CoT
73.02 ± 1.23
72.92 ± 1.23
73.80 ± 1.22
74.07 ± 1.21
Pass@8
w/o CoT
78.38 ± 1.14
77.10 ± 1.16
78.20 ± 1.14
78.80 ± 1.13
mix CoT
78.98 ± 1.13
78.58 ± 1.14
79.00 ± 1.13
79.13 ± 1.13
Appendix
Table 6: Comparison of sampling strategies on MATH. against the proposed sequence -level sampling adapter, using Qwen3-8B. For the ‘w/ CoT mix’ configuration, a CoT ratio of 0.3 is applied. All reported values are percentages.
Static sampling
Sequence-level adapter
Metric
Setting
Best
Mixed
w/o budget
w/ budget
Pass@1
w/o CoT
12.80 ± 2.39
12.00 ± 2.33
18.80 ± 2.80
17.90 ± 2.74
mix CoT
19.70 ± 2.85
14.50 ± 2.52
22.20 ± 2.97
23.10 ± 3.02
Pass@8
w/o CoT
23.10 ± 3.02
22.23 ± 2.98
26.50 ± 3.16
27.40 ± 3.19
mix CoT
29.10 ± 3.25
23.90 ± 3.05
32.50 ± 3.35
34.20 ± 3.40
Appendix
Table 7: Comparison of sampling strategies on CodeContests. : vs. the sequence -level sampling adapter under two inference settings (without/with a mix of CoT prompts), using Qwen3-8B. For ‘w/ CoT mix’, we use a CoT ratio of 0.3.
Static sampling
Sequence-level adapter
Metric
Setting
Best
Mixed
Just 4 actions
w/ mix of inference strategy
Pass@1
w/o CoT
61.52 ± 1.35
56.42 ± 1.37
61.52 ± 1.35
62.62 ± 1.34
mix CoT
62.10 ± 1.34
59.00 ± 1.36
62.76 ± 1.34
63.20 ± 1.34
Pass@8
w/o CoT
61.52 ± 1.35
66.74 ± 1.31
68.25 ± 1.29
69.66 ± 1.27
mix CoT
63.00 ± 1.34
67.10 ± 1.30
69.32 ± 1.28
70.88 ± 1.26
Appendix
Table 8: Comparison of sampling strategies on MATH. the sequence -level sampling adapter under two inference settings (without/with a mix of CoT prompts). 0.3.
Static sampling
Adapter
Metric
Setting
Best
Mixed
w/o budget
Pass@1
w/o CoT
11.43 ± 2.28
10.53 ± 2.20
12.80 ± 2.39
mix CoT
13.97 ± 2.48
14.80 ± 2.54
17.90 ± 2.74
Appendix
Table 9: Coding: performance comparison of sequence -level adapter trained on MATH train versus baseline numbers.
Figure 3: Entropy modulation under token-level control. Token entropy distributions for a representative static strategy versus the learned token-level adapter, using the temperature-only action set from Table 14 . Action 0 is greedy; larger action indices correspond to higher temperature. Qualitatively, the adapter more often preserves stochasticity on higher-entropy tokens, while collapsing many low-entropy tokens to near-deterministic behavior.
Figure 4: Generation length distributions. Generation length statistics for a representative static strategy and the learned adapters. Length shifts are present but not extreme, suggesting the token-level gains are not explained solely by systematic truncation/verbosity changes.
Figure 5: Word clouds by action. Most frequent tokens under each temperature-based action from Table 14 . This is a lightweight diagnostic and does not by itself explain the policy’s performance improvements.
Parameter
Value
Temperature
[0.3,0.5,0.75,1.0,1.25]
Top- k
[5,10,50,“off"]
Top- p
[0.9,0.95,“off"]
Min- p
[0.1,0.2,“off"]
Appendix
Table 10: Sweep ranges of as the action space for our sampling adapter.
Figure 6: Best of N accuracy vs number of selected actions for greedy selection (our approach) vs the baseline of taking the top N actions.
Strategy
Parameters
do_sample
temperature
top_k
top_p
min_p
1
true
0.75
–
0.9
0.1
2
true
1.0
–
0.9
–
3
true
1.25
10
0.9
–
4
true
1.0
5
0.9
–
5
true
1.25
50
0.9
–
Appendix
Table 11: Selected decoding strategies for math tasks.
Strategy
Parameters
do_sample
temperature
top_k
top_p
min_p
1
true
1.25
–
0.95
0.1
2
true
1.25
–
0.95
0.2
3
true
1.0
–
0.95
0.2
4
true
1.25
50
0.9
0.1
5
true
1.25
5
0.9
–
Appendix
Table 12: Selected decoding strategies for coding tasks.
Strategy
Parameters
do_sample
temperature
top_k
top_p
min_p
0
true
0.5
–
–
–
1
true
1.0
–
–
–
2
true
1.25
–
–
–
3
true
0.75
10
–
–
4
true
0.75
10
0.95
0.1
Appendix
Table 13: Selected decoding strategies for a mix of math and coding tasks.
Strategy
Parameters
do_sample
temperature
0
false
0
1
true
0.5
2
true
1.0
3
true
1.25
Appendix
Table 14: Selected decoding strategies for token-level math tasks.
Parameter
Value
Architecture
MLP
Number of Layers
3
Activation
SiLU
Dropout
0.1
Optimizer
Adam
format
bf16
Appendix
Table 15: Parameters of token -level sampling adapter.
Figure 7: Action distributions and val reward on CodeContests for sampling strategies with sequence-level adapter. The actions are defined in table 12 . Axes are same as in Figure 2 .
Figure 8: Action distributions and val reward on MATH for sampling strategies with the token -level adapter. Actions are defined in table 11 . Axes match fig. 2 . Note that a CoT action probability of 0 indicates that no CoT prompt was sampled in that batch.