01 · The problem
Why tabular prediction is difficult
Tabular data underpins applied machine learning in spreadsheets, logs, transactions, and clinical records. Its columns can mix numbers, categories, dates, and missing values, while each dataset can introduce a new schema and prediction task.
Gradient-boosted trees such as XGBoost and LightGBM remain strong task-specific baselines. They fit new parameters for each dataset, while tabular foundation models try to reuse a prediction procedure learned during pretraining.
Online shopping sessions under stress
Five records from the UCI Online Shoppers dataset ↗. The final session is the query, so its Revenue label is hidden.
last row = query · ? = hidden Revenue target · select a column to inspect it
02 · Adaptation
Fit a model or provide context
A tree ensemble learns a new set of trees from each labeled table. Later predictions need the fitted ensemble and the new feature rows.
In-context TFMs such as TabPFN and TabICL keep their pretrained network weights fixed. They process labeled context rows and query rows together during prediction. [TFM book] [TabPFN]
The difference is where task adaptation happens: fitted parameters or inference context.
Provide examples as context
03 · Theory
Prior-Data Fitted Network (PFN)
A prior-data fitted network, or PFN, learns a prediction rule across sampled supervised tasks. Each episode reveals context labels, hides query labels, and uses query loss to improve one shared predictor.
In the PFN formulation, minimizing expected query loss makes the network approximate the posterior-predictive distribution induced by the sampled task prior. [PFN]
PFN learns how to learn from a table
Instead of fitting a new model to one dataset, pretraining repeats the same four-step lesson across many temporary datasets.
-
01
Sample a taskA fresh table comes from the prior.
-
02
Make an episodeShow context labels; hide the query label.
-
03
Predict the queryOne shared network reads the examples.
-
04
θ′
Learn from the errorUpdate θ, discard the temporary table.
Repeat across tasks. The datasets disappear; the prediction strategy remains in θ.
At inference: freeze θ and use a new table only as context.
Follow one purchase-prediction episode
The same illustrative shopping task runs through every step below.
Start with a fresh supervised task
The prior defines what kinds of tables and relationships the PFN practices on.
- D
- one temporary labeled table
- p(D)
- the task-generating prior
Each click changes the episode below; the shared parameters θ stay the same.
Turn the task into context and a query
The network sees worked examples and one question whose answer is hidden.
Dc = {(xi, yi)} · Dq = {(xq, ?)}
Use the context to predict the hidden answer
The same network parameters serve every task; the context changes what prediction they produce.
Reveal the answer and update the shared predictor
This happens during PFN pretraining, then repeats with another temporary task.
yq = 1; NLL = −log qθ(yq = 1 | xq, Dc) = −log 0.63 = 0.46
Watch a synthetic table come into existence
First sample one data-generating mechanism. Then reuse that same mechanism with fresh random noise to create many related rows.
Choose a causal graph and its functions
See the sampled equations
z = f(ε₁, ε₂)
x₁ = g₁(z, εₓ₁)
x₂ = g₂(z, ε₂, εₓ₂)
y = 1[h(z, x₂, εᵧ) > 0]
Draw noise, then run the equations forward
The generator creates X and y; the episode masks query y later
No rows yet. Generate one row to see its complete causal trace.
| row | X₁ | X₂ | y |
|---|
Minimize expected query loss across the task prior
With enough capacity and representative tasks, this trains qθ to approximate the prior's posterior-predictive distribution.
Important boundary: the approximation is relative to the chosen task prior, not a universal Bayesian predictor for every possible table.
04 · Architecture
Try it.Train it.Run inference.
PFN describes a training formulation, not one required architecture. This tutorial makes it concrete with nanoTabICL, a compact implementation of the TabICLv2 graph. TabICLv2 applies the PFN objective to synthetic tasks; nanoTabICL exposes its core inference graph in a compact educational implementation. [PFN] [TabICLv2] [nanoTabICL]
Compare four predictors on the same task
All four answer the same question: given labeled rows and one query, what class should the query get? Logistic regression and the tree fit task-specific parameters; the frozen TFM instead adapts through inference context without updating its weights.
Nearby labeled rows vote. Spatial distance decides which rows count as evidence.
The same context passes through fixed weights. Learned attention decides how each row is read.
Compare them side by side below: the labeled points and query stay fixed while each model produces its own decision field.
Same data and query across four predictors
Linear, tree, kNN, and TFM use one shared dataset and query. Drag any ★ to update the complete 2×2 comparison.
TFM note: its boundary is a single-view preview for speed; its displayed probability is the full 8-view ensemble. This 20-row context is an out-of-regime illustration: TabICLv2 was pretrained on 300 to 48K rows, and the official authors have not tested generalization below 300 rows. See the official FAQ ↗
How does the model learn this behavior across synthetic tasks?
Follow one toy task through nanoTabICL’s training graph
The graph and tensor dimensions are faithful; the small task and output values are illustrative. Real TabICLv2 pretraining samples graph-SCM tasks in batches and does not run in this browser.
Step 01 explainerStandardize first, then shift and wrap features open +
nanoTabICL first standardizes every feature using statistics from the
context rows only. It then follows the TabICLv2 paper convention: every
position collects offsets 0, +1, and
+3, wrapping past the final column.
x′ij = (xij − μj,context) / (σj,context + ε)
group(j) = [x′1+(j mod d), x′1+((j+1) mod d), x′1+((j+3) mod d)]
[x′₁, x′₂, x′₄][x′₂, x′₃, x′₁][x′₃, x′₄, x′₂][x′₄, x′₁, x′₃]
The shared Linear(3→128) keeps four output positions while
giving each feature repeated local context. Context cells then receive
y_embed_in(yᵢ); query cells receive no label embedding.
The frozen browser checkpoint preserves TabICL 2.0.2’s cyclically shifted
+1,+2,+4 ordering, while this training explainer follows the
paper and current nanoTabICL source.
Step 02 explainerHow column and row attention differ open +
Before this stage, each context cell has already received
y_embed_in(yᵢ); the pink query cell has not. Each of the three
column blocks reuses one learned bank of 128 inducing vectors independently
across feature columns, rather than learning a different bank per column.
Inducing tokens query every context cell and produce 128 column summaries.
All cells, including Q, read those summaries. Information reaches Q through I.
Why use I? It creates a fixed-size context memory and changes
per-column row attention from O(n²) to approximately
O(nk), where k = 128 inducing tokens; across
d feature columns the attention cost is approximately
O(dnk). QASSMax is used in the context-summarizing pass.
One short sequence is processed independently for each row
4 CLS tokens + 4 feature tokens
→
blocks 1–2: all 8 query all 8
→
block 3: 4 CLS query all 8
→
LayerNorm + concatenate = 512D
All three row blocks use RoPE. Eight tokens are already cheap to attend directly, and the first two blocks preserve feature-to-feature interactions. The last block computes only the four CLS outputs. Unlike inducing tokens, CLS tokens collect one row’s output; they do not mediate attention between rows.
Query path: three column blocks → three row blocks → 512D query token → twelve ICL blocks → LayerNorm + MLP → ten logits.
Standardize from context, then create repeated feature groups
Use context mean and standard deviation, group offsets 0, +1, and +3 with wrap-around, project each group to 128D, then add the first label embedding to context cells only.
10×4 → standardize → 10×4×3 → 10×4×128 + y_embed_in(context)
How does the frozen graph use context to answer a query?
Inference repeats the same preprocessing and 3-column / 3-row / 12-ICL-block forward graph, but stops after prediction. Context labels are embedded; the query label is unavailable; pretrained weights remain frozen. There is no loss, backpropagation, or task-specific optimizer step in this diagram. [Qu et al., 2026]
Trace the same toy table without an update step
This is a shape-faithful schematic. Select a stage to inspect what is reused from training and what changes at inference.
Standardize, group each feature position, then embed it
Use context statistics, then gather j, j+1, and j+3 modulo d under the paper/current nanoTabICL convention. For d=4, x₁ maps to [x′₁, x′₂, x′₄]. Context cells receive y_embed_in; the query does not.
10×4 + separate context y → z-score → 10×4×3 → 10×4×128
05 · Live model explorer
Trace a real Iris prediction
The embedded explorer runs mapped upstream TabICLv2 classifier weights locally. Select a query, follow the context rows through the model, and inspect real selected-view attention and output probabilities.
Scope: its 12-row Iris context is deliberately small for tracing and is outside TabICLv2's documented 300 to 48K-row pretraining regime. Treat the output as an out-of-regime illustration, not evidence of expected model quality.
Implementation note: The main playground runs the complete eight-view browser classifier. This embedded inspector uses the selected-view nanoTabICL-shaped bridge adapted to the released TabICLv2 checkpoint so its intermediate tensors remain traceable. It is not the standalone nanoTabICL model.
06 · References
References
Primary papers, implementations, checkpoints, datasets, and evaluation suites cited throughout this tutorial.
Tabular foundation models
TabPFN v3
General classification and regression with large-context variants.
TabICLv2
Open compress-then-ICL model and the main reference for this tutorial.
Nori
Open synthetic-pretrained foundation model for tabular regression.
Evaluation benchmarks
TabArena
Living benchmark and leaderboard for curated IID tabular tasks.
BeyondArena
Evaluation across IID, temporal, grouped, large, and high-dimensional tasks.
ScoringBench
Probabilistic regression benchmark using proper scoring rules for predictive distributions.
TALENT
Broad toolbox and benchmark for classical and deep tabular methods.
TabZilla
A suite of 36 difficult datasets for comparing tabular algorithms.
Methods, data, and materials
PFNs
XGBoost
Online Shoppers
Transformer Explainer (MIT)
The Illustrated Transformer
Three.js (MIT)
This tutorial
Code and checkpoints can use different licenses. Check upstream terms before reuse.