TL;DR
Making predictions on multi-table relational databases usually requires either building complex feature-engineering pipelines or training task-specific models on tens of thousands of examples. RT-J is an 86M-parameter Relational Foundation Model that brings true few-shot, in-context learning to relational data—matching top feature-engineering and tabular ML pipelines with 10× fewer labeled examples, all in a single forward pass.
What Problem Does This Paper Address?
Language and vision models conquered few-shot learning years ago: show an LLM a few examples in a prompt, and it adapts on the fly. Yet this capability has remained stubbornly out of reach for relational databases—the multi-table structures linked by primary and foreign keys where most enterprise, healthcare, and scientific data actually live.
Currently, if an analyst wants to predict customer churn or clinical trial outcomes on a new database with scarce labels, they face two flawed options:
- Flatten the database: Use automated tools or LLM agents to write SQL aggregations that squish connected tables into a single flat table for tabular predictors (like LightGBM or TabICLv2). This destroys explicit cross-table structure and struggles when labeled data is scarce.
- Natively relational models: Graph neural networks and earlier Relational Transformers (RTs) preserve database structure, but either require training from scratch per schema or were pretrained for zero-shot/fine-tuning regimes rather than few-shot in-context learning.
The authors ask: How do we turn a Relational Transformer into a genuine, sample-efficient in-context learner?
Methods
Instead of inventing a new neural backbone, the authors stick to an established 86M-parameter Relational Transformer (RT)—which treats individual database cells as tokens and attends across columns, rows, and primary–foreign key links—and overhaul the training, retrieval, and inference recipe:
- Two-Stage Random-Walk Retrieval (New): A database has millions of cells, while RT-J's context window holds up to 8,192 cells. Naive breadth-first search (BFS) from a query row wastes budget on generic, nearby cells. Instead, RT-J fires 10,000 fast, parallel random walks from the target row across primary–foreign key links on the CPU (zero GPU data-loading overhead!). Candidate labeled rows from the target table are ranked by visit count—prioritizing entities connected via shared items, users, or events—and then expanded locally via bounded-width BFS. Because everything lives in one shared context window, overlapping relational neighborhoods aren't duplicated.
- Stochastic Long-Context Pretraining (New): The model is trained on a uniform mix of context lengths (512 to 8,192 cells) and random BFS hyperparameters so it can flexibly trade off compute and accuracy at test time.
- Test-Time Compute Scaling (New): At inference, RT-J boosts accuracy by tuning retrieval hyperparameters on a validation split (context tuning) and averaging predictions over multiple independently sampled random-walk contexts (context ensembling).
Datasets
- Pretraining Phase 1 — PluRel: A synthetic corpus of 1,900 databases and 86,211 tasks (yielding an intermediate model, RT-PluRel).
- Pretraining Phase 2 — THE JOIN (Newly Introduced): Because real-world relational pretraining corpora were scarce, the authors curated THE JOIN: 639 real web-crawled databases (from APIs, Stack Exchange, sports portals, SEC filings, etc.) standardized for clean types and inferred foreign keys. Crucially, they used an LLM (Claude Opus 4.6) paired with deterministic verification and XGBoost quality filtering to generate 6,023 realistic forecasting tasks alongside 11K autocomplete tasks.
- Evaluation — RelBench: Held-out benchmark of 21 forecasting tasks (9 regression, 12 classification) across 7 diverse databases, strictly decontaminated from THE JOIN.
Key Insights and Ideas
- Native relational context beats feature flattening: Because all baselines see the exact same labeled examples, RT-J's massive lead in low-data regimes proves that directly attending over raw connected cells preserves predictive signal lost when SQL/feature pipelines aggregate neighborhoods into flat tables.
- World knowledge hides in schema names: RT-J embeds table and column names using frozen language model embeddings. Shuffling those names at test time degrades both classification (up to 2.1 AUROC points) and regression—and the gap widens with more examples, showing RT-J learned real-world semantic priors from THE JOIN that raw numbers alone can't replace.
- Retrieval quality isn't just cramming more labels: Ablations show that uniformly random retrieval packs nearly as many labeled examples into an 8K-cell window as random walks (208 vs. 223), yet trails by over 4 nMAE and 6 AUROC points. Which examples and relational neighborhoods you retrieve matters far more than raw label count.
- Synthetic + Real data is synergistic: Pretraining on synthetic data (PluRel) builds structural reasoning, while continued pretraining on real data (THE JOIN) provides the biggest jump for in-context learning (+1.5 AUROC and +0.6 nMAE points).
Key Results
On RelBench in-context evaluations (matching exact example counts without tuning/ensembling):
- 10× Sample Efficiency on Regression: At its max training context of 8,192 cells (~225 examples on average), RT-J beats strong pipelines (
LLM Agent + TabICLv2,RDBLearn + TabICLv2/LightGBM) by 2.3–5.0 nMAE points across all context sizes. Remarkably, RT-J with just 15 examples beats every baseline at 225 examples; the best baseline needs ~2,300 examples to catch up. - Scarce-Label Classification Lead: RT-J leads by 3.1 AUROC points at the smallest context size, with
LLM Agent + TabICLv2only catching up at ~225 examples. - Test-Time Scaling: Averaging 16 random-walk contexts adds +1.1 to +1.3 AUROC points on classification, while context tuning drops single-seed regression nMAE from 33.4% to 32.5%. Fine-tuned RT-PluRel also took 1st place on the RelArena-$\alpha$ leaderboard.
Limitations and Future Work
- Context ceiling: RT-J is currently capped at 8,192 cells (~225 examples); scaling to longer contexts would allow both more support examples and deeper relational neighborhoods.
- Task scope: Like the original RT architecture, RT-J predicts cell values (classification/regression) and cannot perform link prediction or recommendation tasks.
- Benchmark breadth: Evaluation is limited to RelBench's 21 tasks across 7 databases; the authors suggest using their automated LLM task-curation pipeline to build broader real-world benchmarks.
Summary updated