Learning Adaptive LLM Decoding
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
Abstract
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
| 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%) | |||
| 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 |
| Metric | Setting | Reported | Adapter (w/ budget) |
| Pass@1 | non-thinking | 19.1 | 20.1 2.62 |
| thinking | 65.6 | 71.1 2.96 |
| 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%) | |||||
| 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 | |
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 | |
| 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 | |
| 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 | |
| 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 | ||
| Parameter | Value |
| Temperature | |
| Top- | |
| Top- | |
| Min- |
| 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 | – |
| 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 | – |
| 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 |
| Strategy | Parameters | |
| do_sample | temperature | |
| 0 | false | 0 |
| 1 | true | 0.5 |
| 2 | true | 1.0 |
| 3 | true | 1.25 |
| Parameter | Value |
| Architecture | MLP |
| Number of Layers | 3 |
| Activation | SiLU |
| Dropout | 0.1 |
| Optimizer | Adam |
| format | bf16 |