Quantizing Text-attributed Graphs for Semantic-Structural Integration

Jianyuan Bo, Hao Wu, Yuan Fang · DOI

Abstract

Text-attributed graphs (TAGs) are ubiquitous in domains such as citation networks and e-commerce. However, integrating these structures with Large Language Models (LLMs) remains challenging due to the fundamental misalignment between continuous graph neural network (GNN) embeddings and discrete LLM token spaces. We introduce STAG (Soft Tokenization for Text-attributed Graphs), a framework that bridges this gap by converting complex graph structures into discrete, LLM-compatible tokens. STAG utilizes a frozen semantic codebook and a soft quantization approach to enable robust zero-shot transfer learning across diverse datasets and LLM architectures. Our evaluation demonstrates that STAG significantly outperforms existing state-of-the-art methods in zero-shot node classification while maintaining high computational efficiency.

Introduction

Text-attributed graphs (TAGs) represent entities with rich textual descriptions and their interconnections. While LLMs excel at processing text and GNNs are optimized for structural data, combining them effectively is difficult. Current approaches typically rely on manual verbalization—which is unscalable and often inconsistent—or alignment projectors that require expensive training and labeled data.

The core issue is the "misalignment" between the continuous embedding spaces of structural encoders and the discrete token spaces native to LLMs. STAG addresses this by treating graph structure as a sequence of tokens, allowing LLMs to "read" the graph directly.

Methodology: The STAG Framework

STAG (Soft Tokenization for Text-attributed Graphs) treats graph structure as something that can be tokenized similarly to text. The framework consists of several key components:

The STAG framework: (a) Codebook Construction, (b) Pre-training, (c) Inference, and (d) Prompt Tuning.

Frozen Semantic Codebook

Instead of learning a new vocabulary, STAG utilizes a subset of the LLaMA-2 vocabulary. These tokens are embedded once using a frozen Sentence Transformer. This ensures that the semantic meaning of the tokens remains constant throughout the training process, facilitating better generalization.

Soft Tokenization

Unlike traditional Vector Quantization (VQ) which maps inputs to a single "hard" token, STAG employs soft assignment. It maps a node to a distribution over tokens. This probabilistic representation prevents overfitting and increases robustness when transferring the model to unseen datasets.

Semantic-Structural Fusion and Training

A GNN encoder captures neighborhood structures, which are then fused with raw text features. To prevent the structural information from overwhelming the original text semantics, a KL Divergence loss aligns the distribution of fused features with text-only features. The model is trained in a self-supervised manner using two primary tasks:

  1. Reconstruction: Predicting original node features from the generated tokens.
  2. Contrastive Learning: Ensuring that a node's tokens are semantically similar to its neighbors' tokens while remaining distinct from distant nodes.

Experimental Results

STAG was evaluated across a diverse set of benchmarks, including citation networks (Cora, ogbn-arxiv), web graphs (WikiCS), and e-commerce networks (ogbn-products).

Zero-Shot Performance and Efficiency

In zero-shot node classification, STAG outperformed existing state-of-the-art methods like OFA by margins of 20-30% on challenging transfer tasks. The framework is also highly efficient, achieving a throughput of approximately 121,920 nodes per second during quantization.

Qualitative Analysis

Qualitative results show that STAG successfully translates structural context into relevant semantic tokens. As shown in the example below, even when raw text is abstract, the structural tokens provide clear categorical indicators.

Qualitative comparison of raw text, raw features with quantization, and STAG-generated tokens.

For instance, a paper with vague text located in a "Computational Complexity" neighborhood was assigned tokens such as complexity, algebraic, and computation, demonstrating the model's ability to infer context from structure.

Conclusion

STAG represents a significant advancement in integrating graph structures with LLMs. By using soft quantization and a frozen semantic codebook, it enables true zero-shot transfer without the need for manual descriptions or domain-specific alignment. Future work will explore extending STAG to whole-graph classification tasks and integrating it with Chain-of-Thought prompting to enhance the interpretability of LLM-based graph reasoning.

Summary updated

BibTeX
@inproceedings{bo2025quantizing,
  author = {Jianyuan Bo and Hao Wu and Yuan Fang},
  title = {{Quantizing Text-attributed Graphs for Semantic-Structural Integration}},
  booktitle = {ACM SIGKDD Conference on Knowledge Discovery and Data Mining},
  year = {2025},
  doi = {10.1145/3711896.3737096},
}
Figure