Abstract
In this paper, we propose Dynamic Compressive Transformer (DCT), a transformer-based framework for modeling the unbounded sequence. In contrast to the previous baselines which append every sentence representation to memory, conditionally selecting and appending them is a more reasonable solution to deal with unlimited long sequences. Our model uses a policy that determines whether the sequence should be kept in memory with a compressed state or discarded during the training process. With the benefits of retaining semantically meaningful sentence information in the memory system, our experiment results on Enwik8 benchmark show that DCT outperforms the previous state-of-the-art (SOTA) model.
Introduction
Standard Transformers face significant challenges when processing "unbounded" sequences, such as entire books, due to the quadratic scaling of self-attention mechanisms. While architectures like Transformer-XL and Compressive Transformers have introduced memory buffers to handle longer contexts, they typically employ a First-In-First-Out (FIFO) policy. This approach treats all information equally, dropping the oldest data regardless of its semantic importance.
The Dynamic Compressive Transformer (DCT) addresses this by introducing a selective memory mechanism. By mimicking human-like selective attention, DCT identifies and preserves semantically meaningful information while discarding noise, allowing for more efficient and effective long-range modeling.
Methods: The Selective Memory Architecture
The DCT framework integrates a reinforcement learning-based "judger" with a standard Compressive Transformer backbone.
The system consists of two primary components:
- Compressive Transformer: Processes sequences and generates hidden representations.
- Compression Judger: A reinforcement learning (RL) agent that manages the memory buffer. It includes an Actor (a BiLSTM encoder) that decides whether to Keep or Discard evicted memory, and an Evaluator (a frozen GPT-2 model) that provides a stable baseline for reward calculation based on perplexity.
The model is trained using the REINFORCE algorithm, where the reward is tied to the model's ability to minimize perplexity. If keeping a specific memory segment improves future token prediction, the agent is rewarded, effectively learning a heuristic for "semantic importance."
Experimental Results
The authors evaluated DCT on the Enwik8 dataset, a standard character-level language modeling benchmark consisting of 100MB of English Wikipedia text. This dataset is particularly challenging as it requires predicting the next character based on a massive historical context.
As shown in the results, DCT achieved a Bits-Per-Character (BPC) of 0.963, outperforming the 8-layer Compressive Transformer (0.978) and even the significantly larger 24-layer Transformer-XL (0.99). These results suggest that the quality of information retained in memory is more critical than the sheer quantity. By being selective, a smaller 8-layer DCT can surpass the performance of much larger models.
Conclusion
DCT demonstrates that dynamic, policy-driven memory management is a powerful alternative to static FIFO buffers for long-range sequence modeling. While the current implementation faces computational overhead—training for approximately 10 days on a single GPU—the shift toward "selective memory" opens new avenues for efficient processing of massive datasets. Future work may involve incorporating contrastive learning to further refine the Actor's understanding of sentence embeddings and testing the architecture on non-textual domains like DNA sequence analysis.
Summary updated