CS224W

Lecture 13 · Thu 11/5 · slides PDF · lecture notes

Advanced Architectures in Relational Deep Learning

Relational entity graphs have a shape of their own — junction tables, bridges, hubs, timestamps — so the best RDL models rewire message passing along "atomic routes" (RelGNN) or tokenise rich context for a transformer (RelGT).

24
sectionstick "got it" as you go
20
figuresredrawn from the slides
interactive figuresplay with the ideas
5
self-check questionsplus flashcards
17′
reading time3,649 words, walkthrough aside

Before you start: review of the earlier sessions

The thread so far. Session 12 made databases into graphs; session 13 designs architectures for the specific shape of those graphs, borrowing the transformer tools of session 8.

What this session takes from earlier ones

  • Lecture 12: the database graph: tables as node types, foreign keys as edges
  • Lecture 8: graph transformer design (tokens, positional encodings), reused in the relational graph transformer
  • Lecture 14: in-context learning is the next lecture: the relational foundation model here is its database version

Those sessions in one minute each

Lecture 12 · Relational Deep Learning

A relational database is a temporal heterogeneous graph; a GNN on that graph is a differentiable, multi-hop generalisation of SQL joins and aggregations, so it can learn predictive features end-to-end while temporal sampling prevents leakage.

\[ \mathcal V=\bigcup_{T\in\mathcal T}T,\qquad (v_1,v_2)\in\mathcal E \iff v_1.\text{pkey}=v_2.\text{fkey},\qquad \mathbf h_v^{(t)}\ \text{uses only rows with time}\le t \]

Lecture 8 · Graph Transformers

A transformer is a GNN on the complete graph; a graph transformer re-injects the real graph via tokens, positional encodings, and attention biases — and the positional encodings must respect the symmetries (sign/basis) of whatever spectral object they come from.

\[ \text{GraphAtt}(X)=\text{softmax}\!\Big(\frac{(X+P)W^Q\,\big((X+P)W^K\big)^\top}{\sqrt d}+C\Big)(X+P)W^V \]

\(P\): positional encodings (one row per node); \(C\): edge / shortest-path biases \(c_{ij}\). Setting \(C_{ij}=-\infty\) for non-edges recovers neighbourhood-restricted attention (GAT-like).

Lecture 14 · Advanced Topics in GNNs — In-Context Learning and Relational Foundation Models

Foundation models for graphs need a universal input format: PRODIGY turns any few-shot graph task into link prediction on a prompt graph; the Relational Transformer turns any database task into masked-cell prediction over (value, column, table) tokens — and both are pretrained on self-generated tasks in that same format.

\[ \hat y_q=\arg\max_{c}\ \cos\big(\mathbf h_{\text{label }c},\ \mathbf h_{q}\big)\qquad\qquad \text{token}_{cell}=\phi_{\text{dtype}}(\text{value})+\text{LM}(\text{column of table}) \]

Warm-up: answer these before you read on

Why does a foreign key make a good edge? from Lecture 12

It is a deliberate, hand-verified link between two entities; the schema is a graph the database designers already drew.

Why do graph transformers need positional encodings more urgently than text transformers? from Lecture 8

In text a simple index encodes position; a graph has no canonical order, so without encodings the model sees only a bag of node features and cannot tell the graph structure at all.

Why pretrain in the prompt-graph format rather than with ordinary supervised tasks? from Lecture 14

So that the model learns to read examples from the prompt; a model pretrained on fixed labels has no mechanism for using in-context examples.

What replaces the hand-made aggregate features? from Lecture 12

The GNN layers: an aggregation over a customer's transactions is exactly a message-passing step over the foreign-key edges.

More questions from every session you have reached, with spaced repetition: the cumulative review.

In short

Lecture 12 turned databases into graphs and ran standard heterogeneous GNNs. But relational data is multi-modal (text, images, numbers, categories, timestamps in each row) and multi-scale (relational and temporal structure across the database), with recurring patterns: tripartite user–transaction–product structures, cycles, and structure that changes over time.

A key observation: PK–FK edges carry no semantics; many-to-many relations are stored through junction tables (a transaction table linking customers and products). Standard message passing then suffers from imbalance (the informative node is 2 hops away while the bland junction node is 1 hop) and redundancy (a node's own information bounces back to it via the junction). RelGNN fixes this with composite message passing along automatically derived atomic routes — up to 25% gains on RelBench.

RelGT (Relational Graph Transformer) instead samples a temporal-aware local context around each seed node and represents every token by a 5-tuple (features, node type, hop distance, time, GNN positional encoding) — improving over GNNs — and becomes the backbone of the first relational foundation model with zero-shot in-context learning.

The picture: standard vs composite message passing

RelGNN: atomic routes and composite messages standard message passing RelGNN composite message passing CTPC = customer · T = transaction (junction) · P = product layer 1layer 2 imbalance: informative product is 2 hops away 1 redundancy: own info returns via junction 2 CTP one step: FUSE(h_trans, h_product) atomic route: P → T → C 3 routes derived automatically from the schema (bridge & hub structures) — no expert needed 4

How to read it (hover a step)

  1. Imbalance: the junction (transaction) node is a 1-hop neighbour; the more informative product is 2 hops away, so its signal is diluted.
  2. Redundancy: in hop 1 the customer's information goes into the junction; in hop 2 it comes back and is mixed with junction and product information.
  3. Composite message: aggregate along the whole atomic route in a single step, fusing the junction and the endpoint before sending to the destination.
  4. Atomic routes are simple paths between "pink" (non-junction) node types in the schema graph — derived automatically, e.g. bridge structures (one junction linking two types) and hub structures (a central table linking several).

1 · Recap and why specialised models

Recap from Lecture 12: relational entity graph (rows = nodes, PK–FK = edges), training table with timestamps, GNN computation graphs on the entity graph. LLMs on serialised tables underperform: on RelBench, RDL-GNNs beat in-context-learning Llama-3.2-3B by roughly 10–25% ROC-AUC on most entity classification tasks (slide 19).

Why specialised architectures? Relational databases carry multi-modal information at the entity level (text, image, numerical, categorical, timestamp) and multi-scale structure at the database level (relational and temporal). Recurring motifs: tripartite patterns (users–sales–products), cycle patterns, and structure that changes over time.

Multi-modal, multi-scale information; tripartite and cycle patterns. slide 24 ↗

2 · RelGNN: composite message passing (ICML 2025)

The observation

Bridge and hub structures in RelBench schemas. slide 34 ↗

In a standard heterogeneous graph, "customer — purchase → product" is one typed edge. In a relational entity graph the purchase is a row in a transaction table: customer — transaction — product. Edges just record table connectivity without semantics, and junction tables decompose every many-to-many association into a pair of one-to-many links.

Junction tables split many-to-many links. slide 29 ↗

Atomic routes and composite messages

Atomic routes and composite message passing. slide 37 ↗

An atomic route is (informally) a simple path between non-junction node types through junction types, e.g. product → transaction → customer. Routes come straight from the schema — no manual intervention or domain knowledge. Composite message passing aggregates along a route in one step:

\[ \mathbf h_{dst}^{(l+1)}=\text{AGG}\Big(\mathbf h_{dst}^{(l)},\ \big\{\text{FUSE}\big(\mathbf h_{mid}^{(l)},\mathbf h_{src}^{(l)}\big)\big\}\Big),\qquad \text{e.g. }\ \text{FUSE}=\mathbf W_1\mathbf h_{mid}+\mathbf W_2\mathbf h_{src} \]

Instantiation on slide 37 uses attention-weighted aggregation over fused (junction, source) pairs. The junction node's own features are still used, but the source signal arrives in one hop with no bounce-back.

Results

RelGNN reaches state of the art on most RelBench tasks, with improvements up to 25% — e.g. rel-f1 (will a driver qualify top-3 next month?), rel-trial (trial-site success rate next year), rel-amazon (which items will a customer buy and review in detail in 3 months?).

Couldn't a 2-layer GNN learn the same thing as one composite step? What's really gained?

In principle a 2-layer MPNN sees the same 2-hop information, but it must route it through the junction's aggregated state: the junction first sums over all its neighbours (mixing the customer's own message with the product's), then the customer aggregates over all its junctions. Information about which product pairs with which transaction attributes is blurred, and the customer's own signal is double-counted. A composite message keeps each (transaction, product) pair together — an inductive bias that matches how the data was normalised. It's the relational-database version of "choose the computation graph deliberately" (Lecture 5).

3 · RelGT: a Relational Graph Transformer

Text transformers represent a token by (token id, position) — feature + structure. Graph transformers use (node feature, graph PE). Most are built for homogeneous, static graphs. Relational entity graphs are large-scale, heterogeneous and temporal, and existing PEs have limitations: designed for homogeneous graphs, no temporal dynamics, computational overhead, and the graph changes over time.

Tokenisation

  1. Sampling stage: for each training (seed) node, select a fixed set of \(K\) tokens from its local neighbourhood (e.g. up to 2 hops) by temporal-aware sampling.
  2. Each token: (feature, type, hop, time, GNN PE). slide 56 ↗
  3. Each token is a 5-tuple: (node feature, node type, hop distance from seed, time, GNN positional encoding).
  4. Element-wise encoders: PyTorch Frame encoder for the multi-modal row features; nn.Embedding for node type and hop distance; a time encoder; a light GNN on the sampled subgraph for the PE. Their combination is the token fed to the transformer.
  5. Element-wise encoders produce transformer tokens. slide 60 ↗

The architecture combines local attention over the sampled tokens with global attention to learnable centroids (slide 50). Ablations show every element of the multi-element tokenisation matters; overall RelGT improves over GNN baselines on RelBench.

4 · Towards relational foundation models

Limitations of all models so far: they are schema- and task-specific; they don't transfer knowledge from one database or task to another, and don't generalise to new databases or tasks. Goal: bring the success of foundation models (LLMs, ViT) to relational data.

The slides present a relational foundation model whose backbone is the Relational Graph Transformer, with zero-shot predictions via in-context learning (ICL): given labelled context examples from a new database, it predicts without training (KumoRFM). Time to first prediction drops from hours of human work and hundreds of lines of code to roughly a second and one line of a predictive query (slide 68). Lecture 14 continues with the Relational Transformer.

Relational foundation model capabilities, and time to first prediction. slide 66 ↗

The mathematics, step by step

Lecture 12 turned a database into a graph and ran a standard heterogeneous GNN on it. This session changes the architecture to fit how databases are built. There are three ideas, each one formula: skip over junction tables in a single step (RelGNN), describe each node to a transformer by a sum of five encodings (RelGT), and predict from examples placed in the input instead of from trained weights (the foundation model).

Symbols used in this session

symbolmeaningwhat kind of object
\(\mathbf h_{src},\ \mathbf h_{mid},\ \mathbf h_{dst}\)embeddings of the source row, the bridging (junction) row, and the destination row of a routevectors
\(\text{FUSE}\)combines the bridge row with the source row into one messagefunction, e.g. \(\mathbf W_1\mathbf h_{mid}+\mathbf W_2\mathbf h_{src}\)
\(\text{AGG}\)order-free aggregation over all routes that end at the destination (here with attention)function
\(\mathbf x_v,\ \tau(v)\)features of row \(v\); its table (node type)vector; type
\(d(v,\text{seed})\)number of hops from \(v\) to the seed node the prediction is forwhole number
\(t_v-t_{seed}\)age of row \(v\) relative to the prediction time (never positive)time difference
\(\phi_{\cdot}\)one encoder per kind of information: features, type, hop, time, structurefunctions with learned parameters
\(\{(G_i,y_i)\}_{i=1}^{k}\)context examples: subgraphs of other entities with their known labelsset of (subgraph, label) pairs

1Composite message passing along atomic routes

\[ \mathbf h_{dst}^{(l+1)}=\text{AGG}\Big(\mathbf h_{dst}^{(l)},\ \big\{\text{FUSE}\big(\mathbf h_{mid}^{(l)},\mathbf h_{src}^{(l)}\big)\big\}\Big),\qquad \text{FUSE}=\mathbf W_1\mathbf h_{mid}+\mathbf W_2\mathbf h_{src} \]

In words. When a row has two foreign keys, it bridges two other rows. Instead of passing a message to the bridge in one layer and on to the far side in the next, fuse the bridge row with the source row and deliver the pair to the destination in one step.

Why it has this form. In the graph of Lecture 12 an order row sits between a customer and a product. Standard message passing needs two layers for the product to reach the customer, and in the first layer the order averages its messages before passing them on, which dilutes them; messages also bounce back to where they came from. An atomic route is the triple (source, bridge, destination) read off the schema. Along a route the bridge row keeps its own columns (quantity, date) and is paired with exactly the source it points to, so the destination receives 'this product, bought in this order' as one message.

With numbers. Scalars with \(\mathbf W_1=\mathbf W_2=1\) and AGG = mean plus self. A customer (\(h=1\)) has two orders: order A (\(h_{mid}=2\), quantity information) of product P (\(h_{src}=10\)), and order B (\(h_{mid}=4\)) of product Q (\(h_{src}=20\)). Fused messages: \(12\) and \(24\); mean \(18\); new customer value \(1+18=19\). One layer was enough for the products to arrive, each still paired with its own order.

Watch out. Routes exist only where the schema has a table with two or more foreign keys. A table with one foreign key (a plain child table) is handled by ordinary message passing.

2RelGT: a token is a sum of five encodings

\[ \text{token}_v=\phi_{feat}(\mathbf x_v)+\phi_{type}(\tau(v))+\phi_{hop}(d(v,\text{seed}))+\phi_{time}(t_v-t_{seed})+\phi_{PE}(\text{GNN}(v)) \]

In words. Each row sampled around the seed becomes one input token for a transformer. The token is the sum of five vectors that say what the row contains, which table it is from, how far it is from the seed, how old it is, and where it sits in the local subgraph.

Why it has this form. A transformer treats its input as a set (Lecture 8), so everything about the graph must be written into the tokens. One global positional encoding, such as Laplacian eigenvectors, is too expensive for a database with millions of rows and ignores types and time. Splitting the position into separate, cheap pieces fits relational data: type and hop are small lookup tables, time is an encoding of a number, and the structural part is a small GNN with random initial features run on the sampled subgraph only.

With numbers. A sampled order row: its columns encode to \((0.2,0.1)\); table 'orders' to \((1,0)\); hop 1 to \((0,0.5)\); 'three days before the seed time' to \((-0.3,0)\); structure to \((0.1,0.1)\). Token \(=(1.0,\,0.7)\). The same order sampled for a different seed, at hop 2 and thirty days before, would get a different token although its columns are the same.

Watch out. Summation assumes the five encoders learn to use the dimensions without destroying each other's information; concatenation followed by a projection is the more cautious alternative.

3Local and global attention

\[ \mathbf h_{seed}=\text{FFN}\Big(\big[\ \text{Attn}\big(\text{token}_{seed},\{\text{token}_v\}_{v\in\text{sample}}\big)\ \Vert\ \text{Attn}\big(\text{token}_{seed},\{\mathbf c_b\}_{b=1}^{B}\big)\ \big]\Big) \]

In words. The seed attends in two directions: to the \(K\) rows sampled around it, and to \(B\) learned centroid vectors that summarise the whole database. The two results are concatenated and passed through a feed-forward network.

Why it has this form. Attention over the sample replaces message passing: every sampled row can reach the seed directly, whatever its hop distance, so there is no junction-table detour. But a sample only shows a neighbourhood. The centroids \(\mathbf c_b\) are a small set of vectors, updated during training as running cluster centres of all tokens seen, that give every seed the same view of global patterns at a cost of \(B\) extra attention scores instead of millions.

With numbers. With \(K=300\) sampled rows and \(B=4096\) centroids, the seed computes \(300+4096\) attention scores. Attending to a database of \(10^7\) rows directly would need \(10^7\) scores per seed.

Watch out. The centroids are not rows of the database and carry no timestamps, so they must be built from training-time data only.

4Prediction from context instead of from weights

\[ \hat y_{q}=f_\theta\Big(G_q,\ \big\{(G_i,y_i)\big\}_{i=1}^{k}\Big),\qquad \theta \text{ fixed after pretraining} \]

In words. A relational foundation model receives the query entity's subgraph together with a handful of other entities' subgraphs and their known labels, and predicts the query's label in one forward pass. No weights are trained for the new task.

Why it has this form. The labels \(y_i\) come for free from history, by the training-table construction of Lecture 12: pick earlier seed times and compute what happened next. The model's job, learned once over many databases and tasks, is to compare the query's subgraph with the labelled ones and transfer the labels. The task is defined entirely by the examples, so a new prediction question needs only a new query for the labels, not a new model.

With numbers. Task: 'will this customer buy in the next 30 days?' Context: 3 customers who bought (label 1) and 3 who did not (label 0), each with their subgraph as of an earlier date. If the query customer's subgraph resembles the buyers' (recent orders, frequent visits), the output is near 1.

Watch out. The context labels must be computed from windows that end before the query's seed time; otherwise the examples leak the future exactly as in Lecture 12.

Check yourself

Questions from the lecture, in order. Answer each one in your head (or on paper) before you open it. If one stumps you, follow the link to the walkthrough block it comes from.

Check yourself: (before reading on): in the users–sales–products graph, how many hops separate a user from a product they bought? show answer

Two, because the sale row sits in between. Keep this in mind; it is the starting point for RelGNN later in the lecture.

from Recap: relational databases as graphs

Check yourself: with 2 layers of standard message passing, which nodes does a customer "see"? show answer

Its transactions (hop 1), and at hop 2 the products and also itself again through each transaction. So a third of the 2-hop signal is the customer's own echo, and products enter only at the last layer.

from Junction tables in RelBench schemas, and why they hurt message passing

Check yourself: why must "time" be relative to the seed's time and not absolute? show answer

Because the same pattern ("bought something 3 days ago") should mean the same thing whatever the calendar date; relative time also generalises to future seed times not seen in training.

from RelGT: token feature encoders

Lecture walkthrough reference · slide by slide · opens on demand

The whole lecture in order, grouped by topic. Every drawing on the slides is redrawn here as a clean figure (click the step buttons where a figure has them), the heading of each block links to the matching pages of the official PDF, and the Review section after the walkthrough ties this session to the earlier ones. Read this and you do not need the deck.

  1. Recap: relational databases as graphs
  2. Recap: training table, entity graph, GNN
  3. Why not an LLM, and RDL's measured gains
  4. Why relational data needs specialised models
  5. Edges without semantics: junction tables
  6. Junction tables in RelBench schemas, and why they hurt message passing
  7. RelGNN: atomic routes and composite message passing
  8. Transformers on graphs: tokens, positions, attention
  9. From graph Transformers to the Relational Graph Transformer
  10. RelGT: sampling a local context as tokens
  11. RelGT: token feature encoders
  12. RelGT ablations and results
  13. Towards a Relational Foundation Model

Recap: relational databases as graphs slides 4-9 ↗

Slides 4–9, recap: the Users–Sales–Products database as a relational entity graph. slides 4-9 ↗

The lecture opens with a recap of Lecture 12.

Slide 4: valuable data in commerce, finance and social media is stored in relational databases (three schema diagrams: tables as boxes, key links as lines). Slide 5: typical predictive questions on such data: which products will a user purchase in the next 7 days? Will an active user churn in the next 90 days? What will the total sales of each product be in the next 30 days?

Slide 6, insight: data is a graph. The small schema has Users (ID), Sales (ID, Product_ID, Session_ID, User_ID, Price) and Products (Product_ID). Slide 7 draws the database as a graph: users on the left, sale nodes in the middle with their prices ($20, $80, $15, …), products on the right. Rows become nodes; key references become edges.

Slide 8, ML in the language of graphs:

  • node-level: churn, lifetime value, next best action;
  • link-level: product affinity, recommendations;
  • graph-level: fraud, money laundering.

Slide 9, the pipeline: Relational DB → Graph problem → Graph ML → Solutions.

Check yourself: (before reading on): in the users–sales–products graph, how many hops separate a user from a product they bought? show answer

Two, because the sale row sits in between. Keep this in mind; it is the starting point for RelGNN later in the lecture.

Recap: training table, entity graph, GNN slides 10-14 ↗

Slides 10–14, recap of the RDL pipeline. slides 10-14 ↗

Slide 10, the training table: a special table of training labels with rows (entity ID, time, label); it supports classification, regression and multi-class tasks. The example table has columns Entity ID, Timestamp, Label (e.g. entity 99 with label 1, entity 100 with label 0).

Slide 11, the four-panel RDL pipeline: (a) relational tables with a training table (Products, Transactions, Customers, and Customer LTV with 90-day LTV, User_ID, SeedTime); (b) entities linked by foreign keys; (c) the relational entity graph; (d) the GNN computation trees for the training rows A and B.

Slide 12, the relational entity graph: create connections via primary–foreign keys.

Slide 13: training labels, with timestamps, are attached to the graph (for example, one user has "May '23 Churn" and "June '23 Active").

Slide 14, a GNN on the entity graph: each node's neighbourhood defines its computation graph, and nodes learn how to use information from neighbours optimally. The same user has different computation graphs for different label times (May '23 vs June '23), because only earlier rows can be used.

Why not an LLM, and RDL's measured gains slides 15-19 ↗

Slide 19: measured gains of relational deep learning over an LLM used in context, task by task. slide 19 ↗

Slide 15 asks again: why not use an LLM? Slide 16, "some have tried": the paper "Tackling prediction tasks in relational databases with LLMs" (Wydmuch, Borchmann, Graliński; Snowflake AI Research) builds one LLM example by following the keys from a task-table row to the related Customers, Transactions and Products rows and serialising them into a JSON document. Slide 17 shows such a prompt: a full slide of dense JSON text for one example.

Slide 18 lists the reasons:

  • LLMs are not trained to understand and learn from the relational nature of databases.
  • Database prediction is not sequence modelling.
  • LLMs are not trained to predict the future.
  • Context size is limited.

Slide 19, RDL gains over LLM: entity classification, ROC-AUC (%) on the RelBench test set, comparing in-context learning with Llama 3.2 3B against RelGNN:

  • rel-amazon: user-churn 62.55 vs 70.99 (13% relative gain); item-churn 73.41 vs 82.64 (13%).
  • rel-avito: user-visits 53.36 vs 66.18 (24%); user-clicks 54.07 vs 68.23 (26%).
  • rel-event: user-repeat 70.11 vs 79.61 (14%); user-ignore 68.65 vs 86.18 (26%).
  • rel-f1: driver-dnf 80.03 vs 75.29 (−6%); driver-top3 87.11 vs 85.69 (−2%).
  • rel-hm: user-churn 63.81 vs 70.93 (11%).
  • rel-stack: user-engagement 81.23 vs 90.75 (12%); user-badge 79.99 vs 88.98 (11%).
  • rel-trial: study-outcome 59.17 vs 71.24 (20%).

RelGNN wins on 11 of 13 tasks, often by double digits. The two exceptions are both rel-f1, a small database (Formula 1 results), where the LLM's world knowledge about drivers may help. The slide ends with "stay tuned for more discussion on LLMs later" (Lecture 16).

Why relational data needs specialised models slides 21-24 ↗

Slides 21–24: rows mix modalities and the graph has recognisable tripartite and cycle patterns that change over time. slides 21-24 ↗

Slides 21–23 build one message: relational databases hold multi-modal, multi-scale information.

  • Entity level (slide 22): each row mixes modalities: text, image, numerical, categorical, timestamp. The schema picture: Products (ProductID, Description, Image, Size), Transactions (TransactionID, ProductID, Timestamp, CustomerID, Price), Customers (CustomerID, Name).
  • Database level (slide 23): there is relational structure (how rows link across tables) and temporal structure (when rows were created).

Slide 24, the structure of relational databases has recognisable patterns:

  • Tripartite patterns: users – sales – products. Every user–product relation passes through a middle layer of sale rows.
  • Cycle patterns: two users each bought the same two products (a T-shirt and sneakers), giving a cycle user → sale → product → sale → user → sale → product → sale → back.
  • Structure changes over time: new sale rows keep arriving, so the graph grows.

The point: a generic GNN or transformer treats all of this the same way. Architectures that know about modalities, the tripartite shape and time should do better. The rest of the lecture gives two such architectures (RelGNN and RelGT) and then a foundation model.

Edges without semantics: junction tables slides 26-29 ↗

Slides 26–29: in a relational entity graph the purchase is a node, and junction tables turn every many-to-many relation into a pair of one-to-many links. slides 26-29 ↗

Slides 26–27 compare two graphs of the same purchase data:

  • A standard heterogeneous graph: customer —purchase→ product. The edge itself carries the meaning.
  • The relational entity graph: customer — transaction — product. The purchase is a row (node) of the Transactions table, linked to both sides by keys.

Slide 28, observation: edges in relational entity graphs are defined by primary–foreign key links that merely record table connectivity, without semantics. An edge says "this row's foreign key points to that row", nothing more.

Slide 29: databases introduce junction tables, which decompose each many-to-many association into a pair of one-to-many links. The figure: on the left, customers 1, 2 and products 1, 2 with crossing many-to-many edges; on the right, the same information stored with transactions 1, 2, 3 in the middle, each pointing to one customer and one product.

Why databases do this: a relational column can hold only one value, so a customer row cannot list all its products. The standard design (normalisation) is a separate table whose rows are the pairs. The cost for graph learning: every customer–product relation becomes a 2-hop path through a node that is often just bookkeeping.

Junction tables in RelBench schemas, and why they hurt message passing slides 31-35 ↗

Slides 31–35: RelBench schemas are full of junction tables in bridge and hub shapes, which make plain message passing imbalanced and redundant. slides 31-35 ↗

Slide 31 recalls the 7 RelBench datasets: E-commerce (rel-amazon, rel-avito, rel-hm), Social (rel-event, rel-stack), Sports (rel-f1), Medical (rel-trial).

Slides 32–34 show their schema graphs, with pink nodes for entity tables and purple nodes for junction tables:

  • rel-amazon: customer — review — product.
  • rel-hm: customer — transactions — article.
  • rel-F1: entity tables constructors, races, drivers, circuits; junction tables constructor_standings, constructor_results, standings, results, qualifying, each pointing to two or three entity tables.

Slide 34 names two shapes: a bridge structure (a junction table linking two entity tables: standings → races, drivers) and a hub structure (a junction table linking three or more: results → races, constructors, drivers).

Slide 35, the limitations of standard message passing on such graphs:

  1. Imbalance: junction nodes are 1-hop neighbours, while the more informative nodes become 2-hop. For a customer, the 1st-hop neighbour is a transaction and the product is only a 2nd-hop neighbour.
  2. Redundancy: information from the source node is passed to the junction node in the first hop and routed back to itself in the second hop, where it is aggregated together with the junction and 2-hop node information. The figure: customer → transaction (1st hop), transaction → customer (2nd hop).
Check yourself: with 2 layers of standard message passing, which nodes does a customer "see"? show answer

Its transactions (hop 1), and at hop 2 the products and also itself again through each transaction. So a third of the 2-hop signal is the customer's own echo, and products enter only at the last layer.

RelGNN: atomic routes and composite message passing slides 36-38 ↗

Slides 36–38, RelGNN: atomic routes from the schema, and composite message passing that fuses the junction row with its source and delivers it in one hop. slides 36-38 ↗

Slide 36, atomic routes (RelGNN, Chen, Kanatsoulis, Leskovec, ICML 2025). Informally, an atomic route is a simple path between pink (entity) node types, going through purple (junction) types if needed. They can be derived automatically from the schema, without manual intervention or domain knowledge. On the rel-f1 primary–foreign key graph the examples are: circuits → races (a direct link); races ← standings → drivers (a bridge); races ← results → drivers (one route through the results hub).

Slide 37, composite message passing: aggregate messages along atomic routes in a single step. For a route (src, mid, dst),

\[ \mathbf m^{(l+1)}_{(\text{dst},\text{mid},\text{src})}=\text{AGGR}\Big(\mathbf h^{(l)}_{\text{dst}},\ \big\{\!\!\big\{\text{FUSE}\big(\mathbf h^{(l)}_{\text{mid}},\mathbf h^{(l)}_{\text{src}}\big)\big\}\!\!\big\}\Big). \]

The junction node's features and the source node's features are first fused, and the fused message goes straight to the destination. An instantiation:

\[ \text{FUSE}\big(\mathbf h^{(l)}_{\text{mid}},\mathbf h^{(l)}_{\text{src}}\big)=\mathbf W_1\mathbf h^{(l)}_{\text{mid}}+\mathbf W_2\mathbf h^{(l)}_{\text{src}}, \] \[ \text{AGGR}\big(\mathbf h^{(l)}_{\text{dst}},\{\!\{\mathbf h^{(l)}_{\text{fuse}}\}\!\}\big)=\mathbf W_{\text{proj}}\mathbf h^{(l)}_{\text{dst}}+\sum_{\text{fuse}\in\mathcal N(\text{dst})}\alpha_{\text{dst},\text{fuse}}\,\mathbf W_V\,\mathbf h^{(l)}_{\text{fuse}}, \]

i.e. an attention-weighted sum (weights \(\alpha\)) of the fused messages plus a projection of the destination's own state. The figure contrasts standard message passing (customer ← transaction ← product takes 2 hops, and the customer's message goes to the transaction and back) with composite message passing (transaction and product are fused into one message that reaches the customer in a single hop).

This fixes both problems of slide 35: the product is now a 1-hop source (no imbalance), and the customer's own state is not echoed back through the junction (no redundancy).

Slide 38, results (Hetero-GNN vs RelGNN):

  • rel-F1, predict whether a driver will qualify in the top 3 for a race in the next month: ROC-AUC, 13% improvement.
  • rel-trial, predict the success rate of a trial site in the next year: MAE (lower is better), 25% improvement.
  • rel-amazon, predict the list of distinct items each customer will purchase and review in detail in the next 3 months: MAP, 11% improvement.

RelGNN achieves state-of-the-art performance on the vast majority of RelBench tasks, with improvements of up to 25%.

Transformers on graphs: tokens, positions, attention slides 40-45 ↗

Slides 40–45, recap of the graph transformer design: match the three graph inputs to the three transformer components. slides 40-45 ↗

Slides 40–41 recall the key components of a Transformer (slide credit Joshua Robinson; the header cites You, Ying, Leskovec, "Design Space of Graph Neural Networks", NeurIPS 2020):

  1. tokenizing (the inputs \(x_1,x_2,\dots\));
  2. positional encoding (added to each token);
  3. self-attention (the Transformer block over all tokens).

Key question: what should these be for a graph input? How do we choose them for graph data?

Slides 42–44, processing graphs with Transformers. A graph Transformer must take as input (1) node features, (2) adjacency information, (3) edge features. There are many ways to do this; different approaches correspond to different "matchings" between the graph inputs (1)–(3) and the Transformer components (1)–(3). Slide 44 draws the standard matching (Lecture 8): node features → tokens, adjacency information → positional encoding, edge features → self-attention (as attention biases).

Slide 45, PEARL + Transformer: how to use PEARL (a learnable positional encoding) in practice:

  1. Sample node IDs from a probability distribution (random input vectors \(\mathbf q^{(1)},\dots,\mathbf q^{(M)}\)).
  2. Process each set of node samples independently with a GNN, on the graph with node attributes removed (giving \(\mathbf P^{(1)},\dots,\mathbf P^{(M)}\)).
  3. Summarise the outputs by an empirical expectation, \(\mathbf P=\rho[\cdot]\) over the \(M\) samples.
  4. Concatenate the PEARL embeddings with the node features \(\mathbf X\).
  5. Pass through the main GNN/Transformer as usual (output \(\mathbf Y\)).
  6. Backpropagate to train PEARL and the prediction model jointly.

Why remove node attributes in step 2: the PE should encode structure only (where a node sits), so the GNN sees the bare graph with random inputs; averaging over samples makes the result stable and equivariant to node relabelling.

From graph Transformers to the Relational Graph Transformer slides 46-51 ↗

Slides 46–51: a token is feature plus structure; for relational graphs the structure needs several elements. slides 46-51 ↗

Slide 46: in a (text) Transformer, an input token is represented by 2 elements: the token id (its feature) and its position (its structure). The picture is the original encoder–decoder Transformer with positional encodings added at the inputs.

Slide 47: in a graph Transformer, a token (node) is also 2 elements: the node feature (feature) and a graph positional encoding (structure). The picture is a graph Transformer layer.

Slide 48: but most graph Transformers are designed for homogeneous, static graphs. RDL adds heterogeneity and temporality, so the design must be improved.

Slide 49: for RDL, the inputs a graph Transformer must take become: node features, adjacency information, edge features (crossed out: PK–FK edges carry no features), node types, and timestamps.

Slide 50, the Relational Graph Transformer (RelGT). Pipeline figure: relational entity graph → tokens (for each seed node, a set of local-context nodes) → Transformer network (\(L\) layers; the seed attends to its local tokens and to a set of global centroids) → downstream layers → prediction. The key idea: represent graph structure with multiple elements, not one: node feature + <multiple information elements> that together encode structure.

Slide 51, limitations of existing positional encodings for RDL:

  • designed for homogeneous graphs;
  • no temporal dynamics;
  • computational overhead (e.g., Laplacian eigenvectors of a graph with millions of rows);
  • the graph changes over time (so a PE computed once becomes stale).

RelGT: sampling a local context as tokens slides 52-56 ↗

Slides 52–56, Relational Graph Transformer: sample a local context around each seed node and turn it into K five-element tokens. slides 52-56 ↗

Slide 52, the unique properties of relational entity graphs and the matching fixes. The graph is:

  • large-scale,
  • heterogeneous → add a categorical encoding of node type,
  • temporal → add a time encoding.

Slide 53: for the large scale, we cannot attend over the whole graph. Solution: sample a subgraph around the seed node.

Slide 54: training (seed) nodes are the nodes of the type on which the task is defined (e.g., customers for churn). For each seed node we sample a context (subgraph). The figure maps the entity graph to a "seed node + local context" token set.

Slide 55, token preparation (sampling stage):

  • For each training node, a fixed set of \(K\) tokens from its local neighbourhood (e.g., up to 2 hops) is selected with temporal-aware sampling (only rows from before the seed time). With \(B\) training nodes in a batch, this gives \(B\times K\) tokens.
  • Structure is encoded with a GNN positional encoding for each node in the context, plus its hop distance from the seed node.

Slide 56: each of the \(K\) context nodes is represented by a 5-tuple:

\[ (\text{node feature},\ \text{node type},\ \text{hop distance},\ \text{time},\ \text{GNN PE}). \]

Compare with slide 46: a text token has 2 elements; a RelGT token has 5. Node type handles heterogeneity, time handles temporality, and hop distance plus the GNN PE handle structure.

The GNN PE here is computed on the small sampled subgraph, not on the full database graph. That keeps it cheap and always current, which answers the "computational overhead" and "graph changes over time" limitations of slide 51.

RelGT: token feature encoders slides 57-60 ↗

Slides 57–60: each element of a token has its own encoder; their combination is the token the Transformer sees. slides 57-60 ↗

Slides 57–60 build the encoder picture step by step.

Slide 57: seed nodes and their local tokens. Slide 58: for each local token, the five elements are extracted: node feature, node type, hop distance, time, and the sampled subgraph (for the GNN PE).

Slides 59–60: each element goes to its own element-wise encoder, and their combination becomes the token feature fed to the Transformer:

  • node feature → a Torch Frame encoder (handles the row's mixed columns: numerical, categorical, text, timestamps);
  • node type → nn.Embedding (a learned vector per table);
  • hop distance → nn.Embedding (a learned vector per distance 0, 1, 2, …);
  • time → a time encoder (of the time relative to the seed);
  • subgraph → a GNN encoder that produces the GNN positional encoding.

Slide 60 also draws the sampled subgraph next to the GNN encoder, showing that the PE is computed from it.

Check yourself: why must "time" be relative to the seed's time and not absolute? show answer

Because the same pattern ("bought something 3 days ago") should mean the same thing whatever the calendar date; relative time also generalises to future seed times not seen in training.

RelGT ablations and results slides 61-62 ↗

Slides 61–62: ablations of the five token elements, and RelGT's gains and losses against the GNN baseline. slides 61-62 ↗

Slide 61, ablation studies (Table 2: relative drop in % after removing one component; negative means the component matters). Averages over the eight tasks:

  • no global module: −3.87;
  • no GNN PE: −5.95;
  • no node type: −1.75;
  • no hop distance: −2.19;
  • no relative time: −9.91.

Every element helps on average, and relative time helps most. The extreme case is rel-hm item-sales without relative time: −77.24. Some entries are positive (e.g., rel-avito user-clicks gains 7.79 without the global module), so not every component helps on every task. Takeaway: the multi-element tokenization is what lets RelGT capture arbitrary structure in relational data.

Slide 62, results (Table 1, RelBench test set; RDL = HeteroGNN baseline, HGT = heterogeneous graph Transformer, HGT+PE = HGT with Laplacian PEs; relative gain over RDL):

  • Entity regression (MAE, lower is better). Examples: rel-trial site-success RDL 0.400 → RelGT 0.3263 (+18.43%); rel-avito ad-ctr 0.041 → 0.0345 (+15.85%); rel-f1 driver-position 4.022 → 3.9170 (+2.61%); rel-stack post-votes 0.065 → 0.0654 (−0.62%).
  • Entity classification (AUC, higher is better). Examples: rel-f1 driver-top3 0.7554 → 0.8352 (+10.56%); rel-f1 driver-dnf 0.7262 → 0.7587 (+4.48%); rel-avito user-clicks 0.6590 → 0.6830 (+3.64%); rel-stack user-badge 0.8986 → 0.8632 (−3.94%); rel-hm user-churn 0.6988 → 0.6927 (−0.87%).

Takeaway: Relational Graph Transformers improve over GNNs on most tasks, and clearly over plain HGT and HGT+PE (generic graph Transformers). The gains are not universal: on a few tasks the GNN baseline remains better.

Towards a Relational Foundation Model slides 64-68 ↗

Slides 64–68: from schema-specific models to a relational foundation model built on RelGT with in-context learning. slides 64-68 ↗

Slide 64, limitations of all previous models (GNNs, RelGNN, RelGT):

  • they are schema- and task-specific (trained for one database and one training table);
  • they do not transfer knowledge from one database to another or from one task to another;
  • they do not generalise to new databases or tasks.

Slide 65, can we do better? Goal: bring the success of foundation models (LLMs, ViT) to relational data.

Slide 66, the Relational Foundation Model (RFM) figure. One model receives questions such as "What will user 123 buy next?", "Will user 321 churn soon?", "Is transaction 557 fraudulent?", "Will clinic 987 have high appointment demand?", "Is patient 234 at risk of hospital readmission?". It produces predictions, explanations and evaluations. It works across schemas: (a) e-commerce (Users, Orders, Likes, Items), (b) finance (Customers, Transactions, Account, Branch), (c) health care (Patient, Record, Visit, Doctor). The caption lists the key capabilities: apply to new, unseen databases with very different structure; handle any predictive task type, from one-off assessments (entity-level fraud) to temporal queries (recommendation); generalise to new tasks without task-specific tuning; and support explanations and quantitative evaluation to build trust.

Slide 67, RelGT as the backbone of the RFM (KumoRFM, "A Foundation Model for In-Context Learning on Relational Data", May 2025). The pipeline:

  1. A task is written as a query in a predictive query language, e.g. PREDICT COUNT(orders.*, 0, 7) FOR users.user_id = 0 (how many orders will user 0 place in the next 7 days?). A PQL parser and validator check it.
  2. A backward-looking graph sampler builds context examples: subgraphs around entities at earlier times \(\hat t\lt t\), together with their known labels \(y\) (a forward-looking sampler computes those labels from what happened after \(\hat t\)).
  3. The prediction subgraph is the queried entity at time \(t\), with unknown label "?".
  4. A Relational Graph Transformer (\(L\) times) encodes context and query, and in-context learning produces the prediction (with an "explain" path back).

So RelGT is the backbone of the first relational foundation model with zero-shot capabilities powered by in-context learning (ICL): no training on the new database or task.

Slide 68, time to first prediction on node classification tasks (user-engagement, user-badge, user-churn (amazon), item-churn, driver-dnf, driver-top3, user-churn (hm), study-outcome), log scale. KumoRFM is orders of magnitude faster: about 1 second vs about 30 minutes (RDL) vs about 12.3 hours (data scientist) of human labour, and needs about 1 line of code vs about 56 (RDL) vs about 878 (data scientist).

The trajectory of Lectures 12–13: hand features (hours, ~900 lines) → task-specific RDL (minutes, ~50 lines) → foundation model with in-context learning (seconds, one query). It mirrors the path NLP took from feature engineering to fine-tuned models to prompting.

Not shown (no new content): slides 1,2,3,20,25,30,39,63 — title page, announcements, and section-divider title pages.

Review: what to keep from this session

Carried forward. Lecture 14 generalises the in-context idea (PRODIGY) to graphs at large; Lecture 15 does the same for knowledge graphs.

Quick self-check

What is an atomic route?

A short path (e.g. customer → transaction → product) treated as one message, so the informative node two hops away reaches the target in one step.

Why is a junction node a problem for plain message passing?

It has few features of its own but sits between the nodes that matter, so it dilutes the message and doubles the hops needed.

What makes a model a foundation model here?

It is pretrained once and solves new tasks on new databases from in-context examples, without gradient updates.

Key idea

Architect for how relational data is actually stored: send messages along schema-derived atomic routes so junction tables don't dilute or echo information (RelGNN), or encode each context node with type, hop, time and structure for a transformer (RelGT) — the backbone for relational foundation models.

\[ \text{token}_v=\phi_{feat}(\mathbf x_v)+\phi_{type}(\tau(v))+\phi_{hop}(d(v,\text{seed}))+\phi_{time}(t_v-t_{seed})+\phi_{PE}(\text{GNN}(v)) \]

One natural way to combine RelGT's five element-wise encodings (sum or concatenation + projection).

Worked example: what a customer's embedding sees

Customer C bought product P₁ via transaction T₁ (price 20) and P₂ via T₂ (price 80). Each transaction has features (price, time); each product (category).

  1. Standard 2-layer MPNN. Hop 1: T₁ aggregates {C, P₁}; T₂ aggregates {C, P₂}. Hop 2: C aggregates {T₁, T₂}. C's own vector enters twice (redundancy), and P₁'s category reaches C only after being mixed into T₁'s state (imbalance).
  2. RelGNN. One composite step: C aggregates {FUSE(T₁, P₁), FUSE(T₂, P₂)} = {"20 on a bike", "80 on shoes"}. The pairing between price and category is preserved exactly — the information a data scientist would write as SUM(price) GROUP BY category.
  3. RelGT. Seed C; sampled tokens {C, T₁, T₂, P₁, P₂, (other buyers of P₁…)} each tagged with (type, hop 0/1/2, relative time, PE); attention can relate any pair directly.

Strictly speaking: gains depend on schema shape — databases with few junction tables benefit less from RelGNN; RelGT's cost grows with the context size \(K\).

Proof workshop: When composite message passing is exactly two hops in one

One problem in olympiad style. Give it fifteen minutes on paper before you open the first hint; the hints are graded, so open them one at a time.

Problem. Each transaction \(e\) links one customer \(c(e)\) and one product \(p(e)\). Two-layer standard heterogeneous MP gives \(h_c=\mathrm{AGG}_{e\in T(c)}\psi\big(h_e,\,\mathrm{AGG}'_{q\in N(e)}h_q\big)\), where \(N(e)=\{p(e)\}\) (ignore the edge back to \(c\)). Composite MP gives \(h_c=\mathrm{AGG}_{e\in T(c)}\phi(h_e\oplus h_{p(e)})\). Prove that, with expressive enough \(\psi,\phi\), both families compute the same functions of \(\{\!\{(h_e,h_{p(e)})\}\!\}_{e\in T(c)}\). What, then, does composite MP buy?

Hint 1
What is \(\mathrm{AGG}'\) of a one-element multiset, for sum, mean or max?
Hint 2
Each side applies an outer aggregate to a per-transaction function of \((h_e,h_{p(e)})\). Can each side simulate the other's per-transaction function?
Solution
For a singleton, mean and max return the element and sum returns it too; write \(\mathrm{AGG}'\{h_{p(e)}\}=h_{p(e)}\) (or a fixed injective map of it). Then standard MP is \(\mathrm{AGG}_e\,\psi(h_e,h_{p(e)})\), and composite MP is \(\mathrm{AGG}_e\,\phi(h_e\oplus h_{p(e)})\). Concatenation is injective, so for any \(\psi\) take \(\phi(x\oplus y)=\psi(x,y)\), and conversely. The families coincide. What composite MP buys is cost, not power: one layer instead of two, no intermediate transaction state to learn and store, fewer parameters. That matches the notebook (2-layer MP \(\approx\) composite MP \(\approx0.96\)). It also gives a better inductive bias when the product's state should not be mixed with the other edges of the transaction node. \(\square\)

Why it matters. Read architecture papers through this lens: does the change add expressive power, or does it reorganise computation for efficiency and inductive bias? Both are legitimate, but they need different evidence: a separation result for the first, a controlled efficiency comparison for the second.

Sharper lens: walks that do not turn back

Not on the slides. Three or four points where the lecture rounds something off: the exact statement, a second way to see it, and where it stops being true. Each is short and has a pointer for going further.

second viewpoint

Composite messages are non-backtracking walks

The "redundancy" in the lecture has a precise form. In two rounds of ordinary message passing, information moves along all walks of length 2, including customer → transaction → the same customer. A transaction row has few neighbours (its customer, its product), so a large share of what returns to the customer is the customer's own state, echoed. An atomic route product → transaction → customer keeps only the walks that do not turn back.

Walks that never immediately reverse are counted by the non-backtracking (Hashimoto) matrix, indexed by directed edges, and its advantage is known from network science: on sparse graphs the spectrum of the adjacency matrix is dominated by hubs and their echoes, while the non-backtracking spectrum still shows the communities, down to the theoretical detection threshold (Krzakala et al., PNAS 2013). Removing the echo is not only a saving. It changes which signal dominates, and it is the same reason "redundancy-free" message passing helps on trees and molecules.

precise statement

Why in-context learning is natural on a database: history labels itself

For a language model, in-context examples must be supplied by the user. For a temporal database they are free. A predictive query such as "will this customer buy in the next 30 days?" can be evaluated at any past date, because the database already holds what happened in the following 30 days. Section 4's foundation model builds its prompt this way: sample earlier timestamps, compute the true labels from history, attach each entity's subgraph as it stood then, and place the present-day query after them.

The training table of Lecture 12 has become the prompt, which has two consequences. The time rule of Lecture 12 now applies inside the prompt: every context example may use only data before its own timestamp, and its label window must end before the query's time. And a task whose labels were rare or absent in the past (a new product line, a new kind of fraud) has no context to learn from, however large the model.

where it breaks

A fixed token budget meets a heavy-tailed degree distribution

RelGT gives every seed node \(K\) tokens from at most two hops. Relational data is heavy-tailed: a best-selling product or a marketplace account has millions of linked rows, and a temporal sampler that keeps the most recent \(K\) sees a few minutes of a hub's history and several years of a quiet customer's. Sampling recent rows is a sensible prior and still a decision about which evidence the model may use; for hubs, recency-weighted or stratified sampling, or pre-aggregated summary rows, can matter more than the architecture.

The positional encoding deserves a second look too. A light GNN run on random node features over the sampled subgraph is Lecture 8's PEARL at small scale: it tells tokens apart by local structure without an eigendecomposition, and like PEARL it is equivariant only in expectation over the random features.

Lab: hands-on and practical tips

notebook · L13 advanced RDL builds a junction-table database, shows standard heterogeneous message passing, implements composite message passing along atomic routes (RelGNN) and RelGT's token representation.

Find the junction tables in your schemaA table whose rows are mostly foreign keys (retweets: user × tweet; hashtag_uses: tweet × hashtag; mentions: tweet × user) is a junction. Standard message passing spends a hop on it and echoes the sender's message back (toggle the figure above).
Atomic routes carry the row's features on the edgeWhen you collapse customer → transaction → product into one edge, put the transaction's attributes (amount, time) into the edge features; otherwise you lose exactly what the junction row stored.
RelGT tokens are a 5-tuple(features, node type, hop distance, time, GNN positional encoding). Sampling a temporal local context around each seed and tokenising it is what makes the transformer schema-agnostic; the time entry is the cutoff again.
Ablate the route choiceRelGNN reports up to 25% gains on RelBench; the gain depends on how many junction tables the schema has. Report the number of atomic routes you derived and which ones mattered.

Readings & lookup guide

lecture notes CS224W course notes (Leni Aniva, Autumn 2024 — in your course folder)

Concise written version of the lectures; the walkthrough above cites it page by page.

read first Chen, Kanatsoulis, Leskovec — RelGNN: Composite Message Passing for Relational Deep Learning (ICML 2025)

  • Read: the analysis of bridge and hub structures and the imbalance/redundancy problems; the definition of atomic routes and how they're extracted from the schema graph; the composite message passing equations.
  • Skim: RelBench results tables — note which datasets gain most and relate that to their schema shapes.

core Dwivedi, Jaladi, Shen, et al. — Relational Graph Transformer (2025)

  • Read: the multi-element tokenisation (5-tuple), temporal-aware sampling, local + global (centroid) attention, and the ablation table.
  • Connect: compare with Lecture 8's design space — which elements map to tokens, PEs and attention?

industry KumoRFM technical report (Kumo AI, 2025)

Search "KumoRFM: A Foundation Model for In-Context Learning on Relational Data" · skim (~30 min)
  • How a relational graph transformer is used for zero-shot predictive queries — a bridge to Lecture 14's Relational Transformer.

Homework & deadlines

Colab 4 out Thu 11/5 · due Tue 12/1

Released with this lecture; open it from the course website and save a copy into the course folder. Expect RDL / heterogeneous-graph material with RelBench and PyG.

Homework 3 due Thu 11/12 · Milestone due Tue 11/10 · Exam Wed 11/18

The exam focuses on Lectures 1–13: this is the last lecture in the focus window. Use every page's self-check and flashcards as revision.

Self-check

A junction table typically represents …

  1. a one-to-one relation
  2. a primary key
  3. a many-to-many association split into two one-to-many links
  4. a training table

E.g. transactions linking customers and products.

"Redundancy" in standard message passing on relational graphs means …

  1. a node's own information returns to it through the junction node
  2. duplicate rows
  3. too many layers
  4. repeated tables

Hop 1 sends it into the junction; hop 2 brings it back.

Atomic routes in RelGNN are obtained …

  1. by domain experts
  2. automatically from the schema graph
  3. by random walks
  4. from the training table

Simple paths between non-junction node types.

Which is NOT one of RelGT's five token elements?

  1. node type
  2. hop distance
  3. time
  4. node degree in the full database

The 5-tuple is (features, type, hop, time, GNN PE).

The main limitation that relational foundation models address is …

  1. lack of GPUs
  2. too few tables
  3. models being schema- and task-specific
  4. missing timestamps

They aim to generalise to new databases and tasks via ICL.

Flashcards (click to flip)

Imbalance & redundancy
Informative node 2 hops away; own info echoes back via junction.
Composite message
AGG(h_dst, {FUSE(h_mid, h_src)}) along an atomic route in one step.
Bridge vs hub
One junction linking two types vs one central table linking many.
RelGT token
(features, type, hop distance, time, GNN PE) via element-wise encoders.
RelGT sampling
K temporal-aware tokens from ~2-hop context per seed; local + global attention.
Relational foundation model
RelGT backbone; zero-shot predictions via in-context labelled examples.

History & the bigger picture

  • 1970s — normalisation (Codd's normal forms): databases split many-to-many relations into junction tables to avoid redundancy and update anomalies. Ironically, the design that removes redundancy for storage creates it for message passing.
  • 2024 — RDL & RelBench; 2025 — RelGNN, RelGT, KumoRFM; the first relational foundation models appear.
Philosophy of science · inductive bias from the data's history

RelGNN is a neat example of an architectural inductive bias coming not from physics or geometry but from how humans engineered the data. Schemas encode decades of database-design practice; a model that reads the schema inherits that accumulated knowledge. It's a reminder that "raw data" is never raw — it carries the theory of whoever designed its storage.

Classic SNA bridge

In this lectureClassic SNA counterpartWhat carried over, what changed
Junction table (customer × product via transactions)Two-mode (affiliation) data and its one-mode projection; hypergraphs of eventsA junction table is an affiliation matrix. SNA projected it (losing the event); RelGNN keeps the event's attributes on the composite edge; hypergraph models keep the event as a node. Three answers to Breiger's duality.
Imbalance: informative node two hops away, bland node one hop awayWeighting alters by tie type and distance; "effective size" discounts redundant alters (Burt 1992)Burt discounted alters that only repeat what others say; the redundancy problem of junction tables is the same echo, caused by the schema instead of by social structure.
Atomic routes derived from the schemaMeta-paths chosen by the analyst (Author–Paper–Author)Both are symbolic path templates. RelGNN derives them automatically from key structure; HIN analysis chose them from domain knowledge. Combining the two is an obvious next step.
RelGT: sample a temporal local context, tokenise itEgo-network sampling with a time window (e.g. "contacts in the last 30 days")The context sampler is a temporal ego network. Its five-tuple tokens encode what an ego-network table would: alter attributes, alter type, distance, recency.
Relational foundation modelComparative sociology: the same model across organisations with different record systemsCross-schema transfer is the technical form of "the same theory should hold in a different organisation". Statistical SNA achieved it with a common model (ERGM terms); RDL attempts it with a common tokenisation.
Bridge idea

Model retweeting three ways on the same data: (1) standard message passing through the retweet row, (2) a composite user→tweet edge carrying the retweet time, (3) a hyperedge per cascade. Evaluate engagement prediction and inspect which alters each model weights. The comparison tells you, for social data specifically, when the junction is noise and when the event itself carries the signal.

Connecting to your research

For SNA
  • Social platforms are full of junction tables: retweets (user × tweet), hashtag_uses (tweet × hashtag), mentions (tweet × user). A user's retweet behaviour reaches them via user → retweet-row → tweet → author — exactly an atomic route. RelGNN-style composite messages could model "who amplifies whom" more faithfully.
  • For your proposal: framing a social-media database as a relational entity graph and comparing GNN / RelGNN / RelGT on engagement or account-suspension prediction is a novel, concrete, publishable study (RelBench has no Twitter-like dataset).

Frontier 2025–26: what changed since the slides

2025RelGNN and RelGT, and what came after — Composite message passing along atomic routes (RelGNN, ICML 2025, as the section above says) and the relational graph transformer (RelGT, a 2025 preprint) are the two architectures of this lecture. Treat the reported gains as the authors' numbers: an October 2026 study, Revisiting Simple Baselines for Relational Deep Learning (Nguyen, Dwivedi & Gust), shows that fixed low-pass feature propagation plus an MLP, refined by Correct & Smooth (Lecture 20), recovers a substantial part of heterogeneous-GNN performance on RelBench. RT-J (also October 2026) scales Relational Transformer pretraining for context-efficient prediction.sources: arXiv:2610.20534 · arXiv:2610.17867 · arXiv:2502.06784 · arXiv:2505.10960
ICLR 2026Relational Transformer: the schema is input — Tokenise cells with table and column names, mask tokens for any task, restrict attention with relational masks (column, feature, neighbour, full). Pretrained leave-one-database-out, it transfers zero-shot. This is the "relational foundation model" the lecture points toward (Lecture 14).sources: arXiv:2510.06377
ICML 2026PluRel and scaling laws for relational data — Synthetic relational databases for pre-training and the first scaling-law studies on relational tasks: the questions of a field that has decided its models work and now asks how they scale.
Atlas · hypergraphsA junction table is a hyperedge — A transaction row links one customer, one product and a time; a reply thread links many users. Hypergraph neural networks (AllSet: node → hyperedge → node multiset functions) are the general form of composite message passing, and TopoBench/DHG-Bench (ICLR 2026) make the comparison cheap.
Open question to carryCan atomic routes be learned rather than read from the schema, for databases with poor or missing foreign-key declarations (and for social data where the "schema" is an analyst's choice)? ∂lift (2026 preprint) learns which cells to add to a graph; the same idea applies to routes.
Frontiers · message passing on hyperedges · learned liftings

Words & phrases

TermSimple meaningPersianIn context
junction tablen.a table whose rows link entities of two other tables (many-to-many)جدول واسط (پیوند)"many-to-many relations are stored through junction tables"
dilutev.to make weaker by mixing with something elseرقیق کردن، کم‌اثر کردن"so junction tables don't dilute or echo information"
compositeadj.built from several parts acting as one unitمرکب"composite message passing along atomic routes"
atomicadj.smallest, not split furtherاتمی (تجزیه‌ناپذیر)"an atomic route through a junction table"
redundancyn.repeating the same information more than neededافزونگی"extra layers add redundancy"
sampled contextn.a small neighbourhood drawn at random around the target, fed to the modelزمینه نمونه‌گیری‌شده"RelGT tokens come from a sampled context"

Go deeper

  • Next: Lecture 14 — advanced topics: Relational Transformer (zero-shot), PRODIGY (in-context learning over graphs), conformal prediction for GNNs.
  • Open question: can atomic routes be learned rather than read from the schema — e.g. for databases with poor or missing foreign-key declarations?