How the Relational Transformer predicts over a database
What replaces feature engineering, and what it costs.
1 Aug 2026 · Architecture · 7 min
Your data lives in a rich graph: a customer table, the orders pointing at it, the tickets those orders spawned, and the timestamps holding all of it in order. However, historically most approaches have predicted over a rectangular shape of data rather than retaining that original graph structure.
Architecture
When first looking at the Relational Transformer architecture, the striking thing is how ordinary it is: pre-norm RMSNorm, QK-norm on the queries and keys, a SwiGLU feed-forward, zero-initialised residual branches. All standard modern transformer hygiene. Similar to LLMs, it takes some context of tokens, applies attention, normalizes, and then outputs tokens.
On top this, RelativeDB adds a task head to support multiclass and ranking over the backbone. Each example is encoded once and a [outputs × 512] layer is fitted on the results, about 2 KB.
The Data
RT-J was pretrained on The Join: 650 real-world relational databases spanning e-commerce, sports, media, finance, healthcare, government, and more. Together they supply roughly 6,000 forecasting tasks, plus autocomplete tasks over ordinary database rows. Every database keeps its tables, schema names, and primary-foreign-key graph, and any overlap with the seven RelBench evaluation databases was excluded.
Cell tokenisation
Each cell is tokenized with its column name, the type, and its data. Embedding the column name is what lets a model work with schemas it has never seen. For example, a column named sentiment can give sentiment analysis results despite only ever being trained on product review data.
enc_dict = {
"number": Linear(1, d_model),
"text": Linear(d_text, d_model), # 384, MiniLM
"datetime": Linear(1, d_model),
"boolean": Linear(1, d_model),
"col_name": Linear(d_text, d_model),
}Masked relational attention
Each block runs three attentions in sequence, each with its own weights and mask: feat (own row and its parents), nbr (rows pointing back), col (the same column elsewhere). These masks turn the database structure into the attention pattern: foreign keys are not another feature, but the rules that decide which cells can exchange information. As blocks stack, evidence can travel beyond one row or one join without opening attention across the entire context.
Context construction
Relational Transformers work with just a few thousand cells rather than your whole dataset. Which cells is decided by a sampler. The target cell goes first. Then a breadth-first shell around it; then peers of the same table, found by random walks across the foreign keys; then random rows to top up. This is configurable from 256-8192 cells. Like LLMs, more context doesn't always mean more accuracy.
Learning by hiding cells
Pretraining turns each database into its own supervision: hide known cells, reconstruct them from the visible relational context, and compare the predictions with the original values. Numbers, text, and dates use Huber loss; booleans use cross-entropy. At inference, an unknown target is presented in the same shape as a masked cell, its value is absent, while its schema and surrounding data remain visible.
The Future
PluRel's result is that synthetic databases can unlock scaling laws for Relational Transformers. Pretraining loss follows a power law in the number of synthetic databases. Those databases are generated, not acquired through buying anyone's private data, which is a usual toll on this road.
Small model, large database
RT-J scales by being small and selective. An 85-million-parameter model reads at most 8,192 cells per prediction, so the database behind that window can hold millions of rows without making every inference enormous. On held-out RelBench tasks, it matches or beats much larger in-context pipelines, including LLM agents that write SQL, while using far fewer labels.
Sources
- 2025Relational Transformer: Toward Zero-Shot Foundation Models for Relational DataRanjan et al., ICLR 2026
- 2026PluRel: Synthetic Data unlocks Scaling Laws for Relational Foundation ModelsKothapalli et al., ICML 2026
- —RT-J: large-scale pretraining for context-efficient predictionsin progress
- —The Join650 real-world relational databases for pretraining
- —stanford-star/relational-transformermodel and sampler source, quoted lightly reformatted
- —RelBench leaderboardbenchmark standings
- —RelQL documentationthe query language