> ## 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

<Info>
  Looking for usage documentation? Check out [Fine tuning](/capabilities/fine-tuning).
</Info>

<div className="python-reference-heading">
  <h2 id="fit-from-preprocessed">
    `TabPFNClassifier.fit_from_preprocessed`
  </h2>

  <a className="python-reference-source" href="https://github.com/PriorLabs/TabPFN/blob/c70b6ef0488858d32244c52222abfc0c5be207d6/src/tabpfn/classifier.py#L979" aria-label="View source for TabPFNClassifier.fit_from_preprocessed"><span aria-hidden="true">\</></span> View source <span aria-hidden="true">↗</span></a>
</div>

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**

<div className="python-reference-table">
  | Parameter | Type | Default | Description |
  | - | - | - | - |
  | <span id="fit-from-preprocessed--x-preprocessed" /><code className="python-reference-parameter">X\_<wbr />preprocessed</code> | <code className="python-reference-type">list\[torch.Tensor]</code> | 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) |
  | <span id="fit-from-preprocessed--y-preprocessed" /><code className="python-reference-parameter">y\_<wbr />preprocessed</code> | <code className="python-reference-type">list\[torch.Tensor]</code> | Required | The target variable obtained from the preprocessed Dataset |
  | <span id="fit-from-preprocessed--cat-ix" /><code className="python-reference-parameter">cat\_<wbr />ix</code> | <code className="python-reference-type">list\[list\[list\[int]]]</code> | Required | categorical indices obtained from the preprocessed Dataset |
  | <span id="fit-from-preprocessed--configs" /><code className="python-reference-parameter">configs</code> | <code className="python-reference-type">list\[list\[<a href="/api-reference/python/tabpfn/preprocessing/configuration#ensembleconfig">Ensemble<wbr />Config</a>]]</code> | Required | Ensemble configurations obtained from the preprocessed Dataset |
  | <span id="fit-from-preprocessed--performance-options" /><code className="python-reference-parameter">performance\_<wbr />options</code> | <code className="python-reference-type"><a href="https://github.com/PriorLabs/TabPFN/blob/c70b6ef0488858d32244c52222abfc0c5be207d6/src/tabpfn/architectures/interface.py#L58">Performance<wbr />Options</a></code> | Required | Performance and memory options forwarded to the model on each forward call inside the resulting executor. |
  | <span id="fit-from-preprocessed--no-refit" /><code className="python-reference-parameter">no\_<wbr />refit</code> | <code className="python-reference-type">bool</code> | `True` | if `True`, the classifier will not be reinitialized when calling fit multiple times. |
</div>

**Returns**

<div className="python-reference-table python-reference-returns">
  | Type | Description |
  | - | - |
  | <code className="python-reference-type"><a href="/api-reference/python/tabpfn/classifier/configuration#constructor">Tab<wbr />PFN<wbr />Classifier</a></code> | — |
</div>

***

<div className="python-reference-heading">
  <h2 id="predict-proba-batched">
    `TabPFNClassifier.predict_proba_batched`
  </h2>

  <a className="python-reference-source" href="https://github.com/PriorLabs/TabPFN/blob/c70b6ef0488858d32244c52222abfc0c5be207d6/src/tabpfn/classifier.py#L1056" aria-label="View source for TabPFNClassifier.predict_proba_batched"><span aria-hidden="true">\</></span> View source <span aria-hidden="true">↗</span></a>
</div>

Predict probabilities for several independent datasets in one pass.

Each `(X_train, y_train, X_test)` triple is preprocessed exactly as in
[`fit()`](/api-reference/python/tabpfn/classifier/fitting-and-prediction#fit) + [`predict_proba()`](/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`](/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**

<div className="python-reference-table">
  | Parameter | Type | Default | Description |
  | - | - | - | - |
  | <span id="predict-proba-batched--x-train-list" /><code className="python-reference-parameter">X\_<wbr />train\_<wbr />list</code> | <code className="python-reference-type">list\[<a href="https://github.com/PriorLabs/TabPFN/blob/c70b6ef0488858d32244c52222abfc0c5be207d6/src/tabpfn/constants.py#L25">X<wbr />Type</a>]</code> | Required | Training features, one array per dataset (all same shape). |
  | <span id="predict-proba-batched--y-train-list" /><code className="python-reference-parameter">y\_<wbr />train\_<wbr />list</code> | <code className="python-reference-type">list\[<a href="https://github.com/PriorLabs/TabPFN/blob/c70b6ef0488858d32244c52222abfc0c5be207d6/src/tabpfn/constants.py#L26">Y<wbr />Type</a>]</code> | Required | Training labels, one array per dataset. |
  | <span id="predict-proba-batched--x-test-list" /><code className="python-reference-parameter">X\_<wbr />test\_<wbr />list</code> | <code className="python-reference-type">list\[<a href="https://github.com/PriorLabs/TabPFN/blob/c70b6ef0488858d32244c52222abfc0c5be207d6/src/tabpfn/constants.py#L25">X<wbr />Type</a>]</code> | Required | Test features, one array per dataset (all same shape). |
</div>

**Returns**

<div className="python-reference-table python-reference-returns">
  | Type | Description |
  | - | - |
  | <code className="python-reference-type"><a href="https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html">np.ndarray</a></code> | Probabilities of shape `(n_datasets, n_test, n_classes)`. |
</div>

**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` or `tuning_config`
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`](/api-reference/python/tabpfn/classifier/fitting-and-prediction#predict-proba). Also raised for
`inference_precision=torch.float64`, which the fused forward
does not support.

***

<div className="python-reference-heading">
  <h2 id="fit-with-differentiable-input">
    `TabPFNClassifier.fit_with_differentiable_input`
  </h2>

  <a className="python-reference-source" href="https://github.com/PriorLabs/TabPFN/blob/c70b6ef0488858d32244c52222abfc0c5be207d6/src/tabpfn/classifier.py#L1272" aria-label="View source for TabPFNClassifier.fit_with_differentiable_input"><span aria-hidden="true">\</></span> View source <span aria-hidden="true">↗</span></a>
</div>

Fit the model with differentiable input.

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

**Parameters**

<div className="python-reference-table">
  | Parameter | Type | Default | Description |
  | - | - | - | - |
  | <span id="fit-with-differentiable-input--x" /><code className="python-reference-parameter">X</code> | <code className="python-reference-type">torch.Tensor</code> | Required | The input data. |
  | <span id="fit-with-differentiable-input--y" /><code className="python-reference-parameter">y</code> | <code className="python-reference-type">torch.Tensor</code> | Required | The target variable. |
</div>

**Returns**

<div className="python-reference-table python-reference-returns">
  | Type | Description |
  | - | - |
  | <code className="python-reference-type"><a href="/api-reference/python/tabpfn/classifier/configuration#constructor">Self</a></code> | self |
</div>

***

<div className="python-reference-heading">
  <h2 id="logits-to-probabilities">
    `TabPFNClassifier.logits_to_probabilities`
  </h2>

  <a className="python-reference-source" href="https://github.com/PriorLabs/TabPFN/blob/c70b6ef0488858d32244c52222abfc0c5be207d6/src/tabpfn/classifier.py#L1715" aria-label="View source for TabPFNClassifier.logits_to_probabilities"><span aria-hidden="true">\</></span> View source <span aria-hidden="true">↗</span></a>
</div>

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,
) -> torch.Tensor
```

**Parameters**

<div className="python-reference-table">
  | Parameter | Type | Default | Description |
  | - | - | - | - |
  | <span id="logits-to-probabilities--raw-logits" /><code className="python-reference-parameter">raw\_<wbr />logits</code> | <code className="python-reference-type"><a href="https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html">np.ndarray</a> \| torch.Tensor</code> | 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). |
  | <span id="logits-to-probabilities--softmax-temperature" /><code className="python-reference-parameter">softmax\_<wbr />temperature</code> | <code className="python-reference-type">float \| None</code> | `None` | Optional override for temperature scaling. |
  | <span id="logits-to-probabilities--average-before-softmax" /><code className="python-reference-parameter">average\_<wbr />before\_<wbr />softmax</code> | <code className="python-reference-type">bool \| None</code> | `None` | Optional override for averaging order. |
  | <span id="logits-to-probabilities--balance-probabilities" /><code className="python-reference-parameter">balance\_<wbr />probabilities</code> | <code className="python-reference-type">bool \| None</code> | `None` | Optional override for probability balancing. |
</div>

**Returns**

<div className="python-reference-table python-reference-returns">
  | Type | Description |
  | - | - |
  | <code className="python-reference-type">torch.Tensor</code> | Probabilities with shape (n\_samples, n\_classes). |
</div>

***

<div className="python-reference-heading">
  <h2 id="forward">
    `TabPFNClassifier.forward`
  </h2>

  <a className="python-reference-source" href="https://github.com/PriorLabs/TabPFN/blob/c70b6ef0488858d32244c52222abfc0c5be207d6/src/tabpfn/classifier.py#L1789" aria-label="View source for TabPFNClassifier.forward"><span aria-hidden="true">\</></span> View source <span aria-hidden="true">↗</span></a>
</div>

Forward pass returning predicted probabilities or logits
for [`TabPFNClassifier`](/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**

<div className="python-reference-table">
  | Parameter | Type | Default | Description |
  | - | - | - | - |
  | <span id="forward--x" /><code className="python-reference-parameter">X</code> | <code className="python-reference-type">list\[torch.Tensor] \| torch.Tensor</code> | Required | list\[torch.Tensor] in fine-tuning, XType in normal predictions. |
  | <span id="forward--use-inference-mode" /><code className="python-reference-parameter">use\_<wbr />inference\_<wbr />mode</code> | <code className="python-reference-type">bool</code> | `False` | Flag for inference mode., default at `False` since |
  | <span id="forward--return-logits" /><code className="python-reference-parameter">return\_<wbr />logits</code> | <code className="python-reference-type">bool</code> | `False` | If `True`, returns logits averaged across estimators. Otherwise, probabilities are returned. |
  | <span id="forward--return-raw-logits" /><code className="python-reference-parameter">return\_<wbr />raw\_<wbr />logits</code> | <code className="python-reference-type">bool</code> | `False` | If `True`, returns the raw logits, without averaging estimators or temperature scaling. |
</div>

**Returns**

<div className="python-reference-table python-reference-returns">
  | Type | Description |
  | - | - |
  | <code className="python-reference-type">torch.Tensor</code> | The predicted probabilities or logits of the classes as a torch.Tensor.<br />- If `use_inference_mode` is `True`: Shape (N\_samples, N\_classes)<br />- If `use_inference_mode` is `False` (e.g., for training/fine-tuning):   Shape (Batch\_size, N\_classes, N\_samples), suitable for NLLLoss.<br />- If `return_raw_logits` is `True`: Shape (n\_estimators, n\_samples, n\_classes) |
</div>


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