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

# Batch and evaluation types

> Batch data for classifier fine-tuning.

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

<div className="python-reference-heading">
  <h2 id="classifierbatch">
    `ClassifierBatch`
  </h2>

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

Batch data for classifier fine-tuning.

```python theme={null}
ClassifierBatch(
    X_context: list[torch.Tensor],
    X_query: list[torch.Tensor],
    y_context: list[torch.Tensor],
    y_query: torch.Tensor,
    cat_indices: list[list[int] | None] | list[list[list[int] | None]],
    configs: list[Any],
)
```

**Fields**

<div className="python-reference-table">
  | Name | Type | Default | Description |
  | - | - | - | - |
  | <span id="classifierbatch--x-context" /><code className="python-reference-parameter">X\_<wbr />context</code> | <code className="python-reference-type">list\[torch.Tensor]</code> | Required | Preprocessed training features (list per estimator). |
  | <span id="classifierbatch--x-query" /><code className="python-reference-parameter">X\_<wbr />query</code> | <code className="python-reference-type">list\[torch.Tensor]</code> | Required | Preprocessed test features (list per estimator). |
  | <span id="classifierbatch--y-context" /><code className="python-reference-parameter">y\_<wbr />context</code> | <code className="python-reference-type">list\[torch.Tensor]</code> | Required | Preprocessed training targets (list per estimator). |
  | <span id="classifierbatch--y-query" /><code className="python-reference-parameter">y\_<wbr />query</code> | <code className="python-reference-type">torch.Tensor</code> | Required | Raw test target tensor. |
  | <span id="classifierbatch--cat-indices" /><code className="python-reference-parameter">cat\_<wbr />indices</code> | <code className="python-reference-type">list\[list\[int] \| None] \| list\[list\[list\[int] \| None]]</code> | Required | Categorical feature indices (list per estimator). |
  | <span id="classifierbatch--configs" /><code className="python-reference-parameter">configs</code> | <code className="python-reference-type">list\[Any]</code> | Required | Preprocessing configurations used for this batch. |
</div>

***

<div className="python-reference-heading">
  <h2 id="evalresult">
    `EvalResult`
  </h2>

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

Container for evaluation results.

```python theme={null}
EvalResult(
    primary: float,
    secondary: dict[str, float] = dict(),
)
```

**Fields**

<div className="python-reference-table">
  | Name | Type | Default | Description |
  | - | - | - | - |
  | <span id="evalresult--primary" /><code className="python-reference-parameter">primary</code> | <code className="python-reference-type">float</code> | Required | The primary metric used for early stopping decisions. |
  | <span id="evalresult--secondary" /><code className="python-reference-parameter">secondary</code> | <code className="python-reference-type">dict\[str, float]</code> | `dict()` | Additional metrics for logging purposes only. |
</div>

***

<div className="python-reference-heading">
  <h2 id="regressorbatch">
    `RegressorBatch`
  </h2>

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

Batch data for regressor fine-tuning.

```python theme={null}
RegressorBatch(
    X_context: list[torch.Tensor],
    X_query: list[torch.Tensor],
    y_context: list[torch.Tensor],
    y_query: torch.Tensor,
    cat_indices: list[list[int] | None] | list[list[list[int] | None]],
    configs: list[Any],
    raw_space_bardist: FullSupportBarDistribution,
    znorm_space_bardist: FullSupportBarDistribution,
    X_query_raw: torch.Tensor,
    y_query_raw: torch.Tensor,
)
```

**Fields**

<div className="python-reference-table">
  | Name | Type | Default | Description |
  | - | - | - | - |
  | <span id="regressorbatch--x-context" /><code className="python-reference-parameter">X\_<wbr />context</code> | <code className="python-reference-type">list\[torch.Tensor]</code> | Required | Preprocessed training features (list per estimator). |
  | <span id="regressorbatch--x-query" /><code className="python-reference-parameter">X\_<wbr />query</code> | <code className="python-reference-type">list\[torch.Tensor]</code> | Required | Preprocessed test features (list per estimator). |
  | <span id="regressorbatch--y-context" /><code className="python-reference-parameter">y\_<wbr />context</code> | <code className="python-reference-type">list\[torch.Tensor]</code> | Required | Preprocessed standardized training targets (list per estimator). |
  | <span id="regressorbatch--y-query" /><code className="python-reference-parameter">y\_<wbr />query</code> | <code className="python-reference-type">torch.Tensor</code> | Required | Standardized test target tensor. |
  | <span id="regressorbatch--cat-indices" /><code className="python-reference-parameter">cat\_<wbr />indices</code> | <code className="python-reference-type">list\[list\[int] \| None] \| list\[list\[list\[int] \| None]]</code> | Required | Categorical feature indices (list per estimator). |
  | <span id="regressorbatch--configs" /><code className="python-reference-parameter">configs</code> | <code className="python-reference-type">list\[Any]</code> | Required | Preprocessing configurations used for this batch. |
  | <span id="regressorbatch--raw-space-bardist" /><code className="python-reference-parameter">raw\_<wbr />space\_<wbr />bardist</code> | <code className="python-reference-type"><a href="https://github.com/PriorLabs/TabPFN/blob/c70b6ef0488858d32244c52222abfc0c5be207d6/src/tabpfn/architectures/shared/bar_distribution.py#L471">Full<wbr />Support<wbr />Bar<wbr />Distribution</a></code> | Required | Bar distribution in raw (original) target space. |
  | <span id="regressorbatch--znorm-space-bardist" /><code className="python-reference-parameter">znorm\_<wbr />space\_<wbr />bardist</code> | <code className="python-reference-type"><a href="https://github.com/PriorLabs/TabPFN/blob/c70b6ef0488858d32244c52222abfc0c5be207d6/src/tabpfn/architectures/shared/bar_distribution.py#L471">Full<wbr />Support<wbr />Bar<wbr />Distribution</a></code> | Required | Bar distribution in z-normalized target space. |
  | <span id="regressorbatch--x-query-raw" /><code className="python-reference-parameter">X\_<wbr />query\_<wbr />raw</code> | <code className="python-reference-type">torch.Tensor</code> | Required | Original unprocessed test features. |
  | <span id="regressorbatch--y-query-raw" /><code className="python-reference-parameter">y\_<wbr />query\_<wbr />raw</code> | <code className="python-reference-type">torch.Tensor</code> | Required | Original unprocessed test targets. |
</div>

***

<div className="python-reference-heading">
  <h2 id="main-process-first">
    `main_process_first`
  </h2>

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

Run the with-block on the main process before all other ranks.

Useful under `torchrun` for work that should happen once and be read
from a shared cache afterwards, such as dataset downloads: the main
process runs the block while the other ranks wait at a barrier, then the
other ranks run it against the warm cache.

Initializes the process group from the torchrun env vars if needed, and
leaves it initialized so that a subsequent `fit()` reuses it. Call
`torch.distributed.destroy_process_group()` at the end of your script.
No-op when running with a single process.

```python theme={null}
main_process_first() -> Iterator[None]
```

**Returns**

<div className="python-reference-table python-reference-returns">
  | Type | Description |
  | - | - |
  | <code className="python-reference-type">Iterator\[None]</code> | — |
</div>


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