Recurrent Neural Networks Meet Context-Free Grammar: Two Birds with One Stone
This work addresses a key challenge in the effective adoption of Recurrent Neural Networks (RNNs) by reducing inference time and expanding the scope of a prediction. It introduces compressed learning, a novel approach that integrates Context-Free Grammar (CFG) and online tokenization into the training and inference of RNNs for streaming inputs. Through a hierarchical compression algorithm, it compresses an input sequence to a CFG and makes predictions based on the compressed sequence. Its algorithm design employs a set of techniques to overcome the issues from the myopic nature of online tokenization, the tension between inference accuracy and compression rate, and other complexities in sequence compression and prediction. Its effectiveness is theoretically analyzed and empirically validated on 16 real-world sequences, including program function calls, memory traces, and system logs. Empirical results demonstrate that compressed learning can successfully recognize and leverage repetitive patterns in input sequences, and effectively translate them into dramatic (1–1,762 \(\times\) ) inference speedups as well as much (1–7,830 \(\times\) ) expanded prediction scope, while keeping the inference accuracy satisfactory.
Authors
- Yuanchao Xu (ORCID: https://orcid.org/0000-0003-4165-9138)
- Lin Ning (ORCID: https://orcid.org/0000-0001-9458-7946)
- Umang Chaudhary (ORCID: https://orcid.org/0009-0005-6654-6617)
- Hui Guan (ORCID: https://orcid.org/0000-0001-9128-2231)
- Xipeng Shen (ORCID: https://orcid.org/0000-0003-3599-8010)
- Lijun Zhang (ORCID: https://orcid.org/0000-0003-1946-7105)
Institutions
- North Carolina State University (US)
- University of Massachusetts Amherst (US)
Publication Details
- Journal
- ACM Transactions on Knowledge Discovery from Data
- Published
- 2025-12-18
- DOI
- https://doi.org/10.1145/3785464
- Primary Topic
- Machine Learning and Algorithms
- Type
- article
- Field-Weighted Citation Impact
- 0.00