Knowledge Modeling, Querying and Inference
Learning Objectives
- Model knowledge as a graph of entities and relations, and reason about what a triple does and does not encode
- Compare knowledge graph embedding models (TransE, TransR, DistMult, ComplEx, RotatE) and their inductive biases
- Apply GNNs to recommendation as link prediction over a bipartite user–item graph
- Understand relational deep learning: learning directly over multi-table relational databases
- Reason about KG foundation models and transferable, inductive reasoning over unseen graphs
Topics
- Knowledge graphs: entities, relations, triples, and completion as link prediction
- Knowledge graph embeddings: translational and bilinear scoring functions
- Querying and reasoning: multi-hop logical queries in vector space (Query2box)
- GNNs for recommender systems: bipartite graphs, NGCF, LightGCN, PinSAGE
- Relational deep learning: GNNs over relational databases (RDL, RelBench)
- Toward foundation models for knowledge graph reasoning (ULTRA-style)
Hands-on demos
A self-contained PyTorch Geometric notebook with two independent demos — runnable on a laptop in seconds. Code lives in docs/11_knowledge_modeling/demos/.
D1 · Heterogeneous GCN & knowledge-graph embeddings
Part A — a heterogeneous / multi-relational GCN. A small synthetic academic graph (papers, authors, venues with cites, writes, published_in) is classified by topic with an R-GCN (Schlichtkrull et al. 2018) from only 3 labels per topic, and compared against a relation-blind baseline so the class can see what typed edges buy you. Hidden states are projected with PCA to watch the topics separate.
Part B — KG embeddings, inference and queries. A fully human-readable knowledge graph is embedded with TransE. The demo then (1) infers missing facts by link prediction, (2) answers 1-hop tail queries by ranking, and (3) answers a 2-hop query directly in vector space by adding relation vectors — recovering which country a person lives in even though that fact is never stored — motivating the Query2box lecture.
- Notebook (.ipynb) — narrated, both parts
- Script (.py) — same code, saves
fig_hetero_gcn.pngandfig_kg_transe.png - README — setup and run instructions (
uv)
Lecture slides and videos
This session follows Stanford CS224W: Machine Learning with Graphs (Fall 2025). Slides below link directly to the official course materials; videos are the public 2023 recordings, which remain the best openly available match.
| Topic | Official slides (CS224W 2025) | Public video |
|---|---|---|
| Knowledge graph embeddings |
Lecture 10 — Knowledge graphs | CS224W 2023 — KG Embeddings |
| Querying & reasoning over KGs |
Lecture 11 — Reasoning over KGs (2024) | CS224W playlist |
| GNNs for recommender systems |
Lecture 11 — GNNs for RecSys | CS224W 2023 — GNNs for RecSys |
| Relational deep learning |
Lecture 12 — Relational Deep Learning | Leskovec — Relational Deep Learning |
| Advanced RDL architectures |
Lecture 13 — Advanced topics in RDL | RelBench overview |
| Foundation models for KGs |
Lecture 15 — KG Foundation Models | Towards Foundation Models for KG Reasoning |