LightPFN 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,16 @@
1
+ __pycache__/
2
+ *.pyc
3
+ *.egg-info/
4
+ dist/
5
+ build/
6
+ .pytest_cache/
7
+ .venv/
8
+ # training and evaluation outputs
9
+ data/
10
+ runs/
11
+ *.pt
12
+ *.safetensors
13
+ # LaTeX build files (the PDF is tracked)
14
+ paper/*.aux
15
+ paper/*.log
16
+ paper/*.out
lightpfn-1.0.0/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
lightpfn-1.0.0/NOTICE ADDED
@@ -0,0 +1,11 @@
1
+ LightPFN
2
+ Copyright 2026 Giorgio Ottoboni
3
+
4
+ This product includes software and model weights licensed under the Apache License, Version 2.0.
5
+
6
+ The model was trained from scratch on synthetic data only, without distillation and without weights or
7
+ outputs of other tabular foundation models.
8
+
9
+ The optional training code (lightpfn.prior) uses the structural causal model prior of TabICL
10
+ (https://github.com/soda-inria/tabicl, BSD-3-Clause, Copyright (c) 2025, Soda team @ Inria) as an installed
11
+ dependency; TabICL code is not redistributed in this repository or in the published wheel.
@@ -0,0 +1,298 @@
1
+ Metadata-Version: 2.5
2
+ Name: LightPFN
3
+ Version: 1.0.0
4
+ Summary: A 4.6M-parameter tabular classifier pretrained only on synthetic data, with a scikit-learn API and CPU, CUDA/ROCm and Vulkan inference
5
+ Project-URL: Homepage, https://github.com/GioOtto/LightPFN
6
+ Project-URL: Documentation, https://github.com/GioOtto/LightPFN/blob/main/docs/en/GUIDE.md
7
+ Project-URL: Paper, https://github.com/GioOtto/LightPFN/blob/main/paper/LightPFN_report.pdf
8
+ Project-URL: Weights, https://huggingface.co/ueuegio/LightPFN
9
+ Project-URL: Issues, https://github.com/GioOtto/LightPFN/issues
10
+ Author-email: Giorgio Ottoboni <247403232+GioOtto@users.noreply.github.com>
11
+ License-Expression: Apache-2.0
12
+ License-File: LICENSE
13
+ License-File: NOTICE
14
+ Keywords: classification,foundation model,in-context learning,scikit-learn,tabpfn,tabular,vulkan
15
+ Classifier: Development Status :: 4 - Beta
16
+ Classifier: Intended Audience :: Developers
17
+ Classifier: Intended Audience :: Science/Research
18
+ Classifier: Operating System :: OS Independent
19
+ Classifier: Programming Language :: Python :: 3
20
+ Classifier: Programming Language :: Python :: 3.10
21
+ Classifier: Programming Language :: Python :: 3.11
22
+ Classifier: Programming Language :: Python :: 3.12
23
+ Classifier: Programming Language :: Python :: 3.13
24
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
25
+ Requires-Python: >=3.10
26
+ Requires-Dist: huggingface-hub>=0.27
27
+ Requires-Dist: numpy>=1.24
28
+ Requires-Dist: safetensors>=0.5
29
+ Requires-Dist: scikit-learn>=1.6
30
+ Requires-Dist: torch>=2.6
31
+ Provides-Extra: dev
32
+ Requires-Dist: build>=1.2; extra == 'dev'
33
+ Requires-Dist: pandas>=2.0; extra == 'dev'
34
+ Requires-Dist: pytest>=8; extra == 'dev'
35
+ Provides-Extra: eval
36
+ Requires-Dist: catboost>=1.2; extra == 'eval'
37
+ Requires-Dist: joblib>=1.3; extra == 'eval'
38
+ Requires-Dist: lightgbm>=4.0; extra == 'eval'
39
+ Requires-Dist: openml>=0.15; extra == 'eval'
40
+ Requires-Dist: pandas>=2.0; extra == 'eval'
41
+ Requires-Dist: threadpoolctl>=3.1; extra == 'eval'
42
+ Requires-Dist: xgboost>=2.0; extra == 'eval'
43
+ Provides-Extra: train
44
+ Requires-Dist: pandas>=2.0; extra == 'train'
45
+ Requires-Dist: scipy>=1.11; extra == 'train'
46
+ Requires-Dist: tabicl==2.2.0; extra == 'train'
47
+ Requires-Dist: threadpoolctl>=3.1; extra == 'train'
48
+ Provides-Extra: vulkan
49
+ Requires-Dist: wgpu<0.33,>=0.32; extra == 'vulkan'
50
+ Description-Content-Type: text/markdown
51
+
52
+ <div align="center">
53
+ <img src="https://raw.githubusercontent.com/GioOtto/LightPFN/main/docs/assets/logo.svg" width="112" height="112" alt="LightPFN logo: a small table with one highlighted cell" />
54
+ <h1>LightPFN</h1>
55
+ <p><strong>A 4.6M-parameter tabular foundation model for classification.</strong></p>
56
+ <p>Pretrained only on synthetic data. A scikit-learn classifier that runs on CPU, CUDA, ROCm and any Vulkan GPU.</p>
57
+
58
+ <p>
59
+ <a href="https://pypi.org/project/LightPFN/"><img alt="PyPI" src="https://img.shields.io/pypi/v/lightpfn?style=for-the-badge&color=111111&label=PyPI" /></a>
60
+ <a href="https://huggingface.co/ueuegio/LightPFN"><img alt="Weights on Hugging Face" src="https://img.shields.io/badge/Weights-Hugging%20Face-111111?style=for-the-badge&logo=huggingface&logoColor=white" /></a>
61
+ <a href="https://github.com/GioOtto/LightPFN/blob/main/paper/LightPFN_report.pdf"><img alt="Technical report (PDF)" src="https://img.shields.io/badge/Technical%20report-PDF-8B1A1A?style=for-the-badge&logo=adobeacrobatreader&logoColor=white" /></a>
62
+ </p>
63
+
64
+ <p>
65
+ <a href="https://github.com/GioOtto/LightPFN/blob/main/docs/en/GUIDE.md">User guide</a> &nbsp;&nbsp;
66
+ <a href="https://github.com/GioOtto/LightPFN/blob/main/docs/en/RESULTS.md">Results</a> &nbsp;&nbsp;
67
+ <a href="https://github.com/GioOtto/LightPFN/blob/main/docs/en/VULKAN.md">Vulkan backend</a> &nbsp;&nbsp;
68
+ <a href="https://github.com/GioOtto/LightPFN/blob/main/docs/en/TRAINING.md">Training</a> &nbsp;&nbsp;
69
+ <a href="https://github.com/GioOtto/LightPFN/issues">Issues</a>
70
+ </p>
71
+ <p><img alt="Python 3.10+" src="https://img.shields.io/badge/python-3.10%2B-181818" /> <img alt="4.6M parameters" src="https://img.shields.io/badge/parameters-4.6M-181818" /> <img alt="Code and weights Apache 2.0" src="https://img.shields.io/badge/code%20%2B%20weights-Apache%202.0-181818" /> <img alt="Trained only on synthetic data" src="https://img.shields.io/badge/training%20data-synthetic%20only-181818" /></p>
72
+ <p><strong>English</strong> &nbsp; <a href="https://github.com/GioOtto/LightPFN/blob/main/README.it.md">Italiano</a></p>
73
+ </div>
74
+
75
+ ## What it is
76
+
77
+ LightPFN is a prior-data fitted network: a transformer pretrained once on millions of synthetic
78
+ classification tasks. At `fit` it stores your training set as context; at `predict_proba` it reads that
79
+ context and the test rows in one forward pass. It does not train on your data and requires no tuning.
80
+
81
+ ```python
82
+ from lightpfn import LightPFNClassifier
83
+
84
+ clf = LightPFNClassifier(n_estimators=4).fit(X_train, y_train)
85
+ proba = clf.predict_proba(X_test)
86
+ ```
87
+
88
+ - **Small.** 4,603,088 parameters, 18 MB of weights, designed for a commodity CPU. TabICLv2 has six
89
+ times as many.
90
+ - **Accurate without tuning.** On 55 OpenML datasets outside TabArena, mean AUC 0.911: 0.86 points above
91
+ default CatBoost and 1.8 to 2.1 points above default LightGBM, XGBoost and random forest. On the 38
92
+ TabArena classification tasks, lower error than default CatBoost on 76% of the tasks.
93
+ - **Any GPU.** CUDA and ROCm through PyTorch, and a Vulkan backend with its own WGSL compute kernels for
94
+ AMD, Intel and NVIDIA GPUs on Linux and Windows, with no CUDA or ROCm install. On an RX 7900 XT it is
95
+ 6 to 10 times faster than a 16-thread CPU.
96
+ - **scikit-learn API.** `Pipeline`, `GridSearchCV`, `clone`, `cross_val_score`, and pandas DataFrames
97
+ with categorical, string, boolean and missing values.
98
+ - **Open.** Code, weights and the full training pipeline under Apache 2.0. Trained from scratch: no
99
+ distillation, no weights or outputs of other tabular foundation models.
100
+
101
+ ## Benchmarks
102
+
103
+ **TabArena-Lite, official pipeline, 38 classification datasets, 99 methods** (8 October 2026).
104
+ LightPFN uses its default configuration with four estimators, eight-fold bagging and the official validation
105
+ protocol. All 38 tasks succeeded, none imputed. **25th of 99, Elo 1420 (+67 / -66)**.
106
+
107
+ | Method | Elo | 95% CI |
108
+ |---|---:|---:|
109
+ | TabICLv2 (default) | 1558 | +77 / -68 |
110
+ | TabDPT-1.3 (default) | 1467 | +78 / -54 |
111
+ | RealMLP (tuned + ensembled) | 1459 | +50 / -47 |
112
+ | **LightPFN (default)** | **1420** | **+67 / -66** |
113
+ | CatBoost (tuned) | 1378 | +58 / -55 |
114
+ | CatBoost (tuned + ensembled) | 1370 | +58 / -48 |
115
+ | LightGBM (tuned + ensembled) | 1365 | +52 / -42 |
116
+ | XGBoost (tuned + ensembled) | 1346 | +58 / -62 |
117
+ | CatBoost (default) | 1339 | +49 / -52 |
118
+ | XGBoost (default) | 1191 | +57 / -69 |
119
+ | LightGBM (default) | 1144 | +59 / -63 |
120
+ | RandomForest (default) | 1000 | +71 / -84 |
121
+
122
+ <p align="center"><img src="https://raw.githubusercontent.com/GioOtto/LightPFN/main/docs/assets/tabarena_lite_pareto.png" width="100%" alt="TabArena-Lite: Elo against fit time, LightPFN highlighted among foundation models" /></p>
123
+
124
+ The point estimate is above every GBDT in this leaderboard, including tuned and ensembled entries; the intervals
125
+ with tuned CatBoost overlap, so this does not establish a clear win. TabICLv2 and larger foundation models
126
+ lead. Median fit time is 0.65 s per 1,000 rows on the RX 7900 XT; among entries with at least its Elo, only
127
+ TabDPT-1.3 has a lower reported time. Leaderboard timings come from different hardware. This is an author-run
128
+ Lite evaluation; TabArena maintainers re-run the full benchmark before leaderboard inclusion.
129
+ [Protocol, results and artifacts](https://github.com/GioOtto/LightPFN/blob/main/docs/en/RESULTS.md).
130
+
131
+ ## Install
132
+
133
+ ```bash
134
+ pip install LightPFN # CPU, CUDA or ROCm, through your PyTorch install
135
+ pip install "LightPFN[vulkan]" # adds the Vulkan GPU backend (wgpu)
136
+ ```
137
+
138
+ Python 3.10 or newer. The first `fit` downloads the weights (18 MB) from
139
+ [Hugging Face](https://huggingface.co/ueuegio/LightPFN) at a pinned commit and caches them. On a CPU-only
140
+ machine, install PyTorch from its CPU index first to skip the CUDA libraries:
141
+ `pip install torch --index-url https://download.pytorch.org/whl/cpu`.
142
+
143
+ ## Quick start
144
+
145
+ ```python
146
+ from sklearn.datasets import load_breast_cancer
147
+ from sklearn.metrics import roc_auc_score
148
+ from sklearn.model_selection import train_test_split
149
+
150
+ from lightpfn import LightPFNClassifier
151
+
152
+ X, y = load_breast_cancer(return_X_y=True)
153
+ X_train, X_test, y_train, y_test = train_test_split(X, y, stratify=y, random_state=0)
154
+
155
+ clf = LightPFNClassifier(n_estimators=4, random_state=0)
156
+ clf.fit(X_train, y_train)
157
+ print(roc_auc_score(y_test, clf.predict_proba(X_test)[:, 1]))
158
+ ```
159
+
160
+ A pandas DataFrame with categorical and missing values goes in as it is:
161
+
162
+ ```python
163
+ import pandas as pd
164
+
165
+ df = pd.DataFrame({
166
+ "age": [34, 51, None, 28, 45, 39],
167
+ "plan": ["basic", "pro", "pro", None, "basic", "enterprise"],
168
+ "region": pd.Categorical(["north", "south", "south", "east", "north", "east"]),
169
+ "active": [True, False, True, True, False, True],
170
+ })
171
+ y = [0, 1, 1, 0, 1, 0]
172
+ clf = LightPFNClassifier().fit(df, y)
173
+ clf.predict_proba(df.head(2))
174
+ ```
175
+
176
+ Columns of category, string, object or bool dtype become ordinal codes of the categories seen in `fit`.
177
+ A category dtype keeps its declared levels, including unused ones. Missing values and values outside
178
+ that vocabulary become NaN, which the model handles natively. More in
179
+ [examples/](https://github.com/GioOtto/LightPFN/tree/main/examples/) and in the [user guide](https://github.com/GioOtto/LightPFN/blob/main/docs/en/GUIDE.md).
180
+
181
+ ## Devices
182
+
183
+ | `device=` | Runs on |
184
+ |---|---|
185
+ | `"auto"` (default) | a CUDA or ROCm GPU through PyTorch, else a Vulkan GPU, else the CPU |
186
+ | `"cpu"` | the CPU, through PyTorch |
187
+ | `"cuda"`, `"cuda:1"` | an NVIDIA (CUDA) or AMD (ROCm) GPU through PyTorch |
188
+ | `"vulkan"`, `"vulkan:1"` | any GPU with a Vulkan driver, through `lightpfn.vulkan` (needs `lightpfn[vulkan]`) |
189
+
190
+ The environment variable `LIGHTPFN_DEVICE` replaces `"auto"`. Every device returns the same probabilities
191
+ up to floating-point rounding (within 3e-5). See the [Vulkan backend](https://github.com/GioOtto/LightPFN/blob/main/docs/en/VULKAN.md).
192
+
193
+ ## When to use it
194
+
195
+ LightPFN is a good default for classification tables with 2 to 10 classes and up to tens of thousands of
196
+ rows, when you want a strong model without tuning. Know its limits:
197
+
198
+ - **Classification only**, 2 to 10 classes. Regression comes with version 2.
199
+ - **Large tables.** Above `max_context` rows (default 20,000) each estimator reads a stratified subsample.
200
+ In the report, with the whole training set as context, its mean AUC is level with default CatBoost
201
+ up to 100,000 rows. Larger contexts cost more; sizes beyond 100,000 were not evaluated.
202
+ - **Categorical columns** are read as ordinal codes. On tables dominated by high-cardinality categorical
203
+ columns, CatBoost is ahead (by up to 4.5 AUC points on two TabArena tasks).
204
+ - **CPU time grows with the context.** On TabArena, four estimators take a median of 1 s per split on small
205
+ tables, 15 s on medium and 54 s on large ones, against 3, 4 and 7 s for CatBoost. When time matters, use a
206
+ GPU or `n_estimators=1` (about four times faster, slightly less accurate).
207
+
208
+ ## Results
209
+
210
+ Baselines at default settings. Differences in AUC points (100 times the AUC difference) with 95% paired
211
+ bootstrap intervals. Full tables, per-task results and timings: [docs/en/RESULTS.md](https://github.com/GioOtto/LightPFN/blob/main/docs/en/RESULTS.md).
212
+
213
+ **55 OpenML-CC18 datasets outside TabArena** (at most 1,000 rows and 100 features, five-fold
214
+ cross-validation, one estimator):
215
+
216
+ | Model | Mean AUC | LightPFN minus model |
217
+ |---|---:|---:|
218
+ | **LightPFN** | **0.911** | |
219
+ | CatBoost | 0.902 | +0.86 [0.42, 1.40] |
220
+ | Random forest | 0.893 | +1.76 |
221
+ | LightGBM | 0.891 | +2.02 |
222
+ | XGBoost (54 datasets: its wrapper fails on one) | 0.889 | +2.06 [1.32, 2.94] |
223
+
224
+ **TabArena, 38 classification tasks** (official splits, first repeat, run with our own harness, which is
225
+ not the official leaderboard protocol):
226
+
227
+ | Model | Mean AUC | Mean rank of 7 | Lower error than CatBoost |
228
+ |---|---:|---:|---:|
229
+ | TabICLv2 (28M parameters, GPU) | 0.864 | 1.58 | 87% |
230
+ | **LightPFN, 4 estimators** | **0.858** | **2.50** | **76%** |
231
+ | LightPFN, 1 estimator | 0.857 | 3.37 | 68% |
232
+ | CatBoost | 0.855 | 3.50 | |
233
+ | LightGBM | 0.844 | 5.34 | 5% |
234
+ | Random forest | 0.838 | 5.89 | 3% |
235
+ | XGBoost | 0.833 | 5.82 | 11% |
236
+
237
+ ## How it works
238
+
239
+ <p align="center"><img src="https://raw.githubusercontent.com/GioOtto/LightPFN/main/docs/assets/architecture.png" width="100%" alt="LightPFN architecture: cell embedding, two column stages, row refinement and compression, in-context learning, retrieval decoder" /></p>
240
+
241
+ Each cell is embedded from its value, its rank in the column and a missing-value flag. Two column stages
242
+ with induced attention read the labelled context of each column. A row stage with four summary tokens mixes
243
+ the features of each row and compresses it into one vector. Seven in-context blocks let every test row
244
+ attend to the training rows, and a retrieval decoder turns the attention into a vote over the training
245
+ labels.
246
+
247
+ Pretraining used 7.68 million task draws from 4.03 million distinct synthetic tasks: 90% from a structural causal graph prior and 10% from a rule
248
+ prior (XOR, parity, lookup tables, trees) that teaches feature interactions. A second stage trained on
249
+ tables of up to 60,000 rows. The [technical report](https://github.com/GioOtto/LightPFN/blob/main/paper/LightPFN_report.pdf) describes the model, the
250
+ priors and the selection protocol; [docs/en/TRAINING.md](https://github.com/GioOtto/LightPFN/blob/main/docs/en/TRAINING.md) explains how to reproduce
251
+ the training.
252
+
253
+ ## Roadmap
254
+
255
+ Version 2 will add:
256
+
257
+ - **Native categorical features.** The model will see the categorical mask from the start of pretraining,
258
+ and the prior will contain high-cardinality categorical columns whose many rare levels each carry a small
259
+ effect. An adapter trained on top of the frozen v1 weights did not help, because the v1 prior has no such
260
+ columns to learn from (report, Section 12).
261
+ - **Regression.**
262
+
263
+ ## Repository layout
264
+
265
+ | Path | Content |
266
+ |---|---|
267
+ | `lightpfn/` | the package: model, scikit-learn wrapper, devices, Vulkan backend (`vulkan/`), and the training code: priors (`prior/`), trainer (`train.py`), evaluation harness (`eval/`) |
268
+ | `tests/` | unit and equivalence tests (CPU; the Vulkan tests also run on a CPU driver) |
269
+ | `examples/` | runnable examples |
270
+ | `docs/` | user guide, results, Vulkan backend and training in English (`en/`) and Italian (`it/`), changelog, third-party licenses |
271
+ | `paper/` | technical report: PDF, LaTeX source, figures and plot data |
272
+
273
+ The published wheel contains only the inference code; training needs a source checkout
274
+ (`pip install -e ".[train,eval]"`).
275
+
276
+ ## Contributing and support
277
+
278
+ Bug reports and focused pull requests are welcome: see [CONTRIBUTING](https://github.com/GioOtto/LightPFN/blob/main/.github/CONTRIBUTING.md). Security
279
+ issues go through [SECURITY](https://github.com/GioOtto/LightPFN/blob/main/.github/SECURITY.md). Changes between versions are in
280
+ [CHANGELOG](https://github.com/GioOtto/LightPFN/blob/main/docs/CHANGELOG.md).
281
+
282
+ ## Citation
283
+
284
+ ```bibtex
285
+ @techreport{ottoboni2026lightpfn,
286
+ title = {A Sling Against Giants: {LightPFN}, a 4.6M-parameter tabular in-context classifier designed to stay small},
287
+ author = {Ottoboni, Giorgio},
288
+ year = {2026},
289
+ url = {https://github.com/GioOtto/LightPFN}
290
+ }
291
+ ```
292
+
293
+ GitHub's "Cite this repository" button reads [CITATION.cff](https://github.com/GioOtto/LightPFN/blob/main/CITATION.cff).
294
+
295
+ ## License
296
+
297
+ Code and weights: [Apache License 2.0](https://github.com/GioOtto/LightPFN/blob/main/LICENSE), with the attribution notice in [NOTICE](https://github.com/GioOtto/LightPFN/blob/main/NOTICE).
298
+ Dependencies keep their own licenses, listed in [THIRD_PARTY_LICENSES](https://github.com/GioOtto/LightPFN/blob/main/docs/THIRD_PARTY_LICENSES.md).