RT-J: Large-Scale Pretraining of Relational Transformers for Context-Efficient Predictions

Rishabh Ranjan, Vignesh Kothapalli, Harshvardhan Agarwal, Charilaos I. Kanatsoulis, Roshan Reddy Upendra, Tom Palczewski, Carlos Guestrin, Jure LeskovecNeurIPS 2026

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:

  1. 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.
  2. 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:

Figure 1: RT-J pretraining recipe. (1) We sample a database and prediction task from THE JOIN. The task specifies the target table and the target column. (2) We sample a target row from the target table. Rows after the target row’s timestamp are dropped; kept target-table rows form the candidate in-context examples. (3) From the target row, many parallel random walks rank candidate examples by visit count, on the fly. (4) We process candidate examples in descending visit-count order, using each as the root of a local bounded-width breadth-first-search (BFS) over primary–foreign key links; the context size and BFS hyperparameters are sampled randomly. (5) The collected rows form the context window for the relational transformer (RT), which treats cells as tokens. The target table rows in the context enable in-context learning. The target cell is always masked; non-target cells may be masked optionally. (6) RT-J predicts all masked cells and is trained against their ground-truth values.
  • 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):

Figure 2: In-context regression. Exam- ples are matched. RT-J at train context size of 8192 cells fits around 225 exam- ples on average. At all example counts, RT-J is > 2 nMAE points better than the best baseline; at all performance levels, RT-J needs ≳10× fewer examples.
  • 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 + TabICLv2 only 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

Abstract

Foundation models for tables and relational databases are increasingly used for predictive tasks across various scientific and industrial domains. However, adapting existing models to unseen datasets requires tens of thousands of examples. Here we introduce RT-J, an 86M-parameter relational foundation model (RFM) that makes accurate predictions even with hundreds of in-context examples or fewer. To achieve this, we first assemble the Join, a large collection of 639 web-crawled databases with 6,023 LLM-generated forecasting tasks. We pretrain with long contexts of up to 8,192 database cells, using in-context examples from a novel lightweight random-walk retriever. Finally, we leverage context tuning and ensembling to scale up test-time compute. On in-context regression tasks from RelBench, RT-J requires 10x fewer examples on average to match strong feature engineering pipelines with LLM-agent or RDBLearn featurizers and TabICLv2 or LightGBM predictors. Overall, our work pushes the frontier for context-efficient predictions on relational data and highlights the importance of real-world semantics, context engineering and large-scale pretraining for RFMs.
BibTeX
@inproceedings{ranjan2026rt,
  author = {Rishabh Ranjan and Vignesh Kothapalli and Harshvardhan Agarwal and Charilaos I. Kanatsoulis and Roshan Reddy Upendra and Tom Palczewski and Carlos Guestrin and Jure Leskovec},
  title = {{RT-J: Large-Scale Pretraining of Relational Transformers for Context-Efficient Predictions}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=sMFUopPlwy},
}
Figure