Abstract
Path-LLM is a novel framework that bridges the gap between graph structures and Large Language Models (LLMs) by conceptualizing shortest paths as linguistic sequences. By replacing conventional random walk strategies with a "long-to-short shortest path" (L2SP) approach, Path-LLM achieves state-of-the-art accuracy in graph representation learning while significantly reducing training time and data requirements. Experimental results demonstrate up to a 35x speedup and a 90% reduction in training data compared to existing LLM-based graph methods.
Introduction
Graph representation learning—the process of encoding complex network structures into mathematical vectors—is traditionally dominated by Graph Neural Networks (GNNs). While effective, GNNs often require extensive task-specific labeled data. Recent attempts to leverage the reasoning capabilities of Large Language Models (LLMs) have treated graph "walks" as text sequences. However, these methods suffer from three primary limitations: the "echo chamber" effect where random walks fail to cross community bridges, the inherent noise and redundancy of erratic paths, and a causal mismatch between unpredictable walks and the next-token prediction logic of LLMs.
Path-LLM addresses these challenges by shifting the focus from random exploration to structured "highways" across the graph, ensuring that the structural logic of the network aligns with the linguistic logic of the LLM.
Methodology
The Path-LLM framework operates through a four-phase pipeline designed to extract high-quality semantic features from graph data.
1. L2SP Selection
Instead of aimless random walks, the model identifies long shortest paths between distant nodes. These paths capture the global "bridge" structure of the network. These long paths are then decomposed into shorter segments (Long-to-Short Shortest Paths, or L2SP), ensuring the model learns both local neighborhood details and wider network connectivity.
2. Path Textualization
To make the graph readable for an LLM, node attributes are processed using PositionRank to extract key phrases. These phrases are then inserted into natural language templates (e.g., "the paper with content [Key Phrases] cites..."), transforming the raw graph into a coherent narrative.
3. Self-Supervised Alignment
The model is pretrained using a causal language modeling objective. It learns to predict the "next node" in a shortest path, mirroring how standard LLMs predict the next word in a sentence. This phase aligns the graph's structural progression with the LLM’s internal causal logic.
4. Embedding Generation
Once trained, the LLM is frozen. Node embeddings are generated by passing node text through the model and averaging the resulting token vectors into a single, high-dimensional representation.
Experimental Evaluation
Path-LLM was evaluated on six diverse benchmarks, including heterogeneous graphs (PubMed, Freebase) and homogeneous citation and social networks (Cora, Citeseer, OGB-ARXIV, Facebook).
Key Results
- Efficiency: Path-LLM demonstrates massive speedups. On the PubMed dataset, it completed training in 380 seconds, compared to 13,370 seconds for the baseline WalkLM—a ~35x improvement. This efficiency is driven by a 91.09% reduction in required training paths.
- Accuracy: In node classification tasks, Path-LLM significantly outperformed baselines. On PubMed, it achieved a 174% relative improvement in Macro-F1 score over WalkLM.
- Robustness: The model remains resilient to data quality issues. Replacing 20% of node text with irrelevant noise resulted in only a marginal 4% performance drop.
- Complex Task Performance: In NP-hard "Keyword Search" tasks, Path-LLM generated more compact and semantically meaningful subgraphs than traditional GNN or LLM approaches.
Conclusion
Path-LLM demonstrates that shortest paths can serve as a "grammar" for graphs, allowing LLMs to interpret network structures with unprecedented efficiency and accuracy. While the current framework focuses on static graphs and carries the computational overhead inherent to large models, its ability to learn from minimal data and capture global connectivity marks a significant advancement in unified graph representation. Future work will explore adapting Path-LLM to dynamic, evolving networks.
Summary updated