RNN Architecture › Training Loss and Convergence

Michael BrenndoerferMay 7, 20252 min read
Language AI HandbookAll chapters
Part 11 of 67Recurrent Neural Networks
Chapter 74RNN Architecture › Training Loss and Convergence
Reading section 15 of 19 · Training Loss and Convergence · 2 minSection 15 of 19 · 2 min

Book contents

Section 15 of 19 · 2 min read

RNN Architecture › Training Loss and ConvergenceOne section · Sections in this chapter15 / 19 ↓
Reading tools Definitions & inline links

Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.

Article links

Make inline references clickable

Visualizing the training loss curve shows how quickly the model is learning to predict the next character.

Out[18]:
Visualization
Line plot of cross-entropy training loss declining from an initial high value over 30 training epochs.
Cross-entropy training loss per epoch for the character-level RNN language model over 30 epochs. The loss decreases steeply in the early epochs as the model learns common character transition patterns, then continues declining more gradually as it captures longer-range sequential dependencies.

A character-level RNN trained on a short corpus learns letter-transition probabilities, common bigrams and trigrams, and some word-level structure, all from the sequential character stream. The hidden state is doing the heavy lifting of remembering which characters have appeared and in what pattern. The steepest descent in loss typically occurs in the first few epochs as the model moves from near-uniform predictions to learning the most frequent character transitions. Later epochs fine-tune the model's handling of less frequent patterns.

Understanding Cross-Entropy Loss for Language Models

It is worth pausing on what the cross-entropy loss value means in practical terms. A random predictor over a vocabulary of size VV has expected cross-entropy log⁡2V\log_2 V bits per token. For our character vocabulary of about 30 characters, that is roughly log⁡230≈4.9\log_2 30 \approx 4.9 bits. If our trained model achieves a loss of around 2.0 nats (≈2.9\approx 2.9 bits), it has learned meaningful structure that compresses the character stream significantly below the random baseline.

The concept of perplexity converts cross-entropy to a more interpretable scale. Perplexity is PPL=eL\text{PPL} = e^{\mathcal{L}} (in nats) or 2L2^{\mathcal{L}} (in bits). A model with perplexity 10 is, on average, as uncertain between 10 equally likely options at each step. Lower perplexity means the model is more confident and more accurate. For reference, well-tuned word-level language models on large corpora achieve perplexities in the range of 20 to 100, while simple baselines start near the vocabulary size.