[Paper Review] ERNIE-Doc: A Retrospective Long-Document Modeling Transformer
ERNIE-Doc proposes a retrospective long-document modeling Transformer that overcomes the context fragmentation problem in long-sequence modeling by introducing a retrospective feed mechanism and an enhanced recurrence mechanism, enabling full-document context awareness during training. It achieves state-of-the-art results, including a perplexity of 16.8 on WikiText-103 and significant improvements on multiple English and Chinese NLU tasks.
Transformers are not suited for processing long documents, due to their quadratically increasing memory and time consumption. Simply truncating a long document or applying the sparse attention mechanism will incur the context fragmentation problem or lead to an inferior modeling capability against comparable model sizes. In this paper, we propose ERNIE-Doc, a document-level language pretraining model based on Recurrence Transformers. Two well-designed techniques, namely the retrospective feed mechanism and the enhanced recurrence mechanism, enable ERNIE-Doc, which has a much longer effective context length, to capture the contextual information of a complete document. We pretrain ERNIE-Doc to explicitly learn the relationships among segments with an additional document-aware segment-reordering objective. Various experiments were conducted on both English and Chinese document-level tasks. ERNIE-Doc improved the state-of-the-art language modeling result of perplexity to 16.8 on WikiText-103. Moreover, it outperformed competitive pretraining models by a large margin on most language understanding tasks, such as text classification and question answering.
Motivation & Objective
- Address the context fragmentation problem in long-document modeling caused by fixed-sequence attention in standard Transformers.
- Overcome the limitations of sparse attention and standard recurrence Transformers, which restrict effective context length and fail to utilize full-document information during training.
- Enable bidirectional modeling of complete documents by allowing each segment to attend to the entire document context during training.
- Improve document-level representation learning through a novel document-aware segment-reordering objective that models inter-segment relationships.
- Achieve state-of-the-art performance on long-context language modeling and downstream NLU tasks in both English and Chinese.
Proposed method
- Introduce a retrospective feed mechanism where document segments are processed twice: first in a skimming phase to build initial representations, then in a retrospective phase where each segment attends to the full document context.
- Propose an enhanced recurrence mechanism that replaces layer-wise shifting with same-layer recurrence, allowing higher-level representations to be reused across layers and significantly increasing the effective context length.
- Design a document-aware segment-reordering objective to pretrain the model on predicting the correct order of shuffled document segments, thereby learning inter-segment relationships.
- Train ERNIE-Doc using autoregressive language modeling with the enhanced recurrence mechanism, enabling theoretical infinite sequence length processing.
- Pretrain the model on large-scale English and Chinese corpora, fine-tuning on diverse downstream NLU tasks including text classification, question answering, and semantic similarity.
- Leverage the [CLS] token from the segment-reordering objective to improve document-level classification performance by capturing global document structure.
Experimental results
Research questions
- RQ1Can a Transformer-based model effectively model long documents without context fragmentation, even when input sequences are split into fixed-length segments?
- RQ2How can the effective context length of a Transformer be extended beyond the limitations of quadratic attention and sparse attention mechanisms?
- RQ3To what extent does incorporating full-document context during training improve downstream document-level understanding tasks?
- RQ4Does a document-aware pretraining objective based on segment reordering enhance the model’s ability to capture long-range dependencies and inter-segment relationships?
- RQ5Can the enhanced recurrence mechanism reduce the required maximum sequence length during pretraining while maintaining or improving model performance?
Key findings
- ERNIE-Doc achieved a state-of-the-art perplexity of 16.8 on the WikiText-103 benchmark, outperforming previous models in autoregressive language modeling.
- On the TQA and HYP English question-answering tasks, ERNIE-Doc -Small achieved F1 scores of 64.56 and 86.10, respectively, with ablation studies showing that each proposed component contributed significantly to performance.
- The segment-reordering objective led to a 1.5 percentage point improvement on the HYP dataset, indicating its effectiveness for long-text classification tasks.
- The enhanced recurrence mechanism enabled ERNIE-Doc -Small with a maximum sequence length of 128 to achieve comparable accuracy to a model with length 512, demonstrating its efficiency in reducing computational cost.
- On seven Chinese NLU tasks, including long-text classification and machine reading comprehension, ERNIE-Doc outperformed previous models by a large margin in the base-size model group.
- Ablation studies confirmed that removing any of the key components—retrospective feed, enhanced recurrence, or segment-reordering—resulted in consistent and significant performance drops across tasks.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.