Introduction
Standard Transformer models, such as BERT, have revolutionized Natural Language Processing (NLP) but face a significant bottleneck: the quadratic scaling of their self-attention mechanism. This typically limits input sequences to 512 tokens, roughly a single page of text. While sparse attention variants like BigBird and Longformer extend this to 4,096 tokens, they often struggle with extremely long documents (e.g., legal filings or books) and fail to capture high-level structural dependencies between distant segments.
HiPool (Hierarchical Pooling) addresses these limitations by replacing sequential hierarchical layers with a graph-based structure. By chunking documents and modeling their relationships through a hierarchical graph with a novel heterogeneous attention mechanism, HiPool achieves state-of-the-art results on long-text classification tasks, outperforming established baselines by significant margins on the longest datasets.
Methodology: The HiPool Framework
The HiPool architecture consists of three primary stages designed to encode long-range dependencies efficiently.
1. Overlapping Sequence Encoder
To process a long document, HiPool first partitions the text into fixed-length chunks (e.g., 300 tokens). A critical feature is the use of overlapping segments (e.g., 150-token overlap), which prevents context loss at chunk boundaries. Each chunk is processed by a pretrained encoder (BERT or RoBERTa) to generate a vector representation, typically using the [CLS] token.
2. HiPool Graph Encoder
The core innovation of HiPool is its graph-based hierarchy. The chunk representations are treated as "low-level nodes" in a graph.
- Hierarchical Clustering: Adjacent low-level nodes are grouped into "high-level nodes" based on their relative positions in the document.
- Heterogeneous Attention: A novel attention mechanism computes two types of relationships: intra-sentence (correlations within a cluster) and cross-sentence (correlations between a high-level node and chunks outside its immediate cluster). This allows the model to capture both local context and global document structure.
3. Aggregation and Classification
A Graph Convolutional Network (GCN) processes the nodes, allowing information to flow across the document graph. Finally, a sum aggregator combines these representations into a single document embedding, which is passed to a linear layer for classification.
Experimental Setup
The researchers evaluated HiPool across several benchmarks:
- Standard Datasets: Hyperpartisan (HYP), 20NewsGroups (20NG), IMDB, and ILDC (Indian legal cases).
- Long-Document Benchmarks: To specifically test long-range modeling, the authors introduced Amazon-512 and Amazon-2048, filtered from product reviews to ensure high token counts.
The ILDC dataset is particularly challenging, with an average document length exceeding 4,000 tokens and some instances reaching 500,000 tokens.
Results and Discussion
HiPool demonstrated superior performance, particularly as document length increased. HiPool-RoBERTa achieved an average F1 score of 0.794, surpassing BigBird (0.774) and Longformer (0.768). On the ILDC dataset, HiPool outperformed the best baseline by 4.8%.
Key Insights
- Non-Linear Structural Modeling: By treating a document as a graph, HiPool enables high-level nodes to "see" distant parts of the text without passing information through every intermediate chunk. This effectively mitigates the information loss issues seen in sequential hierarchical models.
- Scalability: Unlike models with fixed attention windows that often plateau, HiPool's performance improves steadily as more of the input sequence is utilized. This scalability is inherent to the graph structure, where adding more text simply involves adding more nodes.
- Importance of Overlap: Ablation studies confirmed that overlapping chunks are vital. This "information leakage" between segments helps the GNN maintain a coherent global flow of information.
Conclusion
HiPool offers a robust solution for long-document encoding by leveraging the strengths of GNNs. While currently optimized for English-language classification, its hierarchical graph approach is a promising foundation for other long-form tasks such as summarization or question answering. Future work may explore more advanced GNN architectures to further enhance its relational modeling capabilities.
Summary updated