⚡ TabPFN: 表格数据的基础模型
[!TIP]
Dive right in with our interactive Colab notebook! It's the best way to get a hands-on feel for TabPFN, walking you through installation, classification, and regression examples.
pip install tabpfn
TabPFN supports Python 3.10+.
⚡ GPU Recommended: For optimal performance, use a GPU (even older ones with ~8GB VRAM work well; 16GB needed for some large datasets). On CPU, only moderate datasets are feasible (TabPFN-3 and TabPFN-3.5 allow up to 5000 samples; older versions up to 1000). No GPU? Use our free hosted inference via TabPFN Client.
On macOS: GPU support is automatically included for Apple Silicon Macs. For best performance, ensure you are using PyTorch 2.13 or newer (see #949).
On Linux: Nvidia GPU support is automatically included. For AMD GPUs, first install PyTorch with ROCm, then install TabPFN. For example,
pip install torch --index-url https://download.pytorch.org/whl/rocm7.2
pip install tabpfn
For a CPU-only install, first install CPU-only PyTorch, then install TabPFN. This saves disk space if you do not have a GPU.
On Windows: For Nvidia GPUs, install PyTorch with CUDA, then install TabPFN. For AMD GPUs, install PyTorch with ROCm, then install TabPFN.
To use our default TabPFN-3.5 model:
from tabpfn import TabPFNClassifier, TabPFNRegressor
clf = TabPFNClassifier()
clf.fit(X_train, y_train) # downloads checkpoint on first use
predictions = clf.predict(X_test)
reg = TabPFNRegressor()
reg.fit(X_train, y_train) # downloads checkpoint on first use
predictions = reg.predict(X_test)
To use the smaller, faster TabPFN-3.5-Fast you can use ModelVersion.V3_5_FAST or "v3.5-fast".
from tabpfn.constants import ModelVersion
classifier = TabPFNClassifier.create_default_for_version(ModelVersion.V3_5_FAST)
regressor = TabPFNRegressor.create_default_for_version(ModelVersion.V3_5_FAST)
To use other model versions (e.g. the previous default, TabPFN-3):
classifier = TabPFNClassifier.create_default_for_version(ModelVersion.V3)
regressor = TabPFNRegressor.create_default_for_version(ModelVersion.V3)
For complete examples, see the tabpfn_for_binary_classification.py, tabpfn_for_multiclass_classification.py, and tabpfn_for_regression.py files.
Choose the right TabPFN implementation for your needs:
TabPFN Client Simple API client for using TabPFN via cloud-based inference.
TabPFN Extensions Community extensions and integrations, including:
interpretability: Gain insights with SHAP-based explanations, feature importance, and selection tools.unsupervised: Tools for outlier detection and synthetic tabular data generation.embeddings: Extract and use TabPFN's internal learned embeddings for downstream tasks or analysis.many_class: Handle multi-class classification problems that exceed TabPFN's built-in class limit.To install:
pip install tabpfn-extensions
TabPFN (this repo) Core implementation for fast and local inference with PyTorch and CUDA support.
TabPFN UX No-code graphical interface to explore TabPFN capabilities—ideal for business users and prototyping.
The code in this repository is licensed under the Apache License 2.0. Third-party code is subject to its own licenses and attribution requirements; see Third-Party Notices.
Model weights are licensed separately.
The TabPFN-2.5, TabPFN-2.6, TabPFN-3 and TabPFN-3.5 model weights are released under non-commercial licenses (TabPFN-3.5 license, TabPFN-3 license; see the Models page for prior releases). TabPFN-3.5 is used by default.
The TabPFN-2 model weights are licensed under the Prior Labs License (Apache 2.0 with an additional attribution requirement): classifier license, regressor license. To use the v2 model weights, instantiate your model as follows:
from tabpfn import TabPFNRegressor
from tabpfn.constants import ModelVersion
tabpfn_v2 = TabPFNRegressor.create_default_for_version(ModelVersion.V2)
For high-throughput or massive-scale production environments, we offer an Enterprise Edition with the following capabilities:
To learn more or request a commercial license, please contact us at [email protected].
We're building the future of tabular machine learning and would love your involvement:
Connect & Learn:
Contribute:
Stay Updated: Star the repo and join Discord for the latest updates
[!IMPORTANT] Open an issue before starting work on a PR.
If there's a feature you'd like to add or a bug you've found, please open a GitHub issue with a high-level sketch of your plan. This lets us give feedback on the approach before you invest the effort, saving everyone time and increasing the chance your change lands.
There are many reasons a PR may not be mergeable — design fit, scope, compatibility, planned refactors, etc. — and these are often hard to spot from the outside, especially for a first-time contributor.
You can read our paper explaining TabPFNv2 here, and model reports for TabPFN-2.5 and TabPFN-3.
BibTeX…
predict call recomputes the training set. Calling predict on 100 samples separately is almost 100 times slower and more expensive than a single call. If the test set is very large, split it into chunks of 1000 samples each.Recommended row and feature limits vary by checkpoint — see the Models page for the per-release limits. As a quick reference, the current default (TabPFN-3.5, and TabPFN-3.5-Fast) accepts up to 1,000,000 rows and 20,000 features. If your dataset exceeds the recommended limits for your checkpoint, you can subsample, set ignore_pretraining_limits=True to push past the size guardrail, or upgrade to a release with a higher limit.
TabPFN requires Python 3.10+ due to newer language features. Compatible versions: 3.10, 3.11, 3.12, 3.13, 3.14.
On first use, TabPFN will automatically open a browser window where you can log in via PriorLabs and accept the license terms. Your authentication token is cached locally so you only need to do this once.
For headless / CI environments where a browser is not available, visit https://ux.priorlabs.ai, go to the License tab to accept the license, and then set the TABPFN_TOKEN environment variable with a token obtained from your account.
If access via the browser-based flow is not an option for you, please contact us at [email protected].
TabPFN automatically downloads model weights when first used. For offline usage:
Using the Provided Download Script
If you have the TabPFN repository, you can use the included script to download all models (including ensemble variants):
# After installing TabPFN
python scripts/download_all_models.py
This script will download the main classifier and regressor models, as well as all ensemble variant models to your system's default cache directory.
Manual Download
Download the model files manually from HuggingFace:
Place the file in one of these locations:
TabPFNClassifier(model_path="/path/to/model.ckpt")export TABPFN_MODEL_CACHE_DIR="/path/to/dir" (see environment variables FAQ below)%APPDATA%\tabpfn\~/Library/Caches/tabpfn/~/.cache/tabpfn/pickle error when loading the model. What should I do?Try the following:
pip install tabpfn --upgradeTabPFN uses Pydantic settings for configuration, supporting environment variables and .env files:
Authentication:
TABPFN_TOKEN: Provide a PriorLabs authentication token directly (useful for headless/CI environments). Obtain one from [https://ux.priorlab暂无开放 Issues,或尚未同步最近议题。