Skip to content

loading

download_all_models

download_all_models(to: Path) -> None

Download all v2 classifier and regressor models into a local directory.

download_model

download_model(
    to: Path,
    *,
    version: Literal["v2"],
    which: Literal["classifier", "regressor"],
    model_name: str | None = None
) -> Literal["ok"] | list[Exception]

Download a TabPFN model, trying all available sources.

Parameters:

Name Type Description Default
to Path

The directory to download the model to.

required
version Literal['v2']

The version of the model to download.

required
which Literal['classifier', 'regressor']

The type of model to download.

required
model_name str | None

Optional specific model name to download.

None

Returns:

Type Description
Literal['ok'] | list[Exception]

"ok" if the model was downloaded successfully, otherwise a list of

Literal['ok'] | list[Exception]

exceptions that occurred that can be handled as desired.

load_model

load_model(*, path: Path, model_seed: int) -> tuple[
    PerFeatureTransformer,
    BCEWithLogitsLoss
    | CrossEntropyLoss
    | FullSupportBarDistribution,
    InferenceConfig,
]

Loads a model from a given path.

Parameters:

Name Type Description Default
path Path

Path to the checkpoint

required
model_seed int

The seed to use for the model

required

load_model_criterion_config

load_model_criterion_config(
    model_path: None | str | Path,
    *,
    check_bar_distribution_criterion: bool,
    cache_trainset_representation: bool,
    which: Literal["regressor", "classifier"],
    version: Literal["v2"] = "v2",
    download: bool,
    model_seed: int
) -> tuple[
    PerFeatureTransformer,
    BCEWithLogitsLoss
    | CrossEntropyLoss
    | FullSupportBarDistribution,
    InferenceConfig,
]

Load the model, criterion, and config from the given path.

Parameters:

Name Type Description Default
model_path None | str | Path

The path to the model.

required
check_bar_distribution_criterion bool

Whether to check if the criterion is a FullSupportBarDistribution, which is the expected criterion for models trained for regression.

required
cache_trainset_representation bool

Whether the model should know to cache the trainset representation.

required
which Literal['regressor', 'classifier']

Whether the model is a regressor or classifier.

required
version Literal['v2']

The version of the model.

'v2'
download bool

Whether to download the model if it doesn't exist.

required
model_seed int

The seed of the model.

required

Returns:

Type Description
tuple[PerFeatureTransformer, BCEWithLogitsLoss | CrossEntropyLoss | FullSupportBarDistribution, InferenceConfig]

The model, criterion, and config.