Optimizing Temperature for Language Models with Multi-Sample Inference

Weihua Du, Yiming Yang, Sean Welleck
2/7/2025
cs.LGcs.AIcs.CL

No official code found. Best implementation: StigLidu/TURN (23 stars, MIT, last commit 2025-02-16).

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.

View on arXivView PDF

Code Implementations(1)

StigLidu/TURNCommunity60%
MIT

[ICML2025] Official Repo for Paper "Optimizing Temperature for Language Models with Multi-Sample Inference"

231Shell, PythonJan 31, 20251 years agoMIT
llm-inference

Similar Papers

Cite this paper

@article{du2025optimizing,
  title  = {Optimizing Temperature for Language Models with Multi-Sample Inference},
  author = {Weihua Du and Yiming Yang and Sean Welleck},
  year   = {2025},
  eprint = {2502.05234},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2502.05234v2},
  journal = {ICML 2025 2025}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2502.05234.svg)](https://codeofpaper.com/paper/2502.05234)

Discussion