> ## Documentation Index
> Fetch the complete documentation index at: https://docs.priorlabs.ai/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> TabPFN-3 and later versions support up to 1,000,000 rows, subject to feature count and checkpoint/API limits.
> For large datasets, use per-estimator subsampling, e.g. inference_config={"SUBSAMPLE_SAMPLES": 100_000}, in TabPFNClassifier or TabPFNRegressor from tabpfn or tabpfn_client.
> Pass raw pandas DataFrames to fit and predict. Categorical strings/categories, raw text, and missing feature values are handled automatically; no manual integer/one-hot encoding, imputation, scaling, or outlier removal is needed.

# Batched and differentiable inference

> Used in Fine-Tuning. Fit the model to preprocessed inputs from torch

> [!NOTE]
>
> Looking for usage documentation? Check out [Fine tuning](https://docs.priorlabs.ai/capabilities/fine-tuning.md).

## `TabPFNClassifier.fit_from_preprocessed`

[ View source ](https://github.com/PriorLabs/TabPFN/blob/f02b3b5941717472eafd078c15ae2043676b3fcf/src/tabpfn/classifier.py#L1041)

Used in Fine-Tuning. Fit the model to preprocessed inputs from torch
dataloader inside a training loop a Dataset provided by
get\_preprocessed\_datasets. This function always uses the "batched" fit\_mode.

```python theme={null}
TabPFNClassifier.fit_from_preprocessed(
    X_preprocessed: list[torch.Tensor],
    y_preprocessed: list[torch.Tensor],
    cat_ix: list[list[list[int]]],
    configs: list[list[EnsembleConfig]],
    *,
    performance_options: PerformanceOptions,
    no_refit: bool = True,
) -> TabPFNClassifier
```

**Parameters**

| Parameter | Type | Default | Description |
| - | - | - | - |
| `X_preprocessed` | `list[torch.Tensor]` | Required | The input features obtained from the preprocessed Dataset The list contains one item for each ensemble predictor. use tabpfn.utils.collate\_for\_tabpfn\_dataset to use this function with batch sizes of more than one dataset (see examples/tabpfn\_finetune.py) |
| `y_preprocessed` | `list[torch.Tensor]` | Required | The target variable obtained from the preprocessed Dataset |
| `cat_ix` | `list[list[list[int]]]` | Required | categorical indices obtained from the preprocessed Dataset |
| `configs` | `list[list[EnsembleConfig]]` | Required | Ensemble configurations obtained from the preprocessed Dataset |
| `performance_options` | `PerformanceOptions` | Required | Performance and memory options forwarded to the model on each forward call inside the resulting executor. Compilation is enabled if either these options or the estimator's `enable_torch_compile` parameter enables it. |
| `no_refit` | `bool` | `True` | if `True`, the classifier will not be reinitialized when calling fit multiple times. |

**Returns**

| Type | Description |
| - | - |
| `TabPFNClassifier` | — |

***

## `TabPFNClassifier.predict_proba_batched`

[ View source ](https://github.com/PriorLabs/TabPFN/blob/f02b3b5941717472eafd078c15ae2043676b3fcf/src/tabpfn/classifier.py#L1132)

Predict probabilities for several independent datasets in one pass.

Each `(X_train, y_train, X_test)` triple is preprocessed exactly as in
[`fit()`](https://docs.priorlabs.ai/api-reference/python/tabpfn/classifier/fitting-and-prediction#fit) + [`predict_proba()`](https://docs.priorlabs.ai/api-reference/python/tabpfn/classifier/fitting-and-prediction#predict-proba) (input validation, CPU and GPU
preprocessing, same ensemble configs), then compatible model-input shapes
are fused. Heterogeneous post-preprocessing shapes run in separate groups.

All datasets must share the same set of classes (they are scored together
with a single `n_classes_`) and the same raw array shapes. Fitted
transforms may produce different model-input shapes; these are grouped
internally without padding.

This method does not modify the estimator: the per-dataset fits run on an
internal clone, so `self` is unchanged on return (any prior [`fit`](https://docs.priorlabs.ai/api-reference/python/tabpfn/classifier/fitting-and-prediction#fit) is
preserved).

```python theme={null}
TabPFNClassifier.predict_proba_batched(
    X_train_list: list[XType],
    y_train_list: list[YType],
    X_test_list: list[XType],
) -> np.ndarray
```

**Parameters**

| Parameter | Type | Default | Description |
| - | - | - | - |
| `X_train_list` | `list[XType]` | Required | Training features, one array per dataset (all same shape). |
| `y_train_list` | `list[YType]` | Required | Training labels, one array per dataset. |
| `X_test_list` | `list[XType]` | Required | Test features, one array per dataset (all same shape). |

**Returns**

| Type | Description |
| - | - |
| `np.ndarray` | Probabilities of shape `(n_datasets, n_test, n_classes)`. |

**Raises**

`ValueError`

If the input lists have unequal or zero length, the
datasets do not all share the same set of classes, or the training
(or test) arrays do not all share one shape.

`NotImplementedError`

If `balance_probabilities`, `tuning_config`,
or `SAMPLE_SUBSAMPLING_METHOD="majority_downsample"` is
configured on the estimator — their state is per-dataset and
cannot be applied correctly across a shared batch. Score those
datasets individually with [`predict_proba`](https://docs.priorlabs.ai/api-reference/python/tabpfn/classifier/fitting-and-prediction#predict-proba). Also raised for
`inference_precision=torch.float64`, which the fused forward
does not support.

***

## `TabPFNClassifier.fit_with_differentiable_input`

[ View source ](https://github.com/PriorLabs/TabPFN/blob/f02b3b5941717472eafd078c15ae2043676b3fcf/src/tabpfn/classifier.py#L1356)

Fit the model with differentiable input.

```python theme={null}
TabPFNClassifier.fit_with_differentiable_input(
    X: torch.Tensor,
    y: torch.Tensor,
) -> Self
```

**Parameters**

| Parameter | Type | Default | Description |
| - | - | - | - |
| `X` | `torch.Tensor` | Required | The input data. |
| `y` | `torch.Tensor` | Required | The target variable. |

**Returns**

| Type | Description |
| - | - |
| `Self` | self |

***

## `TabPFNClassifier.logits_to_probabilities`

[ View source ](https://github.com/PriorLabs/TabPFN/blob/f02b3b5941717472eafd078c15ae2043676b3fcf/src/tabpfn/classifier.py#L1831)

Convert logits to probabilities using the classifier's post-processing.

```python theme={null}
TabPFNClassifier.logits_to_probabilities(
    raw_logits: np.ndarray | torch.Tensor,
    *,
    softmax_temperature: float | None = None,
    average_before_softmax: bool | None = None,
    balance_probabilities: bool | None = None,
    downsample_correction_weights: np.ndarray | None = None,
) -> torch.Tensor
```

**Parameters**

| Parameter | Type | Default | Description |
| - | - | - | - |
| `raw_logits` | `np.ndarray \| torch.Tensor` | Required | Logits with shape (n\_estimators, n\_samples, n\_classes) or (n\_samples, n\_classes). If the logits have three dimensions, they are averaged across the estimator dimension (dim=0). |
| `softmax_temperature` | `float \| None` | `None` | Optional override for temperature scaling. |
| `average_before_softmax` | `bool \| None` | `None` | Optional override for averaging order. |
| `balance_probabilities` | `bool \| None` | `None` | Optional override for probability balancing. |
| `downsample_correction_weights` | `np.ndarray \| None` | `None` | Optional override for the fitted `downsample_correction_weights_`, either one vector or one row per sample. `None` means "use the fitted weights"; tuning always passes explicit weights (ones where a fold applied no correction) because its folds carry their own correction. |

**Returns**

| Type | Description |
| - | - |
| `torch.Tensor` | Probabilities with shape (n\_samples, n\_classes). |

***

## `TabPFNClassifier.forward`

[ View source ](https://github.com/PriorLabs/TabPFN/blob/f02b3b5941717472eafd078c15ae2043676b3fcf/src/tabpfn/classifier.py#L1924)

Forward pass returning predicted probabilities or logits
for [`TabPFNClassifier`](https://docs.priorlabs.ai/api-reference/python/tabpfn/classifier/configuration#constructor) Inference Engine. Used in
Fine-Tuning and prediction. Called directly
in FineTuning training loop or by predict() function
with the `use_inference_mode` flag explicitly set to `True`.

Iterates over outputs of InferenceEngine.

```python theme={null}
TabPFNClassifier.forward(
    X: list[torch.Tensor] | torch.Tensor,
    *,
    use_inference_mode: bool = False,
    return_logits: bool = False,
    return_raw_logits: bool = False,
) -> torch.Tensor
```

**Parameters**

| Parameter | Type | Default | Description |
| - | - | - | - |
| `X` | `list[torch.Tensor] \| torch.Tensor` | Required | list\[torch.Tensor] in fine-tuning, XType in normal predictions. |
| `use_inference_mode` | `bool` | `False` | Flag for inference mode., default at `False` since |
| `return_logits` | `bool` | `False` | If `True`, returns logits averaged across estimators. Otherwise, probabilities are returned. |
| `return_raw_logits` | `bool` | `False` | If `True`, returns the raw logits, without averaging estimators or temperature scaling. |

**Returns**

| Type | Description |
| - | - |
| `torch.Tensor` | The predicted probabilities or logits of the classes as a torch.Tensor. - If `use_inference_mode` is `True`: Shape (N\_samples, N\_classes) - If `use_inference_mode` is `False` (e.g., for training/fine-tuning):   Shape (Batch\_size, N\_classes, N\_samples), suitable for NLLLoss. - If `return_raw_logits` is `True`: Shape (n\_estimators, n\_samples, n\_classes) |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.