Abstract
Recurrent Neural Networks (RNNs), particularly LSTMs, have long been the standard for character-level language modeling. While these models rely on truncated backpropagation through time to capture long-term dependencies, they often struggle with extremely long contexts. We demonstrate that a deep, 64-layer Transformer model with a fixed context window significantly outperforms RNN variants. By achieving 1.13 bits per character (bpc) on text8 and 1.06 bpc on enwik8, we establish a new state of the art. Our results indicate that the successful training of such deep architectures requires the integration of auxiliary losses at both intermediate network layers and intermediate sequence positions.
Introduction
Character-level language modeling presents a unique challenge: models must learn everything from basic spelling to complex syntactic structures and long-range semantic relationships without pre-defined word boundaries. Traditionally, the sequential nature of RNNs made them the preferred choice for this task. However, the step-by-step processing of RNNs creates a bottleneck for information flow over long distances.
In contrast, the Transformer architecture utilizes self-attention, allowing information to "jump" across arbitrary distances in a single step. This provides a significant advantage for character-level tasks where dependencies may span hundreds of characters. This paper explores whether scaling Transformers to unprecedented depths (64 layers) can further push the boundaries of character-level modeling.
Methods: Scaling to 64 Layers
Training a 64-layer Transformer is inherently unstable due to gradient vanishing or explosion. To facilitate convergence and provide stronger supervision to lower layers, we introduced three types of auxiliary losses as shown in the figure below:
- Multiple Positions: The model predicts the next character at every position in the input sequence, rather than just the final position.
- Intermediate Layer Losses: Auxiliary classifier heads are attached to every layer in the 64-layer stack. These heads force lower layers to develop useful representations early in the network. These losses are gradually decayed during training.
- Multiple Targets: At each sequence position, the model is tasked with predicting multiple future characters (e.g., $t+1$ and $t+2$).
Furthermore, we replaced standard sinusoidal positional encodings with learned per-layer positional embeddings to ensure timing information is preserved throughout the deep stack.
Key Results and Analysis
Our 64-layer model (T64) achieved state-of-the-art performance on two major benchmarks:
- text8: 1.13 bpc
- enwik8: 1.06 bpc
Ablation studies confirmed that "Multiple Positions" and "Intermediate Layer Losses" were the most critical components. Removing the multiple positions loss, for instance, caused performance to degrade from 1.06 to 2.48 bpc. Even a smaller 12-layer version of our model outperformed many larger, more complex RNN variants.
Qualitative analysis revealed that the model is particularly adept at a "copying mechanism," where it can accurately predict rare strings or made-up names by attending to their previous occurrences in the context, even when those occurrences are over 400 characters away.
Conclusion
Deep Transformers prove to be highly effective for character-level language modeling, surpassing traditional RNNs by leveraging the "shortcuts" provided by self-attention. While the 64-layer depth requires careful supervision via auxiliary losses, the resulting models demonstrate superior ability in capturing long-range dependencies. Future work will focus on reducing the inference cost associated with re-processing the context window for each new character.
Summary updated