Abstract
Traditional neural sequence models require raw, decompressed data, leading to significant computational overhead in time and memory when dealing with massive compressed corpora. This paper proposes a method to train models directly on grammar-compressed text. By utilizing a "composer module" to recursively generate vector representations for compressed symbols, we achieve up to a 5x training speedup and substantial memory savings with only a minor decrease in classification accuracy.
Introduction
In the era of "Big Data," text and genomic sequences are typically stored in compressed formats. Standard machine learning workflows necessitate a "decompression bottleneck," where data must be expanded before training. This process is time-consuming, memory-intensive, and can pose privacy risks in sensitive domains like genomics. We bridge this gap by enabling neural networks to learn directly from compressed representations, treating grammar compression as a hierarchical structure.
Methodology
The proposed approach leverages grammar compression algorithms like Re-Pair and LZD, which represent text as context-free grammar (CFG) rules.
The Composer Module
Since compressed "non-terminal" symbols are unique to individual files, they cannot be handled by standard embedding tables. We introduce a Composer Module ($M$) that generates representations for these symbols. While a simple MLP is possible, our Dual-GRU module—a modified Gated Recurrent Unit—effectively merges input vectors to capture the sequential nature of the underlying text.
Parallel Computation
To handle the hierarchical nature of CFG rules (where some symbols depend on others), we implement a Clustering Algorithm. This organizes rules by depth, allowing the GPU to compute independent rules at each level in parallel, maintaining high throughput.
Experimental Evaluation
We evaluated the method on character-level text classification (Sogou News, Yelp Review) and DNA sequence classification (histone protein sequences).
Training Efficiency and Memory Usage
The method demonstrates significant gains in efficiency. On the Sogou dataset, training was approximately 5 times faster per sequence compared to a baseline Bi-LSTM. DNA datasets saw a 3x speedup. Furthermore, peak GPU memory usage was drastically reduced, particularly for datasets with high compression ratios.
Accuracy Trade-offs
While efficiency improved, there was a slight performance cost. For Sogou, the error rate increased from 4.18% to 5.14%. In DNA classification, accuracy typically dropped by less than 5 percentage points. The Dual-GRU architecture was found to be superior to an MLP for the composer module, better preserving model performance.
Conclusion and Future Work
Learning directly from compressed text offers a viable path for scaling sequence models to massive datasets. Future work will focus on closing the accuracy gap, extending the method to sliding-window compression (like DEFLATE), and exploring compatibility with Transformer architectures.
Summary updated