Flock: A Knowledge Graph Foundation Model via Learning on Random Walks

Jinwoo Kim, Xingyue Huang, Krzysztof Olejniczak, Kyungbin Min, Michael M. Bronstein, Seunghoon Hong, Ismail Ilkan Ceylan

Knowledge graphs (KGs) are the backbone of modern AI, powering everything from search engines to drug discovery. But a major challenge remains: how do we build a "Foundation Model" for graphs that can perform zero-shot link prediction—predicting relationships in a graph it has never seen before, involving entities and relations it wasn't trained on?

A new paper, "FLOCK: A Knowledge Graph Foundation Model via Learning on Random Walks," introduces a clever way to bypass the structural "blind spots" of current models using the power of random walks and probabilistic logic.

TL;DR

FLOCK is a Knowledge Graph Foundation Model (KGFM) that replaces traditional message-passing with a random-walk-based architecture. By embracing "probabilistic equivariance," it overcomes a fundamental limitation of existing models—the inability to distinguish between different relations that share the same structure—achieving state-of-the-art results across 54 diverse knowledge graphs.

The Problem: Structural Blind Spots

Current state-of-the-art KGFMs (like ULTRA or TRIX) rely on a principle called deterministic double equivariance. Essentially, these models learn "structural invariants"—patterns of connectivity that should hold true regardless of the specific names of nodes or relations.

Star Wars Knowledge Graph Example

However, the authors point out a fatal flaw: structural isomorphism implies semantic equivalence in these models. Imagine a Star Wars KG where the relations like and dislike have identical connectivity patterns (e.g., Han Solo likes Leia; Darth Vader dislikes Luke). A deterministic model is mathematically forced to give these two relations the exact same representation. It literally cannot tell them apart because they "look" the same structurally. This expressivity bottleneck limits how well these models can generalize to complex, real-world data.

Methods: The FLOCK Architecture

FLOCK (Foundation model via Learning On random walKs) moves away from the standard message-passing paradigm. Its pipeline consists of four main stages:

FLOCK's four-stage pipeline
  1. Random Walk Sampling: For a given query (e.g., "Who does Luke like?"), the model samples multiple non-backtracking random walks starting from the query nodes.
  2. Recording Protocol (Anonymization): To ensure the model doesn't just memorize IDs, it "anonymizes" the walks. Nodes are replaced with discovery order (1, 2, 3...) and relations with generic tokens ($\alpha, \beta, \gamma...$). This forces the model to learn purely from structural roles.
  3. Sequence Processing: These anonymized sequences are fed into a bidirectional GRU (Gated Recurrent Unit). This treats the graph structure like a language, capturing the "context" of how nodes and relations interact.
  4. Consensus Protocol: Since random walks are stochastic, FLOCK aggregates the results from many walks using a softmax-weighted consensus. This allows the model to "vote" on the most likely prediction, effectively using randomness to break the symmetries that trap deterministic models.

The core innovation is probabilistic equivariance. While the model is equivariant in distribution, any single forward pass uses structured randomness to distinguish between structurally similar but semantically distinct relations.

Datasets

The authors evaluated FLOCK on a massive scale:

  • PETALS (New): A diagnostic synthetic dataset designed specifically to trip up deterministic models. It contains "petals" (subgraphs) that are structurally identical but require different predictions.
  • 54 Real-World KGs: A diverse collection including standard benchmarks (FB15k-237, WN18RR), inductive datasets (INGRAM, GraIL), and domain-specific graphs (Wiki, Metafam, etc.).

Key Insights and Ideas

  • Universal Approximation: The authors provide a theoretical proof that FLOCK is a universal approximator for link-level functions. Given enough walks of sufficient length, it can reconstruct any graph up to isomorphism and compute any possible relationship.
  • Randomness as a Feature, Not a Bug: By using random walks, FLOCK avoids the "oversmoothing" and "over-squashing" problems common in deep Message-Passing Neural Networks (MPNNs).
  • The "Aha" Moment on PETALS: While existing models like ULTRA and TRIX scored exactly 50% (random guessing) on the PETALS dataset, FLOCK achieved a perfect 100%. This empirically confirms that probabilistic models can "see" differences that deterministic models are blind to.
  • Adaptive Scaling: FLOCK adaptively changes the number of walks it samples based on the size of the test graph, allowing it to maintain performance even when moving from small training graphs to massive test graphs.

Key Results

  • Entity Prediction: FLOCK consistently outperformed baselines across all 54 KGs. Notably, on the Metafam dataset, it roughly doubled the MRR (Mean Reciprocal Rank) compared to ULTRA.
  • Relation Prediction: FLOCK showed an 11.2% relative improvement over the best baseline (TRIX) in zero-shot settings.
  • Scaling Behavior: The model exhibits clear "foundation model" scaling—performance improves steadily as the number of graphs in the pretraining mix increases and as more ensembled passes are used at inference time.

Limitations and Future Work

  • Computational Cost: Sampling and processing thousands of random walks is more expensive than a few rounds of message passing. The authors note that FLOCK is currently slower and more memory-intensive than its predecessors.
  • Coverage Issues: On very large, dense graphs, random walks might struggle to "cover" the entire neighborhood of a node efficiently.
  • Future Directions: The authors suggest developing optimized GPU kernels for random walk sampling and exploring ways to reduce the number of walks needed without losing expressivity.

Paper Citation: Kim, J., Huang, X., Olejniczak, K., Min, K., Bronstein, M., Hong, S., & Ceylan, İ. İ. (2026). FLOCK: A Knowledge Graph Foundation Model via Learning on Random Walks. Published as a conference paper at ICLR 2026. https://github.com/jw9730/flock

Summary updated

BibTeX
@inproceedings{kim2026flock,
  author = {Jinwoo Kim and Xingyue Huang and Krzysztof Olejniczak and Kyungbin Min and Michael M. Bronstein and Seunghoon Hong and Ismail Ilkan Ceylan},
  title = {{Flock: A Knowledge Graph Foundation Model via Learning on Random Walks}},
  booktitle = {International Conference on Learning Representations},
  year = {2026},
  url = {https://openreview.net/forum?id=1cGOCIOKQd},
}
Figure