NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

ConTextING: Granting Document-Wise Contextual Embeddings to Graph Neural Networks for Inductive Text Classification

Yen-Hao Huang, Yi-Hsin Chen, Yi-Shin ChenCOLING 2022

Abstract

ConTextING is a unified framework for inductive text classification that integrates the sequential modeling capabilities of BERT with the structural reasoning of Graph Neural Networks (GNNs). By utilizing sub-word graphs and a joint training mechanism with separate classifiers, ConTextING addresses the limitations of transductive GNNs and the lack of structural awareness in transformer models. Experimental results across five benchmarks demonstrate that ConTextING outperforms standalone transformers and state-of-the-art inductive GNNs, particularly in data-scarce scenarios.

Introduction

Text classification research has traditionally diverged into two primary paradigms: sequential modeling, epitomized by BERT, and graph-based modeling using Graph Neural Networks (GNNs). While BERT excels at capturing deep contextual semantics, it often struggles with complex, non-sequential syntactic interactions. Conversely, early GNNs were often transductive, requiring the entire dataset to be present during training, which limits real-world applicability. Inductive GNNs addressed this by creating document-specific graphs but typically relied on static embeddings like GloVe, failing to capture word context within a specific document. ConTextING bridges this gap by enriching inductive GNNs with document-wise contextual embeddings from BERT.

The ConTextING Architecture

The ConTextING pipeline integrates transformer-based encoding with graph-based structural analysis through a multi-step process.

The ConTextING architecture pipeline, showing the integration of BERT-style encoding with sub-word graph construction and joint classification.
  1. BERT-style Encoding: The document is processed through a transformer (e.g., RoBERTa) to generate a global document embedding and individual contextual embeddings for each sub-word token.
  2. Sub-word Graph Construction: Unlike traditional models that use whole words, ConTextING constructs graphs using sub-word units (BPE or WordPiece). This approach enhances robustness against rare words and out-of-vocabulary (OOV) issues. Edges are defined by word co-occurrence within a sliding window.
  3. Context Enrichment: Contextual embeddings from the transformer are mapped onto the nodes of the sub-word graph, providing the GNN with features that already incorporate document-specific context.
  4. Message Passing: The model employs gated graph recurrent units or Graph Attention Networks (GAT) to facilitate information sharing across the graph structure.
  5. Joint Training: A key innovation is the use of separate classifiers for the BERT and GNN modules. A hyperparameter balances the final prediction between the sequential semantic view and the structural syntactic view, preventing the "blurring" of their distinct strengths.

Experimental Results

The model was evaluated on five standard benchmarks: Ohsumed (medical abstracts), MR (movie reviews), R8 and R52 (Reuters subsets), and 20NewsGroups (20NG).

Performance comparison of ConTextING against various baselines across five benchmark datasets.

State-of-the-Art Performance

ConTextING-RBT (the RoBERTa-based variant) consistently outperformed all baselines. Notably, it achieved significant accuracy gains over standalone GNNs—up to 9 percentage points in some instances. The model also demonstrated superior performance compared to standalone transformer models, confirming that graph-based structural information is complementary to sequential semantics.

Robustness in Few-Shot Scenarios

ConTextING exhibited remarkable stability in data-scarce environments. In experiments with only 20 labeled documents per class, the model significantly outperformed its competitors. For example, on the MR dataset, ConTextING achieved 73.14% accuracy in a few-shot setting, whereas the standalone RoBERTa model's performance dropped to 69.16%.

Discussion and Insights

A critical finding is the superiority of sub-word units for graph construction. By capturing fine-grained syntactic clues like prefixes and suffixes, the model handles unseen words more effectively than word-level GNNs. Furthermore, t-SNE visualizations revealed that the GNN module often clusters certain document types more distinctly than BERT alone, suggesting that the graph structure captures unique information that sequential models overlook.

Conclusion and Future Work

ConTextING successfully combines the strengths of transformers and GNNs for inductive text classification. While the current model requires manual tuning of the balancing hyperparameter, future work will explore automated mechanisms for learning this weight. Additionally, the authors aim to integrate GNNs directly into the large-scale pre-training phase of transformers to further unify these two powerful paradigms.

Summary updated

BibTeX
@inproceedings{huang2022contexting,
  author = {Yen-Hao Huang and Yi-Hsin Chen and Yi-Shin Chen},
  title = {{ConTextING: Granting Document-Wise Contextual Embeddings to Graph Neural Networks for Inductive Text Classification}},
  booktitle = {International Conference on Computational Linguistics},
  year = {2022},
}
Figure