Papers
Topics
Authors
Recent
Search
2000 character limit reached

Global and Local Graph Contrastive Loss

Updated 10 March 2026
  • Global and Local Graph Contrastive Loss is a dual-scope self-supervised objective that leverages both graph-level and node-level signals to capture multi-scale semantics.
  • It employs NT-Xent, margin-triplet, and InfoNCE losses alongside adaptive negative sampling to enhance representation robustness and mitigate augmentation bias.
  • Practical methodologies include view generation via edge perturbation, SVD-based augmentation, and subgraph sampling to boost performance in tasks like classification and clustering.

Global and Local Graph Contrastive Loss refers to a family of objectives within graph contrastive learning that jointly leverage global (graph-, component-, or cluster-level) and local (node-, subgraph-, or patch-level) self-supervision signals. These losses are designed to enhance the expressivity and robustness of graph neural network (GNN) representations by capturing rich multi-scale semantics and mitigating issues such as semantic drift, augmentation bias, and local indistinguishability. The following sections survey the principal definitions, variants, and methodologies developed for global/local graph contrastive losses.

1. Conceptual Foundations

Graph contrastive learning (GCL) aims to learn node or graph representations by maximizing agreement between semantically similar views and repelling negatives. The global and local dimensions emerge as two complementary contextual scopes:

Combining both losses allows models to bind global structure with local detail, yielding more informative and generalizable embeddings, and sharpening the discrimination of subtle topological or attribute variations that purely global (or local) objectives may obscure.

2. Principal Loss Formulations

Multiple formulations have been proposed for combining global and local contrastive objectives; representative ones include:

2.1. Node–Node (Local) and Graph–Graph (Global) NT-Xent Losses

For a batch of graphs {Gi}\{G_i\}, let ff and fpf_p be dense and pruned GNN encoders, gg a projection head, and τ\tau the temperature:

  • Global (Graph-level) Loss:

LG=1Ni=1Nlogexp(sim(zi1,zi2)/τ)jiexp(sim(zi1,zj2)/τ)L_G = -\frac{1}{N}\sum_{i=1}^N \log\frac{\exp(\mathrm{sim}(z_i^1, z_i^2)/\tau)}{\sum_{j\ne i} \exp(\mathrm{sim}(z_i^1, z_j^2)/\tau)}

where zi1=g(f(Gi))z_i^1=g(f(G_i)), zi2=g(fp(Gi))z_i^2=g(f_p(G_i)) (Wu et al., 2024).

  • Local (Node-level) Loss:

LLocalCvi,k=logexp(sim(hvi,k1,hvi,k2)/τ)(j,)(i,k)exp(sim(hvi,k1,hvj,2)/τ)L_{LocalC}^{v_{i,k}} = -\log\frac{\exp(\mathrm{sim}(h_{v_{i,k}}^1, h_{v_{i,k}}^2)/\tau)}{\sum_{(j,\ell)\neq(i,k)} \exp(\mathrm{sim}(h_{v_{i,k}}^1, h_{v_{j,\ell}}^2)/\tau)}

with hvi,k1h_{v_{i,k}}^1 from f(Gi)f(G_i) and hvi,k2h_{v_{i,k}}^2 from fp(Gi)f_p(G_i).

The total loss is L=LG+αLLocalCL = L_G + \alpha L_{LocalC}, where α\alpha weights the local discrimination (Wu et al., 2024).

2.2. Multi-Level Margin-Triplet Losses

In LS-GCL, for each node ii, three embeddings are aligned:

  • hiSh_i^S: node-in-subgraph (local)
  • hSih^i_S: subgraph-level pooled (meso)
  • hiGh_i^G: full-graph node embedding (global)

Three triplet-style objectives are defined:

  • LNS\mathcal{L}_{NS}: node vs. pooled subgraph
  • LNG\mathcal{L}_{NG}: subgraph-node vs. full-graph node
  • LSG\mathcal{L}_{SG}: full-graph node vs. pooled subgraph

The full objective is the average:

L=13(LNS+LNG+LSG)\mathcal{L} = \frac{1}{3}(\mathcal{L}_{NS} + \mathcal{L}_{NG} + \mathcal{L}_{SG})

(Yang et al., 2023).

2.3. Flexible Contextual Scope Contrast

UGCL introduces a single InfoNCE objective contrasting hvh_v (anchor, patch embedding) against h~v\tilde h_v (contextualized nn-hop embedding), with negatives drawn from other anchors:

L=1SvG^logexp(cos(hv,h~v))uvexp(cos(hv,hu))\mathcal{L} = -\frac{1}{S}\sum_{v \in \hat G} \log \frac{\exp(\cos(h_v, \tilde h_v))}{\sum_{u \neq v} \exp(\cos(h_v, h_u))}

By varying nn, this loss interpolates from purely local to fully global context (Zheng et al., 2022).

2.4. Task-Driven and Domain-Informed Variants

  • MoCL: Incorporates both local, chemistry-preserving augmentation invariance, and global alignment under a dataset similarity graph, each realized as an InfoNCE loss and weighted sum (Sun et al., 2021).
  • CSG²L: Implements a global contrast via SVD-based adjacency augmentation and a local reweighted InfoNCE that emphasizes hard positives and negatives using pseudo-labels and similarity-adaptive weighting (Wei et al., 25 Apr 2025).

3. Practical Methodologies for View Construction

3.1. Global View Generation

3.2. Local View Generation

  • Subgraph Sampling: Personalized PageRank- or random-walk-based selection of kk-hop semantic subgraphs (Yang et al., 2023).
  • Node/Feature Masking: Random feature masking or masked node modeling to force local information recovery (Jiang et al., 2024).
  • Attention Over Local Neighborhoods: Learned, context-sensitive pooling to isolate discriminative local signals (Chen et al., 2023).

3.3. Adaptive Negative Sampling and Reweighting

4. Combined Training Objectives and Optimization

The joint loss is typically a weighted sum:

L=γ1Lglobal+γ2Llocal+(optional task loss)L = \gamma_1 \cdot L_{global} + \gamma_2 \cdot L_{local} + (\text{optional task loss})

The tuning of γ1,γ2\gamma_1, \gamma_2 is critical for balancing the local/global information; dynamic weighting schedules or linear increments can increase downstream performance (Jiang et al., 2024). In many frameworks, all relevant encoders, projection heads, and loss-specific hyperparameters (e.g., margin, temperature) are tuned via empirical validation.

5. Theoretical and Empirical Insights

5.1. Mutual Information Maximization

These objectives can be interpreted as maximizing lower bounds on the mutual information between multi-scale representations of the same instance, either via InfoNCE, margin-based, or triplet losses (Yang et al., 2023, Zheng et al., 2022).

5.2. Robustness and Structure Preservation

Contrasting both local and global information mitigates loss of semantic detail due to aggressive augmentations and preserves critical long-range dependencies. Empirical studies confirm additive performance gains across node classification, link prediction, molecular property prediction, and clustering, with ablations isolating the contribution of each term (Wei et al., 25 Apr 2025, Jiang et al., 2024, Sun et al., 2021, Wu et al., 2024, He et al., 25 Dec 2025).

5.3. Adaptivity Across Graph Types

Flexible-scope methods (UGCL, LS-GCL) or domain-specific augmentations (MoCL) demonstrate effectiveness across both homophilic and heterophilic graphs, as well as structured domains such as molecules (Zheng et al., 2022, Sun et al., 2021, Yang et al., 2023).

6. Representative Algorithms and Pseudocode

Model Global View Mechanism Local View Mechanism Objective Structure
LAMP (Wu et al., 2024) Model pruning, same input Node-level, encoder pair L=LG+αLLocalCL = L_G + \alpha L_{LocalC}
LS-GCL (Yang et al., 2023) Full-graph GNN Semantic subgraph L=13(LNS+LNG+LSG)\mathcal{L} = \frac{1}{3}(\mathcal{L}_{NS}+\mathcal{L}_{NG}+\mathcal{L}_{SG})
MoCL (Sun et al., 2021) Dataset-wide similarity graph Chemistry-guided augment L=Llocal+λLglobalL = L_{local} + \lambda L_{global}
CSG²L (Wei et al., 25 Apr 2025) SVD-based adjacency Adaptive InfoNCE, reweight L=Lce+λLclL = L_{ce} + \lambda L_{cl}
UGCL (Zheng et al., 2022) nn-hop contextual readout Patch-subgraph contrast InfoNCE with AnA^n-based context
Global-Local-Graph (He et al., 25 Dec 2025) Affinity-graph positive/neg Weighted local neighbors Ltotal=Lrec+αLglobal+βLlocalL_{total} = L_{rec} + \alpha L_{global} + \beta L_{local}

The batchwise or epoch-level algorithms typically consist of: global and local view generation, parallel encoding, computation of contrastive positives/negatives (with special weighting or sampling as appropriate), and optimization of the summed loss via Adam or equivalent optimizers.

Integration of global and local contrastive losses improves discrimination of subtle local patterns and stability of global structure, as confirmed by superior performance on diverse benchmarks:

A major direction is the principled, adaptive selection of contrastive scales (as in UGCL), use of dynamic weighting schedules between local and global objectives, and domain-driven generation of both local and global views. Future research also investigates generalization bounds for these losses and deeper integration with task-specific, supervised objectives.


References:

Topic to Video (Beta)

No one has generated a video about this topic yet.

Whiteboard

No one has generated a whiteboard explanation for this topic yet.

Follow Topic

Get notified by email when new papers are published related to Global and Local Graph Contrastive Loss.