ABKD: Graph Neural Network Compression with Attention-Based Knowledge Distillation

Anshul Ahluwalia, Rohit Das, Payman Behnam, Alind Khare, Pan Li, Alexey Tumanov · DOI

Abstract

Graph Neural Networks (GNNs) are increasingly deep and wide to capture complex relationships, leading to high computational costs. We introduce STRIDE, a novel knowledge distillation (KD) framework that addresses the layer mismatch problem between large teacher models and compact student models. By employing a trainable attention mechanism to align intermediate representations and distilling both graph structure and node embeddings, STRIDE achieves massive compression—up to 141×—with minimal performance degradation.

Introduction

Modern Graph Neural Networks (GNNs) are following the "bigger is better" trend to capture intricate relationships in domains like social networks and biology. However, these massive models are often too slow and memory-intensive for real-time applications such as autonomous vehicle perception or instant recommendation systems.

While Knowledge Distillation (KD) is a standard solution for model compression, applying it to GNNs is challenging due to the hierarchical nature of graph data and the structural differences between deep teachers and shallow students. Most existing methods focus solely on the final output layer, ignoring the rich information stored in intermediate layers. STRIDE addresses this "layer mismatch" problem by bridging the gap between disparate architectures through an attention-driven alignment strategy that ensures the student learns both node embeddings and graph structure.

The STRIDE Framework

The core of STRIDE (Structure and Embedding Distillation with Attention) is its flexibility in aligning models with different depths and widths. It does not assume the teacher and student architectures are similar.

Overview of the STRIDE framework, illustrating the attention-driven alignment of teacher and student intermediate layers.

Attention-Driven Alignment

Instead of a rigid 1-to-1 layer mapping, STRIDE uses a trainable attention mechanism. It projects intermediate representations into a shared latent space and learns an attention matrix ($\alpha$) to identify the most informative teacher-student layer pairs for alignment. Theoretically, this mechanism creates direct gradient pathways from every teacher layer to every student layer, allowing shallow students to learn complex, high-order neighborhood information that usually requires many more layers of message passing.

Dual-Track Distillation

STRIDE minimizes two primary types of dissimilarity across the entire network hierarchy:

  1. Embedding Dissimilarity: Ensures student node features match the teacher's semantic representations.
  2. Structural Dissimilarity: Utilizes a Global Contrastive Representation Distillation (G-CRD) loss to ensure the student captures the underlying graph topology.

To handle high-dimensional embeddings more effectively, STRIDE projects features into a lower-rank subspace, which increases the "semantic value" of the distance metrics used during training.

Experimental Results

STRIDE was evaluated on a diverse set of benchmarks, including large-scale datasets like OGBN-Mag and OGBN-Arxiv, as well as standard benchmarks like Cora, Citeseer, Pubmed, and NELL. The researchers tested across various GNN flavors, including GCNII, RGCN, GAT, and GraphSAGE.

Accuracy vs. Compression Ratio comparison across various knowledge distillation methods, showing STRIDE's superior performance at high compression levels.

Performance and Compression

The framework demonstrates superior accuracy and extreme compression capabilities:

  • State-of-the-Art Accuracy: On the massive OGBN-Mag dataset, STRIDE outperformed existing KD methods by 2.13% in accuracy while maintaining a 32.3× compression ratio.
  • Extreme Compression: On the Pubmed dataset, it achieved a staggering 141× compression ratio while matching the original teacher model's accuracy.
  • Robust Generalization: By aligning the internal "logic" of the teacher rather than just outputs, student models showed improved performance on unseen, out-of-distribution data compared to standard KD baselines.

Discussion and Conclusion

The success of STRIDE highlights that intermediate GNN layers encode distinct connectivity patterns essential for reasoning. The attention mechanism acts as a "smart bridge," dynamically focusing distillation based on dataset complexity. For simpler datasets like Cora, the model automatically focuses distillation into a single key layer, whereas for complex datasets, attention is spread across many layers.

While the resulting inference is lightning-fast, the training phase is more complex due to the calculation of attention across all layer pairs. Future work may explore sparsifying the attention matrix to optimize the distillation process and extending the method to more recent architectures like Graph Transformers.

Summary updated

BibTeX
@misc{ahluwalia2023abkd,
  author = {Anshul Ahluwalia and Rohit Das and Payman Behnam and Alind Khare and Pan Li and Alexey Tumanov},
  title = {{ABKD: Graph Neural Network Compression with Attention-Based Knowledge Distillation}},
  year = {2023},
  eprint = {2310.15938},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2310.15938},
}
Figure