Predictive Coding with Neural Nets: Application to Text Compression

Jürgen Schmidhuber, Stefan HeilNeurIPS 1994

TL;DR

This paper demonstrates that neural networks can significantly improve text compression by accurately predicting the probability of the "next character" in a sequence. By pairing a neural predictor with standard entropy coding (like Arithmetic Coding), the authors outperformed industry-standard Lempel-Ziv algorithms (e.g., gzip) on German text.

The Challenge of Predictive Coding

Data compression is essentially a game of prediction. If an algorithm can perfectly predict the next character in a file, that character requires zero bits to store. Traditional algorithms like Lempel-Ziv (the basis for zip and gzip) work by finding repeating strings or patterns. However, these methods have limits in how well they can model the complex, underlying "grammar" of a natural language.

The authors tackle the challenge of predictive coding: using a model to estimate the conditional probability of a character given its predecessors. The better the model's predictions, the fewer bits are required to encode the actual data. The specific gap they address is whether a neural network—with its ability to generalize—can provide better probability estimates than traditional statistical methods or massive look-up tables.

Proposed Methodology

The authors propose a two-stage system separating the "intelligence" from the mathematical encoding:

  1. The Neural Predictor ($P$): A feed-forward neural network trained via back-propagation. It takes a "time-window" of $n$ previous characters (represented as one-hot encoded vectors) and outputs a probability distribution for the next character.
  2. The Coder: The predicted probabilities are fed into either Huffman Coding or Arithmetic Coding. These algorithms assign short bit-sequences to highly probable characters and long sequences to unlikely ones.

The paper highlights two operational variants:

  • Off-line: The network is trained on a large corpus of text, and its weights are frozen. Both the sender and receiver have identical copies of these weights.
  • On-line: Both the sender and receiver start with the same initial weights and update them continuously as they process the file. This allows the model to adapt to the specific style of a new document without needing to transmit weight updates.

Datasets

The experiments focused on German newspaper articles with an alphabet of $k=80$ characters (including upper/lower case, digits, and special German characters like ä, ö, ü, ß).

  • Training Set: 40 articles from the Münchner Merkur (approx. 10,000–20,000 characters each).
  • Test Set A: Unseen articles from the same newspaper (Münchner Merkur).
  • Test Set B: 10 articles from a different newspaper (Frankenpost) to test how well the model generalizes to different writing styles.

Key Results

The "neural" method consistently beat the standard UNIX tools of the era across both test sets.

Performance on Test Set A

On texts drawn from the same distribution as the training data, the neural predictor paired with Arithmetic Coding achieved a compression ratio of 2.72, significantly outperforming gzip -9 (2.29) and standard compress (1.99).

Compression Ratios on Test Set A

Generalization (Test Set B)

To test generalization, the authors evaluated the models on the Frankenpost dataset, which featured a writing style the model hadn't seen during training. Even here, the neural method achieved a ratio of 2.20, maintaining its lead over gzip (2.03).

Compression Ratios on Test Set B

Key Insights

  • Generalization vs. Memory: A simple look-up table for character sequences is inefficient because it grows exponentially ($k^{n+1}$). A neural network's size grows much more slowly (roughly $n^2$) and can "fill in the blanks" for character combinations it hasn't seen before.
  • Probabilistic Interpretation: By minimizing the squared error between the network's output and the actual character (one-hot encoded), the network naturally learns to output the conditional expectation, which is equivalent to the conditional probability in this context.
  • Separation of Modeling and Coding: The neural net doesn't "compress" the data directly; it provides the probability distribution that allows a standard mathematical coder to reach near-optimal efficiency.

Limitations and Future Work

  • Computational Complexity: This is the primary drawback. The authors admit the neural method is roughly three orders of magnitude (1,000x) slower than conventional techniques. They suggest that specialized neural network hardware would be necessary for practical use.
  • Small Context Window: The study used a very small window of only 5 characters ($n=5$). The authors expect that increasing the window size or using Recurrent Neural Networks (RNNs) would yield even better compression ratios.
  • On-line Implementation: While theoretically superior, the on-line learning variant was even more computationally expensive and was not the primary focus of the simulation results.

Summary updated

BibTeX
@inproceedings{schmidhuber1994predictive,
  author = {Jürgen Schmidhuber and Stefan Heil},
  title = {{Predictive Coding with Neural Nets: Application to Text Compression}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {1994},
  url = {https://openreview.net/forum?id=HJZJ_dZ_ZH},
}
Figure