Alternative structures for character-level RNNs

Piotr Bojanowski, Armand Joulin, Tomás MikolovarXiv 2015

Abstract

Recurrent neural networks are convenient and efficient models for language modeling. However, when applied on the level of characters instead of words, they suffer from several problems. In order to successfully model long-term dependencies, the hidden representation needs to be large. This in turn implies higher computational costs, which can become prohibitive in practice. We propose two alternative structural modifications to the classical RNN model. The first one consists on conditioning the character level representation on the previous word representation. The other one uses the character history to condition the output probability. We evaluate the performance of the two proposed modifications on challenging, multi-lingual real world data.

Introduction

Traditional language models typically operate at the word level. While effective, these models often struggle with subword information, treating related tokens like "build," "building," and "buildings" as entirely distinct entities. This leads to challenges with out-of-vocabulary (OOV) words, typos, and morphologically rich agglutinative languages like Finnish or Turkish, where massive vocabularies make word-level modeling impractical.

Character-level Recurrent Neural Networks (Char-RNNs) address these issues by processing text one character at a time. However, to capture long-term dependencies across long sequences, they require large hidden layers, making them computationally expensive and slow to train. This paper explores two structural modifications designed to increase model capacity and accuracy without significantly increasing computational overhead.

Proposed Architectural Modifications

The authors propose two distinct methods to add "cheap" capacity to standard Char-RNNs by offloading some of the representational burden from the hidden layer.

1. The Mixed Model (Conditioning on Words)

This architecture utilizes a dual-network approach. A "slow" word-level RNN processes the text to produce a context vector for each word, which is then fed into a "fast" character-level RNN. By informing the character-level model of the current word it is spelling, the internal memory can focus on local character patterns rather than global sentence structure.

2. The Conditional Model (Conditioning on History)

In a standard RNN, the next character is predicted based solely on the hidden state. The proposed bilinear model makes the output dependent on both the hidden state and the recent character history (n-grams). Because n-grams are represented as sparse one-hot vectors, this significantly increases parameter count (capacity) without a proportional increase in floating-point operations per step.

Architectural diagrams for the Mixed model (left) and the Conditional model (right).

Experimental Results and Efficiency

The models were evaluated on the Penn Treebank (PTB) and the multi-lingual Europarl dataset. A key finding was the efficiency gain provided by the Conditional model. On the PTB benchmark, a Conditional model with a 300-unit hidden layer achieved performance comparable to a standard Char-RNN with a 1000-unit hidden layer. As shown in the table below, this reduction in hidden layer size translates to a significant speedup in training time—approximately 5x to 7x faster per epoch while maintaining competitive bits-per-character (BPC) metrics.

Validation BPC and training time comparison across model types and hidden layer sizes (m).

Multi-lingual Robustness

The proposed modifications proved particularly effective for morphologically rich languages. In experiments across 20 languages in the Europarl dataset, the Conditional model consistently outperformed the baseline. For example, in Finnish, the model achieved a BPC of 1.38 compared to the baseline's 1.63. By explicitly modeling short-term statistics via n-gram conditioning, the hidden layer is freed to learn more complex, long-distance linguistic patterns.

Conclusion

By introducing structural modifications like n-gram conditioning and word-level context, Char-RNNs can achieve high performance with much smaller hidden layers. These techniques leverage sparsity to increase model capacity efficiently, making character-level modeling a viable and powerful alternative for a wide range of languages and sequential data tasks.

Summary updated

BibTeX
@misc{bojanowski2015alternative,
  author = {Piotr Bojanowski and Armand Joulin and Tomás Mikolov},
  title = {{Alternative structures for character-level RNNs}},
  year = {2015},
  eprint = {1511.06303},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1511.06303},
}
Figure