What is Temperature in NLP / LLMs?

Lazy Programmer
6 min readMar 14, 2023

(This also applies to ChatGPT, GPT-3, GPT-3.5, GPT-4, LLaMA, Bard, etc.)

Robot holding a thermometer.

Generative language models are powerful machine learning models that are capable of generating new text based on a given context or prompt. These models have become increasingly popular in recent years, thanks to the advancement of deep learning techniques such as neural networks. One of the key parameters that can be used to control the behavior of generative language models is the temperature parameter. In this article, we will discuss the role of the temperature parameter in generative language models and how it affects the quality of the generated text.

What is a Generative Language Model?

Generative language models are machine learning models that are trained to predict the probability distribution of a sequence of words given a context or prompt. These models are typically based on neural networks, such as Recurrent Neural Networks (RNNs) or Transformer models, that are trained on large corpora of text data. Once trained, these models can be used to generate new text that is similar to the training data but not identical.

The Role of Temperature in Generative Language Models

--

--