Jump to content

Language model loss: Difference between revisions

From Wikibase
Notation: loss is L (via update-page on MediaWiki MCP Server)
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
[[Category:Machine learning]]
[[Category:Large language model]]
[[Category:Large language models]]
 
 
The '''language model loss''' measures how "surprised" a [[large language model (LLM)]] is by the true values of tokens it attempts to predict.
The '''language model loss''' measures how "surprised" a [[large language model (LLM)]] is by the true values of tokens it attempts to predict.


Line 16: Line 13:


<blockquote>
<blockquote>
$\vec x=(x_1,\cdots,x_T)$ is a text [[token]] sequence of length $T$ (e.g., <code>('I','am','myself','.')</code>).
$\vec x=(x_1,\cdots,x_T)$ is a text [[token (machine learning)|token]] sequence of length $T$ (e.g., <code>('I','am','myself','.')</code>).
</blockquote>
</blockquote>


Line 44: Line 41:
== Perplexity ==
== Perplexity ==


Perplexity is the exponential of the loss in nats,
See [[perplexity (LLM)]].


$$
== Loss and training compute budget ==
\operatorname{PP}(\theta) = \exp\big(C_{\text{nat}}(\theta)\big),
$$
 
and reads as the effective number of equally likely tokens the model is choosing between. A loss of $1$ nat per token therefore corresponds to a perplexity of $e \approx 2.718$.
 
== Irreducible loss ==
 
The loss is bounded below by the [[conditional entropy]] of the text itself, since no model predicts next tokens better than the true distribution generates them.
 
== Loss and compute ==


It is empirically determined
It is empirically determined


$$
$$
C(F) \prop F^{-\alpha},
L(C) \propto C^{-\alpha},
\qquad \alpha \approx 0.05.
\qquad \alpha \approx 0.05.
$$
$$
where $C$ is the [[training compute budget]].
As a consequence, halving the loss requires roughly $10^{6}$ times more compute.


The exponent governs how expensive further improvement is: halving the loss requires roughly $10^{6}$ times more compute, which is why the gap between $2$ nats per token and $1$ nat per token, a perplexity fall from $7.389$ to $2.718$, is very large in practice.<ref>{{#cite:Q3141}}</ref>
<ref>{{#cite:Q3141}}</ref>

Latest revision as of 08:36, 12 November 2026

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).

Loss and training compute budget

It is empirically determined

$$ L(C) \propto C^{-\alpha}, \qquad \alpha \approx 0.05. $$ where $C$ is the training compute budget.

As a consequence, halving the loss requires roughly $10^{6}$ times more compute.

[1]