GOFA: A Generative One-For-All Model for Joint Graph Language Modeling

Lecheng Kong, Jiarui Feng, Hao Liu, Chengsong Huang, Jiaxin Huang, Yixin Chen, Muhan Zhang · DOI

Abstract

The development of Foundation Models has revolutionized natural language processing and computer vision, yet the graph domain has lacked a similarly versatile architecture. We present GOFA (Generative One-For-All), a novel Graph Foundation Model that bridges the gap between structural graph learning and generative language modeling. By interleaving Graph Neural Network (GNN) layers into a frozen, pre-trained Large Language Model (LLM), GOFA enables deep structural understanding within a generative framework. GOFA achieves impressive zero-shot performance across a wide array of graph tasks—from node classification to complex shortest-path reasoning—without the need for task-specific architectures.

Introduction

While Large Language Models (LLMs) and Large Vision Models (LVMs) have become standard "Foundation Models," graphs present unique challenges due to their lack of a fixed, grid-like structure. A social network, a protein molecule, and a citation index all possess vastly different topologies, making a universal graph model difficult to engineer.

Existing attempts to create Graph Foundation Models (GFMs) generally follow two paradigms:

  1. LLM as a Predictor: Graphs are flattened into text descriptions and fed into an LLM. While flexible, this approach often fails to capture complex structural patterns like cycles or long-range dependencies effectively.
  2. LLM as an Enhancer: LLMs are used to generate features for a downstream GNN. This captures structure well but results in specialized, "narrow" models that lack the open-ended generative capabilities of modern LLMs.

GOFA addresses these limitations by creating a model that deeply understands graph structure while maintaining the versatile generative power of an LLM.

Methodology

GOFA's architecture is designed to treat graph modeling as a unified generative language task.

Interleaved GNN-LLM Architecture

Rather than simply appending a GNN to an LLM, GOFA interleaves randomly initialized GNN layers between the layers of a frozen LLM backbone (specifically utilizing the ICAE compressor). This deep integration allows the model to process structural information at multiple levels of abstraction.

Token-Level Message Passing

Traditional GNNs often compress a node's entire textual content into a single vector, losing significant semantic nuance. GOFA instead uses a compressor to transform node text into $K$ "memory tokens." The interleaved GNN layers then perform message passing across these tokens, preserving high-dimensional semantic detail during structural propagation.

The Tanh Gate and Nodes of Generation (NOG)

To maintain the pre-trained knowledge of the LLM during the early stages of training, GOFA employs a Tanh gating mechanism. Initialized at zero, this gate allows the model to gradually incorporate structural information without disrupting the LLM's existing linguistic capabilities.

Furthermore, GOFA unifies all graph tasks under the concept of Nodes of Generation (NOG). Whether performing node classification or pathfinding, the model treats the task as a "sentence completion" problem originating from a specific node in the graph.

The Nodes of Generation (NOG) framework unifies diverse graph tasks into a single sentence completion format.

Multi-Task Pre-training

GOFA is pre-trained on four distinct categories of tasks to ensure a robust understanding of both text and structure:

  1. Sentence Completion: Predicting missing node text based on neighbor context.
  2. Structural Understanding: Explicitly computing properties like shortest paths.
  3. Question Answering: Training on chain-like graphs derived from multi-turn dialogues.
  4. Information Retrieval: Querying node content using specific identifiers.
GOFA's pre-training involves four core tasks: Sentence Completion, Question Answering, Structural Understanding, and Information Retrieval.

Experiments and Datasets

The authors utilized a diverse set of large-scale graphs for pre-training, including MAG240M, Arxiv, Pubmed, and Wikikg90mv2. They also introduced WikiGraph, a dataset where entities and relationships were extracted from Wikipedia using an LLM.

Evaluation was conducted in a zero-shot setting on unseen datasets such as Cora-Node, WikiCS, Amazon Products, and ExplaGraphs. To test cross-domain transferability, the model was also evaluated on molecular datasets like BBBP and HIV.

Key Insights and Results

Structure as a Language Feature

A core insight of GOFA is that graph structure should not be treated as a separate input modality but as a context that conditions text generation. By framing structural tasks like shortest-path discovery as next-token prediction, the model learns graph topology as a fundamental part of its "grammar."

Performance and Efficiency

In zero-shot evaluations, GOFA-F (the full model) significantly outperformed base LLMs. For instance, on the WikiCS dataset, GOFA achieved ~71% accuracy, surpassing Mistral-7B's ~63%. In structural reasoning, GOFA reduced the Root Mean Square Error (RMSE) for shortest-path calculations from 1.254 (Mistral) to 0.634.

Moreover, GOFA is computationally efficient. By using sparse GNN message passing for cross-node communication, GOFA was 68% faster per sample than an LLM processing the same information as flattened text on the ExplaGraphs dataset.

Conclusion and Future Work

GOFA represents a significant step toward a universal Graph Foundation Model. While it excels at local neighborhood understanding, challenges remain in capturing global graph properties, such as total node counts in massive networks. Future work may involve fine-tuning the LLM compressor alongside the GNN layers to further enhance graph-text alignment and incorporating more diverse reasoning tasks to bridge common-sense gaps in specific domains like scene graphs.

Summary updated

BibTeX
@inproceedings{kong2025gofa,
  author = {Lecheng Kong and Jiarui Feng and Hao Liu and Chengsong Huang and Jiaxin Huang and Yixin Chen and Muhan Zhang},
  title = {{GOFA: A Generative One-For-All Model for Joint Graph Language Modeling}},
  booktitle = {International Conference on Learning Representations},
  year = {2025},
  url = {https://openreview.net/forum?id=mIjblC9hfm},
}
Figure