Connecting the Dots: What Graph-Based Text Representations Work Best for Text Classification using Graph Neural Networks?

Margarita Bugueño, Gerard de Melo

Abstract

Given the success of Graph Neural Networks (GNNs) for structure-aware machine learning, many studies have explored their use for text classification, but mostly in specific domains with limited data characteristics. Moreover, some strategies prior to GNNs relied on graph mining and classical machine learning, making it difficult to assess their effectiveness in modern settings. This work extensively investigates graph representation methods for text classification, identifying practical implications and open challenges. We compare different graph construction schemes using a variety of GNN architectures and setups across five datasets, encompassing short and long documents as well as unbalanced scenarios in diverse domains. Two Transformer-based large language models are also included to complement the study. The results show that i) although the effectiveness of graphs depends on the textual input features and domain, simple graph constructions perform better the longer the documents are, ii) graph representations are especially beneficial for longer documents, outperforming Transformer-based models, iii) graph methods are particularly efficient for solving the task.

Introduction

While Transformer-based models like BERT currently dominate the Natural Language Processing (NLP) landscape, they are not without limitations. Sequence-based models often struggle to capture non-linear structural relationships within text and face significant computational challenges—specifically quadratic complexity—when processing very long documents.

Graph-based representations offer a compelling alternative by modeling words as nodes and their relationships as edges. Despite numerous proposals for graph-based text classification, the field has remained fragmented, with many methods tested only on narrow domains or using outdated non-neural models. This study provides a comprehensive "apples-to-apples" comparison of graph construction methods across diverse GNN architectures, document lengths, and data distributions to determine their true effectiveness in modern NLP.

Graph Construction Strategies

The researchers categorized graph construction into two primary groups based on how they model textual relationships:

  1. Intuitive Graphs: These rely on simple co-occurrence or positional strategies.
  2. Window-based: Connects words that appear within a sliding window of a fixed size (e.g., 2 or 3).
  3. Sequence-based: Connects words based on their original linear order in the text, often weighted by frequency.
  4. Sophisticated Graphs (TextLevelGCN): This approach treats every word occurrence as a separate node, aiming to capture more granular, in-context meanings.
Visual representation of different graph construction schemes used in the study, ranging from simple window-based connections to complex TextLevelGCN structures.

These representations were evaluated using three prominent GNN architectures: Graph Convolutional Networks (GCN), Graph Isomorphism Networks (GIN), and Graph Attention Networks (GAT). The study also explored node initialization, comparing static embeddings (Word2Vec, GloVe) against contextualized BERT embeddings.

Experimental Setup

To ensure generalizability, the study utilized five diverse datasets:

  • App Reviews: Short, highly imbalanced sentiment data.
  • DBpedia: Standard Wikipedia topic classification.
  • IMDB: Mid-length movie reviews for sentiment analysis.
  • BBC News: Longer news articles for topic classification.
  • Hyperpartisan News Detection (HND): Very long documents (averaging 912 words) characterized by noisy text and class imbalance.

Key Results and Insights

The benchmarking revealed several critical advantages of graph-based approaches, particularly regarding document length and computational efficiency.

The Long Document Advantage

GNNs naturally handle variable-length inputs without the truncation issues inherent to BERT. On the HND dataset, which contains the longest documents, graph methods significantly outperformed the Longformer. Specifically, a Sequence-based graph using GIN achieved a 79.1 F1-score, compared to 77.2 for Longformer and 72.6 for BERT.

Efficiency and Resource Usage

Graph methods proved to be substantially faster and more resource-efficient than their Transformer counterparts. As shown in the results table, for the BBC News dataset, the graph-based approach was approximately 2.3x faster than BERT and 8.6x faster than Longformer.

Main results comparing graph-based models against BoW MLP, BERT, and Longformer. Note the significant differences in execution time and parameter counts.

Furthermore, GNNs are remarkably "green." Across all tasks, they utilized less than 6% of GPU memory, whereas BERT and Longformer required approximately 30% and 68%, respectively. This efficiency makes GNNs a viable option for environments with limited hardware resources.

Structural vs. Contextual Information

A surprising finding was that initializing GNN nodes with static embeddings like Word2Vec or GloVe often yielded results comparable to or better than using expensive BERT embeddings. This suggests that the structural information encoded in the graph itself provides a strong enough signal for classification, reducing the need for heavy contextualized models. Additionally, the GIN architecture proved particularly robust for noisy or imbalanced data (like App Reviews and HND), likely due to its superior ability to distinguish different graph neighborhoods.

Conclusion

This investigation demonstrates that GNNs are a highly competitive and efficient alternative to Transformers for text classification, especially for long-form content. Simple graph constructions, such as sequence-based models, often provide the best balance of performance and simplicity as document length increases.

Future work may expand this research to morphologically rich languages and more complex semantic tasks like question answering. Additionally, exploring Graph Structure Learning—where the model automatically learns optimal word connections—could further enhance the performance of these efficient architectures.

Summary updated

BibTeX
@inproceedings{bugueno2023connecting,
  author = {Margarita Bugueño and Gerard de Melo},
  title = {{Connecting the Dots: What Graph-Based Text Representations Work Best for Text Classification using Graph Neural Networks?}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2023},
  url = {https://openreview.net/forum?id=Ro3x3mCAkD},
}
Figure