Abstract
Graph Neural Networks (GNNs) have demonstrated significant potential in text classification by capturing global word co-occurrences. However, existing GNN-based models often struggle with scalability and the inherent heterogeneity of text graphs. This paper introduces the Text Graph Transformer (TG-Transformer), a novel architecture that utilizes PageRank-based mini-batch sampling and structural encodings to overcome these limitations. TG-Transformer achieves state-of-the-art accuracy across multiple benchmarks while maintaining high efficiency and scalability, enabling its application to large-scale datasets previously inaccessible to graph-based methods.
Introduction
Traditional sequence models like LSTMs and local models like CNNs often fail to capture long-range, global word dependencies across an entire corpus. While GNNs address this by modeling text as a graph, they face two primary hurdles: scalability and heterogeneity. Models like TextGCN typically require loading the entire graph into memory, making them impractical for large datasets. Furthermore, they often ignore the distinct roles of document and word nodes. TG-Transformer addresses these issues by combining the global perspective of GNNs with the efficiency of the Transformer architecture.
Methodology
Heterogeneous Graph Construction and Sampling
The TG-Transformer pipeline begins with the construction of a heterogeneous graph where nodes represent either documents or words. Edges are weighted using TF-IDF for word-document pairs and Point-wise Mutual Information (PMI) for word-word pairs. To ensure scalability, the model employs a PageRank-based intimacy score to sample subgraphs. For any target node, only the top-$k$ most "intimate" neighbors are selected, allowing for efficient mini-batch training.
Structural and Heterogeneity Encodings
Because standard Transformers are permutation-invariant, TG-Transformer injects structural information directly into the node embeddings:
- Heterogeneity Encoding: A binary flag distinguishing document nodes from word nodes.
- Weisfeiler-Lehman (WL) Structural Encoding: Captures the local topological role of a node within its neighborhood.
These encodings are combined with raw feature embeddings and processed through Graph Transformer layers. These layers utilize attention mechanisms and graph residual terms (G-Res) to prevent the common GNN issue of over-smoothing.
Experimental Results
Performance and Scalability
TG-Transformer was evaluated against several baselines, including CNN, LSTM, and previous GNN models like TextGCN and Tensor GCN. The results demonstrate that TG-Transformer consistently achieves state-of-the-art accuracy. Notably, it is the only graph-based model in the study capable of scaling to large datasets like IMDB and Yelp 2014, where previous methods failed due to memory constraints.
Efficiency Gains
Beyond accuracy, the model offers significant computational advantages. On the R52 dataset, TG-Transformer achieved a training time of 0.83s per epoch, compared to 4.32s for Tensor GCN. Ablation studies further confirmed that both structural encodings and pre-trained embeddings are critical to the model's success, with performance dropping when these components were removed.
Conclusion
TG-Transformer represents a significant step forward in making graph-based text classification practical for real-world, large-scale applications. By leveraging intelligent sampling and structure-aware attention, it bridges the gap between the expressive power of GNNs and the scalability of Transformers. Future work may explore learnable sampling methods and the potential for large-scale pre-training on heterogeneous graph structures.
Summary updated