Revisiting Graph Contrastive Learning for Anomaly Detection

Zhiyuan Liu, Chunjie Cao, Fangjian Tao, Jingzhang Sun · DOI

Abstract

Combining Graph neural networks (GNNs) with contrastive learning for anomaly detection has drawn rising attention recently. Existing graph contrastive anomaly detection (GCAD) methods have primarily focused on improving detection capability through graph augmentation and multi-scale contrast modules. However, the underlying mechanisms of how these modules work have not been fully explored. We dive into the multi-scale and graph augmentation mechanism and observed that multi-scale contrast modules do not enhance the expression, while the multi-GNN modules are the hidden contributors. Previous studies have tended to attribute the benefits brought by multi-GNN to the multi-scale modules. In the paper, we delve into the misconception and propose Multi-GNN and Augmented Graph contrastive framework MAG, which unified the existing GCAD methods in the contrastive self-supervised perspective. We extracted two variants from the MAG framework, L-MAG and M-MAG. The L-MAG is the lightweight instance of the MAG, which outperform the state-of-the-art on Cora and Pubmed with the low computational cost. The variant M-MAG equipped with multi-GNN modules further improve the detection performance.

Introduction

Detecting anomalies in graph data—such as identifying fraudulent transactions in a financial network or intrusions in a computer network—is notoriously difficult because "ground truth" labels for anomalies are rare. To solve this, researchers use Graph Contrastive Learning (GCL), a self-supervised approach where the model learns by comparing different "views" of the same data (e.g., a node vs. its local neighborhood).

Recent state-of-the-art models have become increasingly complex, adding various "multi-scale" contrast modules (comparing nodes to nodes, subgraphs to subgraphs, etc.) to boost performance. However, there has been a lack of empirical evidence explaining why these additions work. This research investigates whether the community might be misattributing the success of these models to complex loss functions when the real driver is the use of multiple GNN backbones.

The MAG Framework

The authors propose the Multi-GNN and Augmented Graph (MAG) contrastive framework. MAG serves as a "master template" that can replicate existing popular models (like CoLA, ANEMONE, and GRADATE) simply by adjusting hyperparameters.

The MAG framework overview, showing graph augmentation, multi-GNN backbones, and the combination pool of contrastive patterns.

Key components of the method include:

  • Graph Augmentation: The model creates "perturbed" versions of the graph by masking node features and removing edges.
  • Multi-GNN Modules: Instead of using one GNN backbone, the framework can employ multiple GNNs to process different views of the graph.
  • Contrastive Pool: MAG defines four primary contrast patterns:
  • Normal Node-Subgraph (N-NS): Comparing a node to its neighborhood.
  • Node-Node (NN): Comparing a node to its own masked version.
  • Subgraph-Subgraph (SS): Comparing two different neighborhood representations.
  • Masked Node-Subgraph (M-NS): Comparing a masked node to its neighborhood.

Deconstructing Contrastive Mechanisms

A key finding of this study is that multi-scale contrast modules are often "puppets" for the performance gains actually provided by multiple GNN backbones. In models like ANEMONE, the extra contrastive losses do not significantly help if only a single GNN is used. The real "pusher" of performance is the diversity of representations provided by multi-GNN modules.

Heatmap of detection performance across various combinations of contrastive patterns, highlighting the effectiveness of specific pairings within the MAG framework.

Furthermore, the "Normal Node-Subgraph" (N-NS) contrast pattern was identified as the most effective single pattern. As shown in the combination analysis, simple models using only N-NS (represented by indices [1,3] in the framework) often outperform much more complex multi-scale models. The researchers also found that combining feature masking with edge removal provides the most stable performance boost across different datasets.

Experimental Results

The MAG framework was evaluated on standard citation network benchmarks (Cora, Citeseer, and Pubmed) with injected anomalies. Two specific instances were tested:

  • L-MAG (Lightweight): A single-contrast version that achieved 91.4% AUC on Cora and 95.7% AUC on Pubmed, surpassing complex models like GRADATE and SL-GAD while being computationally cheaper.
  • M-MAG (Multi-GNN): A high-performance version that set new benchmarks with 91.7% AUC on Cora, 92.5% on Citeseer, and 96.6% on Pubmed.

The results demonstrate that by selecting specific combinations from the MAG "pool," one can replicate and exceed the performance of existing state-of-the-art models.

Conclusion

The MAG framework provides a unified perspective on graph contrastive anomaly detection, revealing that the complexity of multi-scale modules is often unnecessary. By focusing on multi-GNN backbones and effective augmentation strategies, L-MAG and M-MAG achieve superior performance with greater simplicity. Future work will involve extending this framework to more complex scenarios, such as heterogeneous and dynamic graphs.

Summary updated

BibTeX
@misc{liu2023revisiting,
  author = {Zhiyuan Liu and Chunjie Cao and Fangjian Tao and Jingzhang Sun},
  title = {{Revisiting Graph Contrastive Learning for Anomaly Detection}},
  year = {2023},
  eprint = {2305.02496},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2305.02496},
}
Figure