Lune

ICML2025Top-tier venue

Optimizing Temperature for Language Models with Multi-Sample Inference

Weihua Du, Yiming Yang, Sean Welleck

Abstract

Multi-sample aggregation strategies, such as majority voting and best-of-N sampling, are widely used in contemporary large language models (LLMs) to enhance predictive accuracy across various tasks. A key challenge in this process is temperature selection, which significantly impacts model performance. Existing approaches either rely on a fixed default temperature or require labeled validation data for tuning, which are often scarce and difficult to obtain. This paper addresses the challenge of automatically identifying the (near)-optimal temperature for different LLMs using multi-sample aggregation strategies, without relying on task-specific validation data. We provide a comprehensive analysis of temperature's role in performance optimization, considering variations in model architectures, datasets, task types, model sizes, and predictive accuracy. Furthermore, we propose a novel entropy-based metric for automated temperature optimization, which consistently outperforms fixed-temperature baselines. Additionally, we incorporate a stochastic process model to enhance interpretability, offering deeper insights into the relationship between temperature and model performance. Our code is available at https://github.com/StigLidu/dualdistill . Optimizing Temperature for Language Models with Multi-Sample Inference ing how to optimize the sampling process to enhance LLM performance under different conditions, including variations in training datasets, task types, and model sizes. A crucial open question is how to tune temperature, a key hyperparameter that controls the smoothness of the system-learned distribution. Intuitively, increasing the temperature leads to a smoother distribution, enhancing the diversity of sampled outputs. However, excessively high temperatures can introduce many low-quality samples, making aggregation more challenging (Holtzman et al., 2019; Renze & Guven, 2024) . Conversely, lowering the temperature results in a highly concentrated distribution, reducing diversity and potentially omitting high-quality samples. Striking the right balance between over-sampling and under-sampling is therefore essential for optimizing LLM performance. A common practice in prior evaluations is to use the same temperature across all methods despite variations in training datasets, task types, model sizes, and aggregation strategies. This practice is clearly suboptimal. An alternative approach is to empirically tune the temperature using labeled validation data for each task, dataset, model size, and aggregation strategy (Zhang et al., 2024a; Dhuliawala et al., 2024) . However, such a process is tedious and time-consuming and heavily dependent on the availability of labeled validation data, limiting its applicability when such data are scarce. In this paper, we present the first systematic investigation of how temperature affects LLM performance under multisample aggregation strategies across various conditions. Furthermore, we propose a principled algorithmic solution for automated temperature optimization without requiring labeled validation data. Our key idea is as follows: 1. We use the confidence score of each model as a selfassessment measure.

Ask Lune

Know this paper in minutes, not an afternoon.

Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.

11 top-tier papers have cited it since. Know what they found before your reviewers do.

Questions to start from

Lune can draw on

the full paper · the top-tier papers that cite it · related work

Get the answer

Free to start. No credit card required.

Lineage

  • Tree of Thoughts: Deliberate Problem Solving with Large Language Models cites Self-Consistency Improves Chain of Thought Reasoning in Language Models
  • Tree of Thoughts: Deliberate Problem Solving with Large Language Models cites Chain-of-Thought Prompting Elicits Reasoning in Large Language Models
  • Self-Consistency Improves Chain of Thought Reasoning in Language Models cites Chain-of-Thought Prompting Elicits Reasoning in Large Language Models
  • Chain-of-Thought Prompting Elicits Reasoning in Large Language Models cites Self-Consistency Improves Chain of Thought Reasoning in Language Models
  • Self-Consistency Improves Chain of Thought Reasoning in Language Models cites The Curious Case of Neural Text Degeneration
  • Temperature as a Meta-Policy: Adaptive Temperature in LLM Reinforcement Learning cites The Curious Case of Neural Text Degeneration
  • Demystifying LLM-as-a-Judge: Analytically Tractable Model for Inference-Time Scaling cites Tree of Thoughts: Deliberate Problem Solving with Large Language Models
  • Demystifying LLM-as-a-Judge: Analytically Tractable Model for Inference-Time Scaling cites Self-Consistency Improves Chain of Thought Reasoning in Language Models
  • Demystifying LLM-as-a-Judge: Analytically Tractable Model for Inference-Time Scaling cites Chain-of-Thought Prompting Elicits Reasoning in Large Language Models
  • Optimal Self-Consistency for Efficient Reasoning with Large Language Models cites Tree of Thoughts: Deliberate Problem Solving with Large Language Models
  • Optimal Self-Consistency for Efficient Reasoning with Large Language Models cites Self-Consistency Improves Chain of Thought Reasoning in Language Models
  • Optimal Self-Consistency for Efficient Reasoning with Large Language Models cites Efficient Memory Management for Large Language Model Serving with PagedAttention
  • Optimal Self-Consistency for Efficient Reasoning with Large Language Models cites Chain-of-Thought Prompting Elicits Reasoning in Large Language Models
Builds onCited byLeft to right by year; the more cited, the higher.

Cited by top-tier papers11

  1. BroRL: Scaling Reinforcement Learning via Broadened ExplorationJian Hu, Mingjie Liu, Ximing Lu, Fang Wu et al.ICML 2026 · 16 citations
  2. Temperature as a Meta-Policy: Adaptive Temperature in LLM Reinforcement LearningHaoran Dang, Cuiling Lan, Hai Wan, Xibin Zhao et al.ICLR 2026 · 9 citations
  3. Optimal Self-Consistency for Efficient Reasoning with Large Language ModelsAustin Feng, Marius Alonso, Ambroise Odonnat, Vasilii Feofanov et al.ICML 2026 · 6 citations
  4. Large Language Models Develop Novel Social Biases Through Adaptive ExplorationAddison J. Wu, Ryan Liu, Xuechunzi Bai, Thomas GriffithsICML 2026 · 4 citations
  5. Demystifying LLM-as-a-Judge: Analytically Tractable Model for Inference-Time ScalingIndranil Halder, Cengiz PehlevanICML 2026 · 4 citations

Builds on14

  1. Chain-of-Thought Prompting Elicits Reasoning in Large Language ModelsJason Wei, Xuezhi Wang, Dale Schuurmans, Maarten Bosma et al.NeurIPS 2022 · 22,562 citations
  2. Tree of Thoughts: Deliberate Problem Solving with Large Language ModelsShunyu Yao, Dian Yu, Jeffrey Zhao, Izhak Shafran et al.NeurIPS 2023 · 5,068 citations
  3. The Curious Case of Neural Text DegenerationAri Holtzman, Jan Buys, Li Du, Maxwell Forbes et al.ICLR 2020 · 4,112 citations
  4. Efficient Memory Management for Large Language Model Serving with PagedAttentionWoosuk Kwon, Zhuohan Li, Siyuan Zhuang, Ying Sheng et al.SOSP 2023 · 1,016 citations
  5. Self-Consistency Improves Chain of Thought Reasoning in Language ModelsXuezhi Wang, Jason Wei, Dale Schuurmans, Quoc V. Le et al.ICLR 2023 · 681 citations

Related papers

  1. The Effect of Sampling Temperature on Problem Solving in Large Language ModelsMatthew RenzeEMNLP Findings 2024 · 212 citations
  2. Thermometer of Thoughts: Enhancing LLM's Exploration via Attention Temperature ModulationZhiyuan Yu, Shijian Xiao, Cam-Tu Nguyen, Zhangyue Yin et al.ACL 2026
  3. Self-Ensemble: Mitigating Confidence Distortion for Large Language ModelsZicheng Xu, Guanchu Wang, Guangyao Zheng, Yu-Neng Chuang et al.EMNLP Findings 2025
  4. Future-Gain Guided Test-Time Learning for Large Language ModelsLangYu Bian, Jinwu Hu, Zitian Zhang, Dongjin Yang et al.ICML 2026 · 12 citations
  5. SelectLLM: Query-Aware Efficient Selection Algorithm for Large Language ModelsKaushal Kumar Maurya, KV Aditya Srivatsa, Ekaterina KochmarACL Findings 2025 · 4 citations
Dusk over the sea between two cliffs drawn in fine vertical lines