How to Turn Your Knowledge Graph Embeddings into Generative Models

Lorenzo Loconte, Nicola Di Mauro, Robert Peharz, Antonio Vergari

This paper, presented at NeurIPS 2023, provides a theoretical and practical bridge between two popular but previously distinct worlds: Knowledge Graph Embeddings (KGEs) and Probabilistic Circuits (PCs). By re-interpreting how we calculate scores for triples in a knowledge graph, the authors transform standard "black-box" embedding models into tractable generative models.

TL;DR

The authors re-interpret state-of-the-art Knowledge Graph Embedding models (like ComplEx and TuckER) as "probabilistic circuits." This allows them to turn discriminative link-prediction models into generative ones that can be trained via exact maximum likelihood, sampled efficiently, and guaranteed to follow logical rules—all while scaling better to massive graphs.

Venn diagram illustrating the intersection of KGE models, Circuits, and Probabilistic Circuits to form GeKCs.

What Problem Does This Paper Address?

Knowledge Graphs (KGs) store information as triples: (subject, predicate, object). Standard KGE models map these entities and relations into vector spaces to predict missing links. However, these models are typically Energy-Based Models (EBMs).

This creates three major headaches:

  1. Intractable Normalization: To turn a "score" into a "probability," you must sum the scores of every possible triple in the graph. For a graph with millions of entities, this is computationally impossible ($O(|E|^2)$).
  2. Sampling is Hard: You can't easily generate "new" plausible triples from an EBM.
  3. Logical Hallucinations: Standard KGEs often predict triples that are logically impossible (e.g., predicting that a "Drug" interacts with a "Rock" because it doesn't understand that the "interacts" relation requires a "Protein" as an object).

Methods

The core innovation is viewing KGE score functions as Circuits—computational graphs made of sum and product units.

Circuit representations of popular KGE models: CP, RESCAL, TuckER, and ComplEx.

The authors prove that popular models like CP, RESCAL, TuckER, and ComplEx are actually "smooth and decomposable" circuits. This structural property is the "secret sauce" that allows them to "push" summations inside the products, reducing the complexity of calculating the total probability from quadratic to linear ($O(|E|)$).

They propose two "recipes" to make these circuits valid probability distributions (Generative KGE Circuits, or GeKCs):

  • Non-negative restriction (GeKC+): Forcing all embeddings and weights to be non-negative.
  • Squaring (GeKC²): Squaring the output of the score function. This ensures the output is always positive while allowing the underlying embeddings to use negative values, preserving model expressivity.

Finally, they introduce Constraint Injection. By compiling logical rules (like domain and range constraints) into a separate "logical circuit" and multiplying it with the GeKC, they can "cut" the probability of illegal triples to exactly zero.

Datasets

The models were evaluated on standard KG benchmarks:

  • FB15k-237 and WN18RR: Standard small-to-medium benchmarks.
  • ogbl-biokg: A biomedical dataset used specifically to test logical domain/range constraints.
  • ogbl-wikikg2: A massive dataset with over 2.5 million entities used to demonstrate scaling.

Key Insights and Ideas

  • KGEs are Secretly Circuits: The trilinear products used in models like ComplEx are mathematically identical to specific circuit architectures. This realization unlocks decades of research in tractable probabilistic modeling for the KG community.
  • The Efficiency Paradox: Counter-intuitively, the generative versions (GeKCs) are often faster to train than the original models. Because they can compute the normalization constant efficiently, they don't need the expensive "negative sampling" tricks usually required to train KGEs.
  • Logic by Design, Not by Penalty: Most researchers try to "teach" models logic using penalty terms (soft constraints). This paper uses "hard constraints"—the model's architecture physically prevents it from assigning probability to triples that violate the schema.

Key Results

  • Competitive Performance: GeKC² models achieve link prediction accuracy (MRR) nearly identical to their state-of-the-art EBM counterparts.
  • Massive Speedups: On the large ogbl-wikikg2 dataset, a GeKC² model achieved a competitive score in just 3 hours, whereas the standard ComplEx model took 3 days to reach a similar level because it couldn't handle large batch sizes.
  • Perfect Logic: The constrained version (D-ComplEx²) achieved 100% semantic consistency, meaning it never predicted a triple that violated the KG's domain/range rules.
  • Better Sampling: Using a new metric called Kernel Triple Distance (KTD), the authors showed that GeKCs generate much more realistic "synthetic" triples compared to previous generative baselines.

Limitations and Future Work

  • Model Scope: This work focuses on multilinear/tensor-factorization models. It does not yet cover "distance-based" models like TransE or RotatE, though the authors suggest these could be adapted in the future.
  • Structure Learning: The circuits used here mimic existing KGE architectures. A promising next step is to use "probabilistic circuit structure learning" to discover entirely new, more efficient KG architectures from scratch.
  • Expressivity Trade-off: While squaring (GeKC²) is powerful, the non-negative version (GeKC+) is significantly less expressive, leading to lower accuracy on some datasets.

Summary updated

BibTeX
@inproceedings{loconte2023how,
  author = {Lorenzo Loconte and Nicola Di Mauro and Robert Peharz and Antonio Vergari},
  title = {{How to Turn Your Knowledge Graph Embeddings into Generative Models}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2023},
  url = {https://openreview.net/forum?id=RSGNGiB1q4},
}
Figure