Before you start: review of the earlier sessions
The thread so far. Sessions 12–13 showed a foundation model for databases; session 14 asks the general question: how do we get in-context learning on any graph, and how do we trust the predictions?
What this session takes from earlier ones
- Lecture 5: self-supervised pretraining tasks, generalised here into prompt graphs
- Lecture 3: the computation graph: a prompt graph is a data graph plus a task graph on top of it
- Lecture 13: the relational foundation model of Lecture 13 as a database example of in-context learning
Those sessions in one minute each
Lecture 13 · Advanced Architectures in Relational Deep Learning
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.
One natural way to combine RelGT's five element-wise encodings (sum or concatenation + projection).
Lecture 5 · GNN Augmentation and Training
Choose the computation graph deliberately (features, virtual nodes, sampling), pick the head that matches the task level, and split so that information from validation/test can never leak into training through message passing.
Lecture 3 · Graph Neural Networks
A GNN layer = for every node, combine its own vector with an order-free aggregate of its neighbours' vectors, using weights shared across all nodes; stacking K layers lets information travel K hops.
Rows of \(H\) are node embeddings; \(D^{-1}A\) averages over neighbours; \(W_k\) transforms the neighbourhood message; \(B_k\) transforms the node itself.
Warm-up: answer these before you read on
What makes a model a foundation model here? from Lecture 13
It is pretrained once and solves new tasks on new databases from in-context examples, without gradient updates.
What is the difference between a transductive and an inductive split? from Lecture 5
Transductive: one graph, all nodes visible, only labels are split. Inductive: separate graphs (or subgraphs) for training and test, so test nodes are never seen.
What does the self-loop (or the B matrix) do in the GCN layer? from Lecture 3
It keeps the node's own previous vector in the update, so a node does not forget its own features while absorbing its neighbours'.
What is an atomic route? from Lecture 13
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.
More questions from every session you have reached, with spaced repetition: the cumulative review.
In short
LLMs changed ML by doing in-context learning (ICL): show a few examples in the prompt ("thanks → merci, wall → mur, hello → ?") and the model performs the task without any gradient update. This lecture asks how to get the same ability on graphs and databases.
PRODIGY (NeurIPS 2023) solves two problems. (1) Format: represent any few-shot graph task — node, edge or graph classification — as a prompt graph: each example's local subgraph (data graph) plus a task graph that links example "data nodes" to "label nodes". Then classification becomes link prediction between queries and labels. (2) Pretraining: train a hierarchical GNN on self-supervised tasks written in that same format (neighbour matching + multi-task). Result: in-context learning on unseen graphs and tasks, up to 48% better than contrastive pretraining.
The Relational Transformer (RT) generalises Lecture 13's foundation-model goal: tokenise each database cell as (value, column, table) so any schema maps into one input space; cast any task as masked token prediction; restrict attention with relational masks (column, feature, neighbour, full). Pretrained leave-one-database-out, a 22M-parameter RT beats a 27B-parameter LLM by 13% zero-shot AUROC.
The assigned readings also include conformalised GNNs (uncertainty quantification), covered in the readings section.
The picture: a PRODIGY prompt graph
How to read it (hover a step)
- Data graphs: each input \(x\) (a node, an edge, or a whole graph) is contextualised by extracting its local subgraph from the source graph; a GNN encodes each into a data node.
- Task graph: one label node per class. Each prompt example connects bidirectionally to all label nodes (edge features say T/F: is this its label?) — that's how the examples "teach" the task.
- Queries receive single directed edges from each label node (so label information flows to them, not back). Different numbers of classes/shots just mean different numbers of label/data nodes.
- After message passing over the task graph, the prediction is the label node with the highest cosine similarity to the query — classification becomes link prediction in the prompt graph.
1 · Paradigms: training, fine-tuning, in-context learning
- Training: one model per task.
- Fine-tuning: pretrain once, update weights for each new task.
- In-context learning: perform a new task by "learning" from examples in the input context, without gradient updates — predicting sums, unscrambling words, translating, all from one foundation model.
For graphs, an in-context learner should solve novel tasks on novel graphs without gradient updates — e.g. given a few labelled edges (link classification) in an unseen knowledge graph, classify new edges. Two challenges: (1) a unified input format so one model can consume prompts for any graph task; (2) a way to pretrain a model that can solve any task in that format.
2 · PRODIGY's prompt graph
Step 1 — data graph. Contextualise each input in graph \(G\) by subgraph extraction (around the edge's two endpoints for link prediction, around the node for node classification, the graph itself for graph classification). Different input node sets handle different task levels; text features from a pretrained language model (e.g. BERT) unify feature spaces across datasets.
Step 2 — task graph. Interconnect inputs and labels across examples to form context for the queries: prompt examples ↔ all label nodes (bidirectional, with T/F edge attributes), label nodes → queries (single directed edges). Flexible: 2-shot 2-class or 1-shot 3-class prompts just change the node counts.
Inference — in-context prediction GNN. Hierarchical message passing: (1) a data-graph encoder GNN embeds each data graph; (2) an attention GNN passes messages over the task graph; (3) logits = cosine similarity between label and query embeddings.
3 · Pretraining for in-context learning
Generate pretraining tasks in prompt-graph format and optimise the same model on them. Two data-generation streams:
- Neighbour matching (self-supervised): sample a few local neighbourhoods; each neighbourhood is a "class" defined by the nodes in it; the task is to classify which neighbourhood a query node belongs to. No labels needed.
- Multi-task (supervised): select multiple real tasks available in the pretraining graph.
Prompt graphs are then augmented (e.g. feature corruption). Objectives: classification loss over the generated tasks + an attribute-prediction loss reconstructing corrupted features. Mixing pipelines yields more diverse data and better results.
Results
Pretrain on MAG240M (citation) or Wiki (KG); evaluate ICL on arXiv paper categories and KG link prediction (FB15K-237, NELL, ConceptNet). Baselines: no pretraining, contrastive pretraining + nearest-neighbour, contrastive + fine-tuned linear head. PRODIGY improves in all cases — up to 48% over contrastive and 3× over fine-tuning — even when pretrained only with neighbour matching, which knows nothing about paper categories. Pretrained with 3-shot prompts, it keeps improving with many more shots at test time, and scales with more pretraining data.
4 · Relational Transformer: zero-shot over any database
End-to-end RDL models (RDL-GNN, RelGNN, RelGT, RelLLM) are schema- and task-specific, and they tokenise at the row level, which ties the architecture to a schema. RT's promise: zero-shot forecasting on new databases and unseen tasks; few-shot / fine-tuning with limited supervision; democratising AI for structured data.
Three core innovations
- Cell-level tokenisation: each token = (value, column, table). Value through a per-datatype encoder (numerical, text, boolean, time); column and table names through a frozen language model (MiniLMv2) describing "<column> of <table>". Any schema maps into one consistent input space, and cell-to-cell dependencies are explicit.
- Task-table integration: the task (e.g. User-Churn) is a table whose label cell is masked; any node-level task becomes masked token prediction. Earlier task rows provide in-context labels.
- Relational attention: attention restricted by relational masks — column attention (cells in the same column), feature attention (cells of the same row and its linked parent rows), neighbour attention (cells of FK-linked rows), and full attention.
Context sampling (no leakage)
- Sample the seed row and hide the target value.
- Always include parent rows (F→P keys).
- Subsample child rows (P→F keys) by breadth-first search.
- Only sample rows with earlier timestamps.
Setup and results
12 layers, 22M parameters; masked-token pretraining on RelBench, 50K steps on 8×A100; Huber loss for regression, BCE for classification; leave-one-database-out pretraining, tested on the unseen schema. Baselines: Griffin (universal feature encoder + GNN), Gemma-3 LLMs on text-serialised subgraphs, RDL-GNN. RT has 1000× fewer parameters, needs a 100× smaller context and gets 13% better zero-shot AUROC than Gemma3-27B; it is the only neural method to beat the non-neural "entity mean" baseline on zero-shot regression; and it fine-tunes quickly when labels exist.
Limitations: no link prediction / recommendation yet; limited pretraining data; room to improve cell encoders and positional biases.
5 · Reading-only topic: conformal prediction for GNNs
One assigned reading (CF-GNN, Huang et al., NeurIPS 2023) isn't in the slides but completes the "advanced topics" picture: how confident should we be in a GNN's prediction?
Conformal prediction wraps any model to output a prediction set \(C(x)\) with a guarantee: \(P(y\in C(x))\ge1-\alpha\) (e.g. 90%), assuming exchangeability between calibration and test points. Recipe: compute non-conformity scores (e.g. \(1-\hat p_y\)) on a held-out calibration set, take the \(\lceil(n+1)(1-\alpha)\rceil/n\) quantile \(\hat q\), and include every label with score ≤ \(\hat q\).
The graph twist: in transductive node classification, calibration and test nodes are connected — CF-GNN shows exchangeability still holds under permutation-invariant training, then trains a second "topology-aware" GNN to make the sets smaller (more efficient) while keeping coverage, exploiting that neighbouring nodes have correlated uncertainty.
The mathematics, step by step
Two ideas with different mathematics. In-context learning needs one formula: classify by the nearest label vector. The second half is about trusting a prediction, and its central result, conformal prediction, is a counting argument that needs no assumption on the model. Each step of that argument is spelled out below.
Symbols used in this session
| symbol | meaning | what kind of object |
|---|---|---|
| \(\mathbf h_q,\ \mathbf h_{\text{label }c}\) | embeddings of the query node and of the label node for class \(c\) in the prompt graph | vectors |
| \(\cos(\mathbf a,\mathbf b)\) | cosine similarity \(\mathbf a^\top\mathbf b/(\lVert\mathbf a\rVert\lVert\mathbf b\rVert)\) | number in \([-1,1]\) |
| \(k,\ m\) | shots (labelled examples per class) and ways (number of classes) of a few-shot task | whole numbers |
| \(\phi_{\text{dtype}}\) | encoder chosen by the data type of a cell (number, text, date, …) | function |
| \(\alpha\) | allowed error rate; \(1-\alpha\) is the coverage aimed for | number in \((0,1)\), e.g. 0.1 |
| \(n\) | number of calibration examples (labelled, not used for training) | whole number |
| \(s_i\) | conformity score of calibration example \(i\): how badly the model fits the true label, e.g. \(1-\hat p(y_i\mid x_i)\) | real number; small = good fit |
| \(\hat q\) | threshold: the \(\lceil(n+1)(1-\alpha)\rceil\)-th smallest calibration score | real number |
| \(C(x)\) | prediction set: all labels whose score is at most \(\hat q\) | set of labels |
1Classifying by the nearest label node
In words. The prompt graph contains one node per class. After message passing, the query is assigned to the class whose label node has the embedding most similar in direction to the query's.
Why it has this form. PRODIGY links each example's node to the label node of its class and each query's node to all label nodes; a GNN on this small graph lets the label nodes absorb what their examples look like. Predicting the class is then predicting which query–label edge exists: link prediction. No output layer has a fixed number of classes, so the same pretrained network handles a 3-class task and a 40-class task. Cosine is used because only the direction should matter, not the length of the vectors.
Watch out. A \(k\)-shot, \(m\)-way task supplies \(k\cdot m\) examples in total. With \(k=3\), \(m=5\) the model sees 15 labelled examples and nothing else about the task.
2A database cell as a token; masked-cell prediction
In words. Every cell of the database becomes one token: an encoding of its value, chosen by its data type, plus a language-model embedding of the names of its column and table. Training hides some cells and asks the model to fill them in.
Why it has this form. A new database has new tables and columns, so nothing may be tied to a particular schema. A cell is the unit every database shares, and a column's name carries its meaning ('price', 'signup date') in a form a language model already understands. Any predictive task can then be written as one more cell: append a column for the label, mask it for the query row, and predict it. Attention is restricted by the structure: same row, same column, and rows linked by foreign keys. The loss \(\ell\) is cross-entropy for categories and a regression loss for numbers.
Watch out. The number of tokens grows with rows × columns of the sampled context, so the context must be sampled carefully, as in Lecture 13.
3Conformal prediction: the threshold
In words. Compute the score of the true label on \(n\) held-out examples and sort the scores. Take the one at position \(\lceil(n+1)(1-\alpha)\rceil\) as the threshold. For a new input, output every label whose score is no larger than the threshold.
Why it has this form. The score measures how strange a label looks to the model. The calibration scores show how strange true labels typically look. Choosing the threshold near the \((1-\alpha)\) quantile means: accept every label that is no stranger than \(1-\alpha\) of the true labels were. The model's probabilities are never assumed to be correct; a bad model simply produces larger sets.
Watch out. It is \((n+1)\), not \(n\): the test point counts as one more draw. If \(\lceil(n+1)(1-\alpha)\rceil>n\) (too few calibration points for the requested coverage), the set must contain every label.
4Why the guarantee holds, and how much the coverage varies
In words. Averaged over calibration sets, the true label is in the set at least \(1-\alpha\) of the time. For one particular calibration set, the actual coverage is a random number that follows a Beta distribution centred near \(1-\alpha\) and tighter for larger \(n\).
Why it has this form. Assume the calibration examples and the test example are exchangeable (any order is equally likely). Then the rank of the test score among the \(n+1\) scores is equally likely to be \(1,2,\dots,n+1\). The true label is covered exactly when that rank is at most \(\lceil(n+1)(1-\alpha)\rceil\), which has probability \(\lceil(n+1)(1-\alpha)\rceil/(n+1)\ge1-\alpha\). That is the whole proof: counting ranks. The Beta law describes the spread of this coverage from one calibration set to another.
Watch out. Exchangeability is the assumption that fails on graphs: nodes are linked, and a test set from a later time or a different region is not exchangeable with the calibration nodes. The guarantee is also only on average over all nodes, not for each class or each degree group.
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: why is ICL harder on graphs than on text? show answer
Text tasks all share one format, a token sequence. Graph tasks differ in what the input is: a node, a pair of nodes, or a whole graph, and in what the classes are.
from In-context learning over graphs: the goal and two challenges
Check yourself: in PRODIGY, where does the "knowledge of the task" live at test time? show answer
In the T/F edges of the task graph and the embeddings of the label nodes, not in any weights.
from Scaling with shots and data; PRODIGY conclusion
Check yourself: which Lecture 13 idea does rule 4 repeat? show answer
Temporal neighbour sampling in RDL, where only events before the prediction time are used.
from Context sampling
Check yourself: why is EntityMean a strong baseline? show answer
Many forecasting targets are very persistent: a user's past churn or a product's past sales predicts the next value well.
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.
- Today's plan and three ML paradigms
- In-context learning over graphs: the goal and two challenges
- Prompt Graph step 1: data graphs
- Prompt Graph step 2: the task graph
- Prompt Graph inference: the in-context prediction GNN
- PRODIGY pretraining: generating tasks
- Experiments and in-context learning results
- Scaling with shots and data; PRODIGY conclusion
- Recap: relational deep learning and its limits
- The goal: a relational foundation model; RT overview
- Cell-level tokenization and task-table integration
- Context sampling
- Relational attention
- Experimental setup and pretraining
- RT results, discussion and limitations
Today's plan and three ML paradigms slides 3,5-10 ↗
Slide 3 names the two papers of this lecture. PRODIGY: Enabling In-context Learning Over Graphs (Huang, Ren, Chen, Krvzmanc, Zeng, Liang, Leskovec; NeurIPS 2023) and the Relational Transformer (Ranjan, Hudovernik, Znidar, Kanatsoulis): "Toward Zero-Shot Foundation Models for Relational Data". Both ask the same question: can one pretrained model solve a new task on new data without being retrained?
Slides 5–7 build one figure that compares three ways to do machine learning. Each column is a network (a trapezoid) with an input at the bottom and an output at the top.
- Training (slide 5): three separate networks for three tasks. The same input "hello" gives "5" (count letters), "h" (first letter) or "bonjour" (translate), each from its own model.
- Fine-tuning (slide 6): one big shared network (blue) at the bottom, with a small task-specific head on top for each task. You pretrain once, then update weights for each task.
- In-context learning (slide 7): one big network with no task heads. The input itself carries the task: "Thanks → merci, Wall → mur, hello → ?". The model answers "bonjour". This is few-shot prompting.
Slide 8 defines in-context learning (ICL): performing a new task by "learning" from the input context, without any gradient update. The slide calls it very powerful, because now one foundation model can directly answer all tasks. The three small panels show GPT-style prompts for predicting a sum ("3 + 8 = 11, …"), unscrambling words and translating; in each, a few examples come first and the model completes the last line.
Slide 9 asks the lecture's question: what is in-context learning over graphs? Slide 10 gives the plan. PRODIGY is an in-context learner for graphs that solves novel tasks on novel graphs. It has three parts:
- Prompt Graph representation: put the few-shot prompt for any graph task into one input format that a single shared model can read.
- Prompt Graph inference: an "in-context prediction GNN" that reads this format.
- Pretraining: generate many diverse pretraining tasks in the Prompt Graph format (Neighbor Matching and MultiTask).
In-context learning over graphs: the goal and two challenges slides 12,14-16 ↗
Slide 12 recalls the three classic graph learning tasks: node classification, link prediction and graph classification. The pictures are a social network, a knowledge graph and a set of small molecules.
Slide 14 shows what ICL means on a graph, using link classification. On the left is text prompting again (different tasks, same model). On the right:
- A graph \(\mathcal{G}\) (a new graph the model has never seen). Some nodes are drawn as coloured circles (head input nodes) and coloured triangles (tail input nodes).
- Prompt examples \(\mathcal{S}\): four pairs (circle, triangle) as input \(x\), each with a label \(y\) drawn as an orange or blue diamond (for example, the relation type of the edge).
- Queries \(\mathcal{Q}\): a new pair (blue circle, blue triangle) whose label is "orange or blue?".
The yellow box states the requirement: an in-context learner for graphs should solve novel tasks on novel graphs without gradient updates. "Different graphs" and "different tasks" are both marked in red: both can change between pretraining and use.
Slides 15–16 state the two challenges and their answers:
- Format. How do we represent the few-shot prompt for different graph tasks in the same input format, so one shared model can consume it? Answer: the Prompt Graph, which represents each few-shot prompt as a meta hierarchical graph.
- Pretraining. How do we pretrain a model that can solve any task in this format? Answer: PG pretraining: pretrain a message-passing model on self-supervised tasks written in the Prompt Graph format, over diverse underlying graphs.
Check yourself: why is ICL harder on graphs than on text? show answer
Text tasks all share one format, a token sequence. Graph tasks differ in what the input is: a node, a pair of nodes, or a whole graph, and in what the classes are.
Prompt Graph step 1: data graphs slides 18-23 ↗
Slide 18 shows the full Prompt Graph, "a unified representation of few-shot prompts over graphs for diverse tasks". It has two layers:
- Bottom (orange band), data graphs \(\mathcal{G}^d\): one small circled subgraph per prompt example (four of them, the prompt examples \(\mathcal{S}\)) and one per query (\(\mathcal{Q}\)).
- Top (blue band), the task graph: one square data node \(v_x\) above each data graph, and two diamond label nodes \(v_y\). Edges between them are marked T (green) or F (red), and edges to the query are marked "?".
Slides 19–22 explain step 1, the data graph: it contextualizes each input \(x\) in the graph \(\mathcal{G}\), for example by subgraph extraction. A single node or edge means little on its own; its neighbourhood carries the information.
- Link prediction (slides 19–20): for each input pair (head, tail), extract the subgraph around both endpoints. The figure shows each prompt example and query of slide 14 turned into one circled subgraph containing its circle and triangle.
- Node classification (slide 21): the input is a single node; extract the subgraph around it.
- Graph classification (slide 22): the input is already a small graph, so the data graph is that graph itself.
Slide 23 sums up how the data graph unifies the input format:
- Use a different input node set for classification at different levels: one node for node classification, two nodes for edge classification, all nodes for graph classification. The rest of the pipeline stays the same.
- Use text features to unify node features across datasets (each node's text is embedded by a language model, so all graphs share one feature space).
Prompt Graph step 2: the task graph slides 24-35 ↗
Slide 24 introduces step 2, the task graph: it interconnects inputs and labels across examples to form context for the queries. Slides 25–31 build it for link prediction, one piece at a time:
- Slide 26: put one data node \(v_x\) above each data graph (it will hold the embedding of that subgraph), and one label node \(v_y\) for each class (two diamonds here).
- Slides 27–28, prompt examples: add bidirectional edges between each example's data node and all label nodes. The edge to the true label carries the feature T; the edges to the other labels carry F. So each example tells the label nodes "I am an instance of you" or "I am not".
- Slides 29–30, queries: add single directed edges from each label node to each query data node (the "?" edges). Information flows from labels to the query, but the query cannot change the label nodes.
Slide 31 shows the finished task graph above the data graphs. Slides 32 and 33 show that the same construction works for node classification (input = single node) and graph classification (input = small graph): only the data graphs change.
Slide 34, flexibility of the task graph. It unifies the classification format:
- A different number of classes just means a different number of label nodes.
- A different number of prompt examples (shots) and queries just means a different number of data nodes and different connections to the label nodes.
The two small pictures are a 2-shot prompt for 2-class classification and a 1-shot prompt for 3-class classification.
Slide 35 explains why this works. On the left, ICL over a graph (graph, prompt examples, query). On the right, the Prompt Graph. The task graph reflects what the task is through the examples (their commonalities and differences), and the data graphs capture all relevant information about each input. The key reframing: ICL over a graph becomes inductive link prediction over a hierarchical graph: predict which label node the query's data node should link to.
Prompt Graph inference: the in-context prediction GNN slides 37-41 ↗
Slide 37 shows the inference picture: the whole Prompt Graph goes into a model, which outputs scores for the queries. Slides 38–41 open the model. It does hierarchical message passing over the Prompt Graph, in three stages:
- Data graph encoder (slide 39). A GNN (the same weights for all, drawn as five blue "GNN" boxes) runs on each data graph and pools the embeddings of the input nodes into the embedding of the data node \(v_x\). This turns "a subgraph around an input" into one vector.
- Message passing over the task graph (slide 40). A second GNN, a GNN with attention, runs on the task graph. Label nodes collect messages from the example data nodes (with T/F edge features), so each label node becomes a summary of "what my examples look like". Query data nodes receive messages from the label nodes.
- Compute logits (slide 41). For each query and each label, \[ \text{logit} = \text{cosine\_similarity}(h_{\text{label}},\, h_{\text{data}}). \] The predicted class is the label node with the highest score.
Intuition: the label node embeddings play the role of class prototypes, but they are not fixed. They are built at inference time from the examples in the prompt, so a new set of classes needs no new weights. Check yourself: if you give a 5-way prompt to a model pretrained only on 3-way prompts, what changes in the computation? (Only the number of label nodes; the GNN weights are reused.)
PRODIGY pretraining: generating tasks slides 43-50 ↗
Slide 43: to pretrain, we generate pretraining tasks in the Prompt Graph format and pretrain the model over them. The pipeline is: pretraining data/graph → data generation → Prompt Graph → model → optimize loss. Slide 44 points at the "data gen" step.
Slides 45–47 split data generation into two stages:
- Few-shot prompt generation from the pretraining graph, by one of two routes:
- MultiTask (slide 46): simply select several labelled tasks that exist on the pretraining graph and sample few-shot prompts from them. This is supervised pretraining.
- Neighbor Matching (slide 47): a self-supervised task that needs no labels.
- Convert to Prompt Graph, with augmentation (for example, dropping nodes or corrupting features in the data graphs).
Slide 48, Neighbor Matching. Idea: classify which neighbourhood a node is in, where each neighbourhood is defined by other nodes in it. The figure shows one large graph with four sampled local neighbourhoods \(\mathcal{G}^d_1, \dots, \mathcal{G}^d_4\) (dotted circles, each around a coloured centre node). Each neighbourhood becomes a class. Prompt examples: four coloured centre nodes, each labelled with its neighbourhood's diamond (two orange, two blue). Queries: two yellow nodes; the "?" arrows ask whether a yellow node lies in the orange or the blue neighbourhood (the dashed circles show 2-hop neighbourhoods). The labels come for free from the graph structure, so we can make unlimited tasks of any number of ways.
Slide 49: mixing different data generation pipelines (Neighbor Matching + MultiTask) gives more diverse pretraining data and better results.
Slide 50, the pretraining objectives:
- a classification loss over the generated tasks (pick the right label node for each query);
- an attribute prediction loss: reconstruct the features that were corrupted during data-graph augmentation.
Why this works: the model never sees the downstream task, but it practises the skill of reading a prompt and matching a query to the examples. That skill is what transfers.
Experiments and in-context learning results slides 51-57 ↗
Slide 51, evaluation and datasets. Two pretraining graphs: MAG240M, a large-scale citation network, and Wiki, a knowledge graph built from Wikipedia (Xiong et al., 2018b). After pretraining, in-context performance is measured on different downstream graphs: paper category prediction on arXiv, and KG link prediction on FB15K-237, NELL and ConceptNet.
Slide 52, baselines:
- NoPretrain: same architecture, random initialization.
- Contrastive: standard contrastive pretraining with the same augmentation, then a hard-coded nearest-neighbour rule to fit the in-context setting.
- Finetune: a linear classification head trained on top of the contrastively pretrained encoder (so it does use gradient updates).
And three variants of PRODIGY: PG-NM (Neighbor Matching only), PG-MT (MultiTask only), and PG-ALL (both; shown as "PRODIGY" in the table).
Slide 53: graphs have different features. PRODIGY handles this with text embeddings from a pretrained language model (for example BERT).
Slides 54–57 show one table: pretrain on MAG, then in-context classification of arXiv paper categories. Accuracy (%) by number of classes (ways):
| Classes | NoPretrain | Contrastive | PG-NM | PG-MT | PRODIGY | Finetune |
|---|---|---|---|---|---|---|
| 3 | 33.16 | 65.08 | 72.50 | 65.64 | 73.09 | 65.42 |
| 5 | 18.33 | 51.63 | 61.21 | 51.97 | 61.52 | 53.49 |
| 10 | 9.19 | 36.78 | 46.12 | 37.23 | 46.74 | 30.22 |
| 20 | 4.72 | 25.18 | 33.71 | 25.91 | 34.41 | 17.68 |
| 40 | 2.62 | 17.02 | 23.69 | 17.19 | 25.13 | 8.04 |
- Result 1 (slide 55): PRODIGY improves performance in all cases, up to 48% over Contrastive and 3× over Finetune (40 ways: 25.13 vs 17.02 and 8.04). Notice that NoPretrain is at chance level (about 100/ways).
- Result 2 (slide 56): PG-NM alone is already strong. Its pretraining had no idea about classifying paper categories, yet it induces strong in-context learning: very different self-supervised tasks are enough.
- Result 3 (slide 57): mixing pipelines (PRODIGY = PG-ALL) gives the best numbers.
Why does Finetune lose so badly with many classes? With 40 classes and only a few shots per class, a newly trained linear head overfits; PRODIGY builds class prototypes from the prompt and needs no training.
Scaling with shots and data; PRODIGY conclusion slides 58-60 ↗
Slide 58, scaling with more shots. The plot is ConceptNet, 4-way, accuracy against the number of shots (1 to 20). PG-ALL (orange) rises from about 0.43 to about 0.63; Contrastive (blue) rises from about 0.38 to about 0.51 and flattens early. The message: the model was pretrained with only 3 shots, but it can learn from much more than 3 shots in the context. It generalizes to longer prompts than it saw.
Slide 59, data scaling. Accuracy against the number of training steps (log scale, \(10^3\) to about \(2\times10^4\)). PG-ALL climbs steadily from about 0.455 to about 0.60; Contrastive is noisy and stays around 0.50–0.53. The message: hard and diverse pretraining-task generation lets the model keep scaling with more training data.
Slide 60, conclusion. PRODIGY enables in-context learning over graphs with a new task representation, the Prompt Graph, plus a matching pretraining architecture and objectives:
- The Prompt Graph is a unified representation of few-shot prompts over graphs for diverse tasks.
- Pretraining a hierarchical message-passing model over Prompt Graphs enables in-context learning on unseen tasks on unseen graphs.
- Hard and diverse pretraining tasks let the model keep improving with more training data.
Check yourself: in PRODIGY, where does the "knowledge of the task" live at test time? show answer
In the T/F edges of the task graph and the embeddings of the label nodes, not in any weights.
Recap: relational deep learning and its limits slides 62-66 ↗
The second part (by Charilaos Kanatsoulis) is about transformers for relational data, towards foundation models for forecasting over relational databases. It builds on Lecture 13.
Slide 62 recalls Relational Deep Learning (RDL; Fey et al. 2023) as a four-step pipeline: relational DB → graph problem → graph ML → solutions.
Slide 63, the key insight: a relational database is an entity-level graph. Every entity (row) is a node, and edges are defined by foreign-key–primary-key links. The figure turns three tables (Users, Sales, Products) into a graph: user icons on the left, sales amounts in the middle, product icons on the right, with coloured bands showing which user bought which product.
Slide 64: predictive tasks become graph ML problems.
- Node-level: churn, lifetime value.
- Link-level: product affinity, recommendation.
- Graph-level: fraud detection.
Slide 65 lists RDL architectures: RDL-GNN (Robinson et al. 2024), RelGNN (Cheng, Kanatsoulis, Leskovec 2025), the Relational Graph Transformer RelGT (Dwivedi et al. 2025) and RelLLM (Wu et al. 2025).
Slide 66, the disadvantages of end-to-end RDL. The figure adds churn labels ("Churn"/"Active" per month) to the users. Two problems:
- Schema- and task-specific: the model is built and trained for one database and one task.
- Limited transfer: it cannot generalize to new databases or new tasks.
The goal: a relational foundation model; RT overview slides 67-69 ↗
Slide 67, the goal: bring the success of foundation models (LLMs, ViT) to relational data. The pictures are an LLM and the Vision Transformer, which splits an image into patches and feeds them as tokens to a transformer encoder.
Slide 68, the promise of a relational foundation model:
- Zero-shot forecasting on new databases and unseen tasks.
- Few-shot / fine-tuning with limited supervision.
- Broader impact: democratize AI for structured data. Non-experts get accessible predictive tools; experts get a strong pretrained initialization.
Slide 69, the Relational Transformer (RT). Key idea: treat each database cell as a token and model the relationships between cells with Relational Attention. Three core innovations: (1) cell-level tokenization, (2) task-table integration, (3) relational attention. The slide's figure has three panels:
- (a) Schema: tables User (UserID (P), Gender), Sale (Time, UserID (F), ItemID (F), Stars), Item (ItemID (P), Price, Details), plus a Task table (Time, ItemID (F), Label) for the task "predict total sales over next week". (P) = primary key, (F) = foreign key.
- (b) Context window: a set of cells taken from these tables. Task rows from the past provide in-context labels; the target row has its label cell masked ("?").
- (c) Architecture: for all cells, a per-datatype encoder (num | text | bool | time) plus a frozen language-model embedding of "<column> of <table>"; then \(N\) Relational Transformer blocks, each with Column, Feature and Neighbor attention, then Full attention, then an MLP; then a per-datatype decoder that outputs the predicted cell value.
Cell-level tokenization and task-table integration slides 70-73 ↗
Slide 70 shows the running example: three linked tables, Transactions, Products and Users; lines show foreign-key links from transaction rows to product rows and user rows.
Slide 71: prior work (RDL-GNN, RelGNN, RelGT, RelLLM) tokenizes at the row level: one row = one node/token, with a table-specific encoder for its columns. This leads to schema-specific architectures: a new database with different columns needs new encoders.
Slide 72, RT's cell-level tokenization. Each token is a triple \[ \text{token} = (\text{value},\ \text{column},\ \text{table}). \] The table and column are given as text descriptions embedded with MiniLMv2 (a small language model). Benefits:
- It unifies relational databases of any schema into one consistent input space: every database is just a set of (value, column-name, table-name) tokens.
- It leverages cell-to-cell dependencies: attention can relate single cells, not only whole rows.
Slide 73, task label integration. The task itself becomes a table, here User-Churn with columns Fkey (the user), Val (the label) and Time. Its rows link to Users like any other table. Benefits:
- Any node-level task becomes masked token prediction (MTP): hide the Val cell of the target row and predict it.
- It adds autoregressive labels as task tokens: past rows of the task table, with their labels visible, sit in the context as in-context examples.
Compare with PRODIGY: there, labels were label nodes in a task graph; here, labels are ordinary cells in a task table. Both put the examples into the input instead of into the weights.
Context sampling slides 74-80 ↗
A database is too big for one transformer context, so RT samples a context window around each prediction. Slide 74 lists the sampling rules:
- Sample a seed node (a row of the task table) and hide its value.
- Always include parent nodes (follow F → P keys: from a foreign key to the row it points to).
- Subsample child rows (follow P → F keys: rows that point to this row). Slide 74 calls this a breadth-first search over children.
- Only sample from previous timestamps.
Slides 75–80 animate this on the example:
- Slide 75: the seed is a User-Churn row; its Val cell is hidden (the smiley).
- Slide 76: its Fkey is user 1, so the parent row of user 1 in Users is included.
- Slide 77: from user 1, child rows in Transactions (Fkey = 1) are sampled; one has product Fkey 100.
- Slide 78: that transaction's parent, product 100, is included.
- Slide 79: a second transaction of user 1 (product 98) and its parent product 98 are added.
- Slide 80: another User-Churn row of user 1 with time \(t_1 \lt t_0\) is included; its label is visible, so it acts as an in-context example. Rows after \(t_0\) are never sampled.
Why rule 2 is "always" and rule 3 is "subsample": a row has few parents (one per foreign key) but may have thousands of children (a user's transactions). Rule 4 avoids temporal leakage: the model must not see information from the future of the moment it predicts.
Check yourself: which Lecture 13 idea does rule 4 repeat? show answer
Temporal neighbour sampling in RDL, where only events before the prediction time are used.
Relational attention slides 81-85 ↗
Plain full attention over a set of cell tokens would ignore the structure of the database. RT therefore uses four attention types in each block (slide 81 shows the sampled context with all included cells outlined). The slides highlight, for one query cell (the face emoji), which cells it may attend to:
- Column attention (slide 82): a cell attends to the cells in the same column of the same table. The query is the hidden Val cell of the target User-Churn row; it sees the Val cells of the other User-Churn rows, that is, the in-context labels. This is how RT learns "what values this column usually takes".
- Feature attention (slide 83): a cell attends to the other cells of its own row and of its parent rows (F → P). The target User-Churn row sees its own cells and the whole Users row of user 1. This mixes the features of an entity.
- Neighbor attention (slide 84): a cell attends to the cells of its child rows (rows that point to it through a foreign key). A cell of the Users row sees the user's Transactions rows and User-Churn rows. This is the message-passing step of a GNN, written as masked attention.
- Full attention (slide 85): every cell attends to all cells in the context, with no mask.
Intuition: column, feature and neighbor attention are relational masks. They put the schema's structure (columns, rows, keys) into the attention pattern as an inductive bias, while full attention keeps the flexibility of a transformer. Since the masks depend only on "same column", "same row" and "key links", they work for any schema.
Experimental setup and pretraining slides 86-89 ↗
Slide 86: RelBench, 7 diverse datasets in four areas: e-commerce (rel-amazon, rel-avito, rel-hm), social (rel-event, rel-stack), sports (rel-f1) and medical (rel-trial).
Slides 87–88, the setup:
- Tasks: binary classification and regression.
- Pretraining: leave-one-database-out. Pretrain on the other databases, then test on the unseen schema. This is a true zero-shot test: the model has never seen these tables or columns.
- Baselines: Griffin (Wang et al. 2025), a universal feature encoder followed by a GNN; Gemma LLMs, prompting Gemma3 with a text-serialized database subgraph; RDL-GNN (Robinson et al. 2024), the schema-specific GNN.
Slide 89, RT pretraining:
- Backbone: 12 layers, 22M parameters.
- Pretraining task: masked token prediction on RelBench.
- Training: 50k steps on 8×A100 GPUs.
- A linear decoder.
- Objective: Huber loss for regression, binary cross-entropy (BCE) for classification.
The Huber loss is quadratic for small errors and linear for large ones, so a few extreme target values (common in sales or counts) do not dominate training.
RT results, discussion and limitations slides 91-96 ↗
Slide 91, fine-tuning tests: test-set learning curves up to 32k fine-tuning steps (batch size 256), x-axis on a log scale.
- Left, binary classification (mean of 5 tasks, AUROC %): pretrained RT starts at 70.8 zero-shot, pretrained Griffin at 68.5. Untrained models (RT, RDL-GNN, Griffin) start near 55 or lower. Pretrained RT stays on top and reaches about 80.
- Right, regression (mean of 4 tasks, \(R^2\) %): pretrained RT starts at 29.0 zero-shot, pretrained Griffin at 17.7. Untrained models start below zero and need about \(10^3\) steps to catch up.
Slide 92, zero-shot classification (AUROC, 10 tasks). Mean AUROC: Gemma 4B 63.3, Gemma 12B 62.4, Gemma 27B 64.6, EntityMean (0 parameters) 66.7, Griffin 64.0, RT 70.1 when the target database is not in pretraining. When it is (but the task label is still unseen), Griffin 67.3 and RT 72.9. Note that bigger Gemma models are not reliably better.
Slide 93, zero-shot regression (\(R^2\) %, 8 tasks; the global-mean baseline scores 0.0). Mean \(R^2\): EntityMean 19.3, Griffin 8.9, RT 22.8 (unseen database); Griffin 10.1, RT 26.4 (seen database). RT is the only neural method to beat EntityMean, the non-neural baseline that predicts an entity's own historical average. LLM baselines are poor here.
Slide 94: RT has 1000× fewer parameters and needs a 100× smaller context, yet gives 13% better zero-shot AUROC than Gemma3-27B.
Slide 95, discussion: RT is capable of robust zero-shot transfer in relational settings and allows rapid fine-tuning when supervision exists; there is strong evidence that relational databases, despite diverse applications, share transferable patterns; it is a step toward foundation models for structured enterprise data.
Slide 96, limitations: no link prediction or recommendation tasks yet; trained on limited data; possible improvements in cell encoders and positional biases.
Check yourself: why is EntityMean a strong baseline? show answer
Many forecasting targets are very persistent: a user's past churn or a product's past sales predicts the next value well.
Not shown (no new content): slides 1,2,4,11,13,17,36,42,61,90 — title slides, announcements, section dividers, and slide 13 (exact duplicate of slide 9).
Review: what to keep from this session
Carried forward. Lecture 15 builds the knowledge-graph foundation model with the same "represent the task as a graph" trick; Lecture 21 continues the trust theme with explainability.
Quick self-check
How does PRODIGY turn classification into link prediction?
Label nodes are added to the task graph; a query node is classified by predicting which label node it should be linked to.
Why pretrain in the prompt-graph format rather than with ordinary supervised tasks?
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 does conformal prediction guarantee?
That the prediction set contains the true label with probability at least 1 − α, under exchangeability of calibration and test data.
Key idea
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.
Worked example: one in-context prediction
A 3-way, 2-shot prompt on a new KG: relations "bornIn", "worksAt", "marriedTo"; 2 labelled edges each; one query edge (Ali, ?, Tehran).
- Build 7 data graphs (6 examples + 1 query) by extracting the 1–2-hop subgraph around each edge's endpoints; encode → 7 data nodes.
- Task graph: 3 label nodes; each example ↔ all 3 labels (edge attribute T only for its own label); labels → query.
- After message passing, label embeddings absorb their examples; cosines with the query: bornIn 0.81, worksAt 0.42, marriedTo 0.05 → predict bornIn.
- No weights changed. A new task = a new prompt graph.
Strictly speaking: PRODIGY's ICL covers classification tasks expressible as "which label?"; regression and generation need other formats. RT handles regression via masked numeric cells but not yet link prediction.
Proof workshop: Why split conformal prediction covers
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. Let \(s_1,\dots,s_n,s_{n+1}\) be exchangeable non-conformity scores (calibration plus test, ties have probability 0). Let \(\hat q\) be the \(\lceil(n+1)(1-\alpha)\rceil\)-th smallest of \(s_1,\dots,s_n\). Prove \(\Pr(s_{n+1}\le\hat q)\ge1-\alpha\), and show the upper bound \(\Pr(s_{n+1}\le\hat q)<1-\alpha+\frac1{n+1}\).
Hint 1
Hint 2
Solution
Why it matters. The guarantee needs only exchangeability, not a good model; a good model only makes the sets small (the notebook: 1.5 labels with a GCN against 3.6 with an MLP, at the same 90%). On graphs the hypothesis is the whole question: transductive node classification with random splits is exchangeable, while temporal or community-based splits are not. That is when you need the graph-aware variants.
Sharper lens: what the guarantees are averages over
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.
The coverage you actually get is random: a Beta distribution
The theorem in the proof workshop averages over the draw of the calibration set. Fix one calibration set of size \(n\) and the coverage on future points is a random number with distribution
\[ \mathrm{Beta}(n+1-l,\ l),\qquad l=\lfloor(n+1)\alpha\rfloor \]
(Vovk 2012). For \(\alpha=0.1\): with \(n=100\) calibration nodes its standard deviation is 0.030, so "90%" is anywhere from about 84% to 95%; with \(n=1000\) it is 0.0095. This is the first thing to compute when choosing how many labelled nodes to hold out, and the reason a plot of empirical coverage that sits at 88% on one split is not a bug.
Marginal, not conditional: 90% overall can be 60% for one community
The guarantee is \(\Pr(y\in C(x))\ge1-\alpha\) over a random test node. It allows 99% coverage on the easy majority and far less on a minority class, a peripheral community or low-degree nodes. It cannot be strengthened for free: distribution-free coverage conditional on \(x\) is impossible with finite sets (Vovk 2012; Barber, Candès, Ramdas and Tibshirani 2021). Three useful repairs:
- Group-conditional ("Mondrian") calibration: a separate quantile per class, community or degree bucket. Exact within each group, at the price of fewer calibration points per group (see the Beta distribution above).
- Weighted conformal prediction under covariate shift: reweight calibration scores by the likelihood ratio between test and calibration distributions (Tibshirani et al., NeurIPS 2019).
- A bound when exchangeability fails: with weights \(w_i\), coverage is at least \(1-\alpha-\sum_i\tilde w_i\,d_{\mathrm{TV}}(Z,Z^{i})\), where \(Z^i\) swaps calibration point \(i\) with the test point (Barber et al. 2023). Temporal and community splits on a graph are this case; the repository's
conformal-shiftexperiment measures the gap.
Why "prior-fitted" models work: in-context learning as Bayesian prediction
Train a transformer on many small datasets sampled from a prior over tasks, to predict a held-out label from the rest of the dataset in its context. The expected log-loss is minimised by exactly one function: the posterior predictive distribution \(p(y\mid x,D)\) under that prior (Müller et al., ICLR 2022). The network is then an amortised Bayesian reasoner, and a forward pass does the work of inference.
This gives the lecture one frame. PRODIGY's prior is the empirical distribution of tasks that neighbour matching produces on MAG240M or Wikidata. GraphPFN's and TabPFN's priors are synthetic generators. The Frontier section's finding, that only prior-fitted models beat a tuned GNN, then reads: the quality of an in-context learner is the fit between its prior and your data, and the prior is something you can inspect and criticise. PRODIGY's last step, classifying a query by cosine similarity to label nodes, is a prototypical network (Snell et al. 2017) in graph form.
Lab: hands-on and practical tips
Try it live. In the Graph Explorer: check a GCN's calibration and build conformal prediction sets on Cora, then calibrate on the high-degree nodes only and watch the coverage of the others. Each lesson has predict-then-check questions.
notebook · L14 advanced topics builds a PRODIGY-style in-context prompt graph, implements Relational Transformer attention masks on cell tokens, and runs conformal prediction on a GNN.
Readings & lookup guide
lecture notes CS224W course notes (Leni Aniva, Autumn 2024 — in your course folder)
- Ch. 14 — Advanced topics (PRODIGY, conformal GNNs, robustness) (pp. 75–81)
- Ch. 19 — Label propagation (pp. 105–108)
- Ch. 20 — Scaling up GNNs (pp. 109–113)
- Ch. 21 — Trustworthy graph AI (pp. 114–120)
read first Huang et al. — PRODIGY: Enabling In-context Learning Over Graphs (NeurIPS 2023)
- Read: §3 (prompt graph: data graph + task graph; Fig. 2), §4 (pretraining: neighbour matching, multi-task, augmentation; loss), §5.2 results tables.
- Think: why does making the task graph's examples→labels edges bidirectional but labels→queries one-way matter?
core Ranjan, Hudovernik, Znidar, Kanatsoulis, et al. — Relational Transformer: Toward Zero-Shot Foundation Models for Relational Data (2025)
- Read: the architecture figure (cell tokenisation, task table, relational attention), the context-sampling rules, and the zero-shot tables vs Gemma/Griffin.
- Compare: with RelGT (Lecture 13): row tokens vs cell tokens — what does each make easier?
uncertainty Huang, Jin, Candès, Leskovec — Uncertainty Quantification over Graph with Conformalized Graph Neural Networks (NeurIPS 2023)
- Read: §3 (exchangeability in transductive graph settings — the key theorem), §4 (topology-aware correction to shrink prediction sets), coverage/efficiency plots.
Homework & deadlines
Colab 5 out Thu 11/12 · due Thu 12/3
The last Colab; open it from the course website and save it into the course folder.
Homework 3 due Thu 11/12 · Exam Wed 11/18, 6–8 pm
A practice exam with solutions is posted on Ed. Exam coverage: Lectures 1–16, focus 1–13.
Self-check
In-context learning means …
- fine-tuning on the prompt
- solving a new task from examples in the input, without gradient updates
- training from scratch
- retrieval augmentation
The model's weights don't change.
In PRODIGY's task graph, classification is turned into …
- regression
- graph generation
- link prediction between query data nodes and label nodes
- clustering
Logit = cosine similarity between label and query embeddings.
Neighbour matching pretraining needs …
- no labels — classes are sampled neighbourhoods
- paper categories
- KG relations
- human annotation
It's self-supervised.
RT's token is …
- a row
- a table
- a node embedding
- a cell: (value, column, table)
Cell-level tokenisation makes any schema fit one input space.
Conformal prediction guarantees …
- the most likely label is correct
- the prediction set contains the true label with probability ≥ 1 − α (under exchangeability)
- calibrated probabilities for each class
- the smallest possible sets
Coverage, not accuracy; CF-GNN then improves set size.
Flashcards (click to flip)
History & the bigger picture
- 2020 — GPT-3 ("Language models are few-shot learners") makes ICL famous.
- 2022–2023 — graph prompting: GPPT, All-in-One, PRODIGY; 2023 — CF-GNN brings conformal guarantees to graphs.
- 2024–2025 — graph and relational foundation models: ULTRA (KGs, Lecture 15), Griffin, KumoRFM, Relational Transformer.
- 1990s–2005 — conformal prediction (Vovk, Gammerman, Shafer) — an old statistical idea that became central once ML systems needed honest uncertainty.
ICL blurs the line between a learner and an inference engine: the "learning" happens in activations, not parameters. Philosophers of mind would recognise the debate between knowledge as stored representation and knowledge as a capacity to reason from given evidence. For structured enterprise data, the social question is concentration: a single pretrained relational model serving every company's database is enormous leverage — and an enormous dependency.
Classic SNA bridge
| In this lecture | Classic SNA counterpart | What carried over, what changed |
|---|---|---|
| In-context learning from a few labelled examples | Seed-based coding and snowball labelling in qualitative network studies; semi-supervised label spreading | Analysts have always labelled a few accounts by hand and extended by structure (label propagation, Lecture 20). PRODIGY makes the "extension rule" a learned model instead of neighbourhood averaging. |
| Prompt graph: data nodes, task nodes, label nodes | Two-mode network of actors × categories; the "affiliation to a label" trick of correspondence analysis | Treating a label as a node in the same graph as the data is Breiger's duality once more: people and categories in one structure. |
| Conformal prediction sets | Confidence intervals for network statistics by bootstrap or permutation (Snijders & Borgatti 1999) | SNA had resampling intervals for whole-network statistics; conformal sets are per-node intervals for predictions. Both break when the sampling design is not what the method assumes. |
| Exchangeability assumption | Random sampling of nodes vs snowball / time-ordered sampling | A community-based or time-based split (how you would evaluate on X data) is not exchangeable. The social sampling design decides whether the guarantee holds. |
| Relational Transformer: schema tokens | Codebooks and variable dictionaries in comparative survey research | Putting the column name next to the value is what a codebook does for a survey analyst. Transfer across schemas is transfer across codebooks. |
Report conformal sets for a claim like "between 4% and 9% of accounts in this hashtag are coordinated". Then redo the calibration under a time split and a community split and show how coverage degrades. Computational social science reviewers expect honest uncertainty; a paper that quantifies how the sampling design breaks the guarantee is more useful than one that reports the guarantee.
Go deeper in the SNA course. The twelve-unit course on social network analysis in this repository gives the classic side of this lecture in full, with labs and real-data analyses: Unit 10 · Causality, interference & graph ML (calibration and conformal prediction: what a model's confidence is worth after a shift); Unit 11 · Polarization, algorithms & misinformation (conformal prediction: honest uncertainty for a detector).
Connecting to your research
Running project. Section L14 · conformal sets of notebooks/project/retweet_thread.py applies this lecture to one synthetic X world with coordinated rings, the same graph across the whole course.
Research extension. experiments/conformal-shift (hypotheses written before running): when rings change tactics or are caught early, marginal coverage still reads 0.94–0.96 while coverage of bots drops to 0.13–0.23; recalibrating on 20 labelled bots restores it with honest, uninformative sets.
- Few-shot social labelling: annotating bots, propaganda accounts or stances is expensive. A PRODIGY-style prompt graph lets you classify accounts on a new platform/dataset from a handful of labelled examples — a natural Iranian-Twitter use case with scarce labels.
- Prompt graphs are symbolic structures: examples, labels and queries are explicit nodes with typed edges — the "program" is a graph. That's a promising neuro-symbolic interface.
- Uncertainty for social science: conformal sets give honest uncertainty for downstream claims ("between 4% and 9% of accounts are coordinated") — the kind of rigour reviewers in computational social science expect.
From the experiments: results and datasets
Generated by scripts/sync_guides.py from the experiments' committed results and the dataset catalogue; rerun it (make sync-guides) after an experiment changes.
conformal-shift
Question. Do conformal guarantees hold when bots change tactics, or when a platform changes country? experiment folder ↗
Verdicts (hypotheses written before running): H1 supported, H2 supported, H3 supported, H4 supported; H8 supported, H9 supported, H10 refuted, H11 supported.
gl.datasets.twitch): calibrated on England, tested on other countries. Worst class under Mondrian: DE 0.87, ES 0.89, FR 0.79, PTBR 0.91, RU 0.91. 200 labelled local accounts restore it.Datasets for this session
From the repo's catalogue (gl.datasets; the full list with sources and licences is in data/README.md). Load one with gl.datasets.graph(name), temporal(name) or node_data(name).
| name | dataset | nodes | ground truth | good for |
|---|---|---|---|---|
twitch-en | Twitch users, England (mature content) | 7,126 | streams mature content (2) | a heterophilous social task; also DE, ES, FR, PTBR, RU for shift |
elliptic | Elliptic Bitcoin transactions | 203,769 | illicit / licit / unknown, 49 time steps | fraud detection under temporal shift |
Frontier 2025–26: what changed since the slides
Frontiers · where does a shared vocabulary come from? · only prior-fitted models beat a tuned GNN · guarantees that assume neighbours are alike
Words & phrases
| Term | Simple meaning | Persian | In context |
|---|---|---|---|
| zero-shotadj. | working on a new task or dataset with no task-specific training examples | بدون نمونه (صفر-نمونهای) | "beats a 27B-parameter LLM by 13% zero-shot AUROC" |
| exchangeabilityn. | (statistics) the joint distribution doesn't change if you reorder the data points | تعویضپذیری | "assuming exchangeability between calibration and test points" |
| in-context learningn. | solving a new task from examples given in the input, without updating weights | یادگیری درونمتنی | "PRODIGY does in-context learning on graphs" |
| promptn. | the examples and query given to a model at inference time | پرامپت (درخواست) | "a prompt graph with labelled examples" |
| coveragen. | how often a prediction set contains the true answer | پوشش | "90% coverage, guaranteed" |
| quantilen. | the value below which a given fraction of the data falls | چندک | "the 90% quantile of calibration scores" |
Go deeper
- Next: Lecture 15 — foundation models for knowledge graphs: how ULTRA generalises to new relation types via double equivariance.
- Survey: Liu et al. (2023), "Towards Graph Foundation Models: A Survey and Beyond".
- Open question: is there a single "universal" pretraining task for graphs, the way next-token prediction is for text? Neighbour matching, masked cells, link prediction are candidates.