Skip to main content
ByEliott Kalfon
Follow one prediction back to the training rows that voted for it. The final predicted label of TabPFN is an attention-weighted average over context labels. This means that each classification prediction is a weighted vote over actual context labels. In this cookbook, you will see how to see exactly which rows TabPFN attended to to generate a prediction. We will use the heart-statlog dataset as example.
This explains the model’s computation. It does not show that a training row caused heart disease, and it is not medical advice.

Setup

Install the local TabPFN model, the decoder helpers, and UMAP for clear 2D views. The decoder readout needs the local model because it reads an internal attention layer. The hosted API does not expose this layer.
If the model asks for access, add TABPFN_TOKEN to Colab secrets. This cell leaves existing local authentication unchanged.

Load Heart Statlog

Use short names so the rows stay easy to scan. Heart Statlog has 270 rows, 13 patient features, and two classes. We keep 200 rows for training and 70 for testing.
Load Heart Statlog

Fit TabPFN

Read the Decoder Votes

Recover one weight for every test-row/training-row pair. For a given test row, all training-row weights are non-negative and sum to one. Adding the weights within each class gives that class’s vote.

One Prediction as a Table

Start with the most uncertain test row. This row has a heart-disease vote closest to 50%. The table ranks the training rows by decoder weight. Its first rows had the strongest vote.
The first row has the largest single weight. The prediction still uses all 200 training rows, not just the ten shown here.
One Prediction as a Table

One Prediction in Raw Feature Space

Place the test row and its strongest voters on a 2D map of the original columns. The star is the test row. A line joins it to each of its 20 strongest training rows. Thicker lines mean larger weights. Blue and orange mark the training class.
One Prediction in Raw Feature Space

The Same Prediction in Embedding Space

TabPFN turns each row into a learned embedding before the decoder acts. This view projects those embeddings to 2D. It often places the strongest voters closer to the star and separates the two classes more clearly.
The Same Prediction in Embedding Space The raw and embedding plots show exactly the same decoder weights. Only the map changes. UMAP compresses many dimensions into two, so distances in either picture are useful summaries, not exact model distances.

Four Predictions Together

Compare confident and uncertain votes in one view. We choose the lowest heart-disease predicted probability, the two observations nearest the 50% predicted probability from either side, and the largest predicted probability.

Combined raw-feature view

The original feature map can mix rows from the two classes. Strong decoder links may cross large parts of this 2D view.
Combined raw-feature view

Combined embedding view

In the learned map, the same links tend to stay within clearer class regions. This is the space that best reveals what the decoder keys on.
Combined embedding view

What to Keep

  • A decoder weight says how much one training row voted for one test row.
  • Summing weights by class gives the class vote.
  • The table is exact; the 2D maps are visual summaries.
  • Raw space shows observations in the raw feature space. Embedding space is closer to the model’s own view.
The decoder readout is most useful for finding influential examples, checking whether a prediction rests on one row or many, and spotting surprising voters worth a closer look. Further reading: decoder readout example and interpretability helpers.