[Paper Review] An Exploration of Hierarchical Attention Transformers for Efficient Long Document Classification
This paper proposes fully pre-trained Hierarchical Attention Transformers (HATs) that process long documents via segment-wise and cross-segment attention, outperforming equally-sized Longformer models in downstream classification tasks while reducing GPU memory usage by 10–20% and accelerating inference by 40–45%. The best HAT configuration uses cross-segment contextualization throughout the network.
Non-hierarchical sparse attention Transformer-based models, such as Longformer and Big Bird, are popular approaches to working with long documents. There are clear benefits to these approaches compared to the original Transformer in terms of efficiency, but Hierarchical Attention Transformer (HAT) models are a vastly understudied alternative. We develop and release fully pre-trained HAT models that use segment-wise followed by cross-segment encoders and compare them with Longformer models and partially pre-trained HATs. In several long document downstream classification tasks, our best HAT model outperforms equally-sized Longformer models while using 10-20% less GPU memory and processing documents 40-45% faster. In a series of ablation studies, we find that HATs perform best with cross-segment contextualization throughout the model than alternative configurations that implement either early or late cross-segment contextualization. Our code is on GitHub: https://github.com/coastalcph/hierarchical-transformers.
Motivation & Objective
- To investigate the efficacy and efficiency of fully pre-trained Hierarchical Attention Transformers (HATs) for long document classification.
- To compare HATs with sparse attention models like Longformer and BigBird in terms of performance and computational efficiency.
- To evaluate the impact of end-to-end pre-training versus ad-hoc (partially pre-trained) HATs on downstream task performance.
- To determine optimal architectural configurations of segment-wise and cross-segment attention layers in HATs.
- To assess the computational advantages of HATs in training and inference, especially in memory and speed.
Proposed method
- The authors design HAT models with two core components: Segment-wise Encoder (SWE) for local context modeling within document segments, and Cross-segment Encoder (CSE) for inter-segment attention.
- The models apply cross-segment attention throughout the network, enabling hierarchical contextualization from word-level to document-level representations.
- Four HAT variants are evaluated, differing in when cross-segment attention is applied: early, late, interleaved, or full cross-segment contextualization.
- All HAT models are pre-trained end-to-end using masked language modeling (MLM) on long documents, with full weights initialized from scratch.
- The authors release fully pre-trained HAT models and code on GitHub and HuggingFace Hub for reproducibility and community use.
- Performance is evaluated on multiple long document classification benchmarks, with comparisons to Longformer and BigBird under identical hardware and model size constraints.
Experimental results
Research questions
- RQ1Which architectural configuration of segment-wise and cross-segment attention layers in HATs yields the best performance on long document classification tasks?
- RQ2How does end-to-end pre-training of HATs compare to ad-hoc (partially pre-trained) HATs in terms of downstream performance?
- RQ3Do HATs offer computational advantages—such as reduced memory usage and faster inference—compared to widely used sparse attention models like Longformer and BigBird?
- RQ4What is the trade-off between model efficiency and performance when using HATs versus Longformer in long sequence processing?
Key findings
- The HAT model with cross-segment contextualization applied throughout the network achieves the highest performance across all evaluated long document classification tasks.
- The best HAT model outperforms an equally-sized Longformer model on multiple downstream tasks, including legal and biomedical text classification.
- HATs reduce GPU memory consumption by 10–20% and accelerate inference by 40–45% compared to Longformer, even after pre-training.
- End-to-end pre-training of HATs leads to substantially better performance than ad-hoc fine-tuning with randomly initialized cross-segment blocks, especially in smaller-scale experiments.
- HATs demonstrate superior computational efficiency compared to both Longformer and BigBird, due to smaller attention windows and hierarchical processing.
- The HAT architecture shows consistent gains in inference speed and memory efficiency, even when accounting for training-phase compute, indicating long-term deployment advantages.
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.