liveBook · Manning

Perplexity

As explained in Transformers in Action

Perplexity is a language-modeling metric equal to the exponential of average cross-entropy loss, measuring how well a model predicts a target token distribution.

Perplexity measures how well a language model predicts a target token distribution. It equals the exponential of average cross-entropy loss, so lower values indicate better fit and less surprise on the evaluation data. section 7.4

How Transformers in Action covers it

How deep it goes
Defines the metric and works through tokenization, padding, loss masking, batching, averaging, and exponentiation.
Examples
Compares base and fine-tuned Gemma checkpoints on up to 500 chat-formatted evaluation examples.
What it assumes
Assumes language-model evaluation, tokenization, chat templates, and model loss interfaces.
What you can do after
Diagnose/debug with it: Compare checkpoint fit using a batched PyTorch calculation that ignores padded tokens.
How it connects
Connects language modeling, cross-entropy loss, tokenization, chat templates, causal language models, and supervised fine-tuning.

Also explained in

Compare how 5 books explain perplexity →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Transformers in Action. The section links point to the parts of the book it draws on.