Jump to content

Language model loss

From Wikibase
Revision as of 16:36, 11 November 2026 by Rongzhou (talk | contribs)

Languages: English · français · Esperanto

The language model loss measures how "surprised" a large language model (LLM) is by the true values of tokens it attempts to predict.

Formal definition

With model parameters $\theta$, the language model loss on training sample $\vec x=(x_1,\cdots,x_T)$:

$$ L(\theta) = -\frac{1}{T}\sum_{t=1}^{T}\log_b P_\theta(x_t \mid x_{1:t-1}) $$

$\vec x=(x_1,\cdots,x_T)$ is a text token sequence of length $T$ (e.g., ('I','am','myself','.')).

Unit

The unit of the language model loss is determined by $b$.

$b$ Unit
2 Bit
e Nat
10 Hartley

Training reports conventionally quote $L_{\text{nat}}$.

Perplexity

See perplexity (LLM).