DeepZip: Lossless Data Compression using Recurrent Neural Networks

Mohit Goyal, Kedar Tatwawadi, Shubham Chandak, Idoia Ochoa

Abstract

Sequential data is being generated at an unprecedented pace in various forms, including text and genomic data. This creates the need for efficient compression mechanisms to enable better storage, transmission and processing of such data. To solve this problem, many of the existing compressors attempt to learn models for the data and perform prediction-based compression. Since neural networks are known as universal function approximators with the capability to learn arbitrarily complex mappings, and in practice show excellent performance in prediction tasks, we explore and devise methods to compress sequential data using neural network predictors. We combine recurrent neural network predictors with an arithmetic coder and losslessly compress a variety of synthetic, text and genomic datasets. The proposed compressor outperforms Gzip on the real datasets and achieves near-optimal compression for the synthetic datasets. The results also help understand why and where neural networks are good alternatives for traditional finite context models.

Introduction

The exponential growth of sequential data, such as genomic sequences and massive text corpora, has outpaced the efficiency of traditional storage and transmission methods. Conventional lossless compressors like Gzip, which rely on the LZ77 algorithm to find exact string repetitions, often struggle with "fuzzy" patterns or long-range dependencies. In the realm of information theory, compression is fundamentally a prediction problem: if a model can accurately predict the next symbol in a sequence, that symbol requires fewer bits to represent. DeepZip addresses this by replacing traditional statistical models with Recurrent Neural Networks (RNNs) to serve as a high-performance prediction engine.

The DeepZip Framework

The DeepZip system consists of two primary components: a neural network probability predictor and an arithmetic coder. The interaction between these components allows for a symmetric encoding and decoding process, as shown in Figure 2.

The DeepZip framework for encoding and decoding sequential data using a neural network predictor and arithmetic coding.

The workflow begins by training the neural network on the specific file to be compressed. The encoder uses the trained model to generate a probability distribution for each symbol based on its preceding context. These probabilities are fed into an arithmetic coder, which converts the data into a compact bitstream. To ensure lossless recovery, the model weights are stored alongside the compressed data, allowing the decoder to replicate the exact same probability estimates during decompression.

Neural Predictor Architectures

The authors evaluated several RNN architectures to optimize prediction accuracy. These include simple Fully Connected (FC) networks, bi-directional Gated Recurrent Units (biGRU), and a specialized multi-input LSTM (LSTM-multi). The LSTM-multi architecture, illustrated in Figure 1(b), is designed to combat the vanishing gradient problem by using multiple context inputs, ensuring the model retains information from the beginning of the context window.

Recurrent neural network architectures: (a) standard LSTM and (b) multi-input LSTM designed to capture long-range dependencies.

Experimental Results

DeepZip was tested on a variety of real-world and synthetic datasets, including human genomic sequences and the text8 Wikipedia corpus.

  • Performance on Real Data: DeepZip consistently outperformed Gzip by approximately 20% on genomic and text datasets.
  • Synthetic Logic: On complex synthetic datasets, such as k-order Markov XOR sequences, traditional compressors often fail, treating the data as random noise. DeepZip successfully learned the underlying mathematical rules, achieving near-theoretical compression limits.
  • Model Tax: For smaller files, the overhead of storing model weights (the "model tax") is a significant consideration. For a 15MB file, weight storage added between 0.17MB and 0.62MB to the final size.

Discussion and Conclusion

DeepZip demonstrates that "overfitting" can be a powerful tool in compression; by perfectly memorizing the patterns of a single file, the model minimizes the categorical cross-entropy loss, which is mathematically equivalent to minimizing the compression entropy.

While the computational cost of training models on a per-file basis is high—often requiring hours of GPU time—the framework offers a significant leap in compression ratios for archival data. Future improvements in weight quantization and pruning could further reduce the model tax, making deep learning-based compression a viable alternative for high-density data storage.

Summary updated

BibTeX
@misc{goyal2018deepzip,
  author = {Mohit Goyal and Kedar Tatwawadi and Shubham Chandak and Idoia Ochoa},
  title = {{DeepZip: Lossless Data Compression using Recurrent Neural Networks}},
  year = {2018},
  eprint = {1811.08162},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1811.08162},
}
Figure