predict. The fit_with_cache mode does that work once, during fit, and caches the result, so the first prediction is noticeably faster. This short notebook benchmarks the two modes side by side on the same data.
Setup
Installing TabPFN and scikit-learn.Imports
The classifier, a dataset, and timing utilities.Authenticating with a Token
SettingTABPFN_TOKEN so the weights can be downloaded.
Data and Split
A synthetic 5,000-row classification set; a small test slice keeps prediction quick.The Benchmark Function
Timing fit and predict.benchmark_tabpfn fits, times the first prediction. The first prediction is where the cache pays off.
With and Without the Cache
Comparing default mode againstfit_with_cache.
The baseline recomputes the training representation at predict time. With fit_with_cache, that work happens during fit, so the first prediction is faster.