AlphaPFN 0.0.1__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.
- alphapfn-0.0.1/.gitignore +29 -0
- alphapfn-0.0.1/CITATION.cff +69 -0
- alphapfn-0.0.1/LICENSE +21 -0
- alphapfn-0.0.1/PKG-INFO +160 -0
- alphapfn-0.0.1/README.md +102 -0
- alphapfn-0.0.1/RELEASING.md +67 -0
- alphapfn-0.0.1/alphapfn/__init__.py +17 -0
- alphapfn-0.0.1/alphapfn/api.py +437 -0
- alphapfn-0.0.1/alphapfn/checkpoints.py +164 -0
- alphapfn-0.0.1/alphapfn/loader.py +194 -0
- alphapfn-0.0.1/alphapfn/model/__init__.py +0 -0
- alphapfn-0.0.1/alphapfn/model/bar_distribution.py +862 -0
- alphapfn-0.0.1/alphapfn/model/encoders.py +795 -0
- alphapfn-0.0.1/alphapfn/model/layer.py +368 -0
- alphapfn-0.0.1/alphapfn/model/layer_norm.py +83 -0
- alphapfn-0.0.1/alphapfn/model/mlp.py +141 -0
- alphapfn-0.0.1/alphapfn/model/multi_head_attention.py +762 -0
- alphapfn-0.0.1/alphapfn/model/save_peak_memory.py +91 -0
- alphapfn-0.0.1/alphapfn/model/transformer.py +717 -0
- alphapfn-0.0.1/alphapfn/priors/__init__.py +1 -0
- alphapfn-0.0.1/alphapfn/priors/alphapfn_model.py +72 -0
- alphapfn-0.0.1/alphapfn/priors/base_model.py +133 -0
- alphapfn-0.0.1/alphapfn/priors/prior.py +100 -0
- alphapfn-0.0.1/alphapfn/priors/utils.py +3 -0
- alphapfn-0.0.1/alphapfn/utils.py +329 -0
- alphapfn-0.0.1/examples/bo_with_optimize_acqf.py +79 -0
- alphapfn-0.0.1/pyproject.toml +82 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
__pycache__/
|
|
2
|
+
*.pyc
|
|
3
|
+
*.pyo
|
|
4
|
+
*.pyd
|
|
5
|
+
.Python
|
|
6
|
+
*.egg-info/
|
|
7
|
+
*.egg
|
|
8
|
+
dist/
|
|
9
|
+
build/
|
|
10
|
+
|
|
11
|
+
# checkpoints (workspace local; eventually fetched from HF Hub)
|
|
12
|
+
*.pt
|
|
13
|
+
*.pth
|
|
14
|
+
*.safetensors
|
|
15
|
+
final_models/
|
|
16
|
+
checkpoints/
|
|
17
|
+
|
|
18
|
+
# uv venv
|
|
19
|
+
.venv/
|
|
20
|
+
|
|
21
|
+
# wandb / experiment tracking
|
|
22
|
+
wandb/
|
|
23
|
+
|
|
24
|
+
# editors
|
|
25
|
+
.vscode/
|
|
26
|
+
.idea/
|
|
27
|
+
|
|
28
|
+
# notebooks
|
|
29
|
+
.ipynb_checkpoints/
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
cff-version: 1.2.0
|
|
2
|
+
message: "If you use this software, please cite the paper below."
|
|
3
|
+
title: "alphapfn: Fast Entropy Search via In-Context Learning"
|
|
4
|
+
abstract: >-
|
|
5
|
+
Lightweight package for α-PFN, a Prior-Fitted Network that amortizes
|
|
6
|
+
information-theoretic acquisition functions (PES, MES, JES) for
|
|
7
|
+
Bayesian Optimization. α-PFN replaces the slow Monte-Carlo sampling
|
|
8
|
+
used by classical entropy-search methods with a single transformer
|
|
9
|
+
forward pass.
|
|
10
|
+
type: software
|
|
11
|
+
version: 0.0.1
|
|
12
|
+
license: MIT
|
|
13
|
+
repository-code: "https://github.com/automl/AlphaPFN"
|
|
14
|
+
url: "https://github.com/automl/AlphaPFN"
|
|
15
|
+
keywords:
|
|
16
|
+
- bayesian-optimization
|
|
17
|
+
- entropy-search
|
|
18
|
+
- prior-fitted-networks
|
|
19
|
+
- pfn
|
|
20
|
+
- in-context-learning
|
|
21
|
+
- amortized-inference
|
|
22
|
+
- acquisition-function
|
|
23
|
+
authors:
|
|
24
|
+
- family-names: "Rakotoarison"
|
|
25
|
+
given-names: "Herilalaina"
|
|
26
|
+
email: "rakoheri@ad.helsinki.fi"
|
|
27
|
+
affiliation: "University of Helsinki"
|
|
28
|
+
- family-names: "Adriaensen"
|
|
29
|
+
given-names: "Steven"
|
|
30
|
+
email: "adriaens@cs.uni-freiburg.de"
|
|
31
|
+
affiliation: "University of Freiburg"
|
|
32
|
+
- family-names: "Viering"
|
|
33
|
+
given-names: "Tom"
|
|
34
|
+
email: "t.j.viering@tudelft.nl"
|
|
35
|
+
affiliation: "Delft University of Technology"
|
|
36
|
+
- family-names: "Hvarfner"
|
|
37
|
+
given-names: "Carl"
|
|
38
|
+
affiliation: "Meta"
|
|
39
|
+
- family-names: "Müller"
|
|
40
|
+
given-names: "Samuel"
|
|
41
|
+
affiliation: "Meta"
|
|
42
|
+
- family-names: "Hutter"
|
|
43
|
+
given-names: "Frank"
|
|
44
|
+
affiliation: "Prior Labs / ELLIS Institute Tübingen / University of Freiburg"
|
|
45
|
+
- family-names: "Bakshy"
|
|
46
|
+
given-names: "Eytan"
|
|
47
|
+
affiliation: "Meta"
|
|
48
|
+
preferred-citation:
|
|
49
|
+
type: conference-paper
|
|
50
|
+
title: "α-PFN: Fast Entropy Search via In-Context Learning"
|
|
51
|
+
year: 2026
|
|
52
|
+
url: "https://openreview.net/forum?id=7Oonij8oLU"
|
|
53
|
+
conference:
|
|
54
|
+
name: "Forty-third International Conference on Machine Learning (ICML)"
|
|
55
|
+
authors:
|
|
56
|
+
- family-names: "Rakotoarison"
|
|
57
|
+
given-names: "Herilalaina"
|
|
58
|
+
- family-names: "Adriaensen"
|
|
59
|
+
given-names: "Steven"
|
|
60
|
+
- family-names: "Viering"
|
|
61
|
+
given-names: "Tom"
|
|
62
|
+
- family-names: "Hvarfner"
|
|
63
|
+
given-names: "Carl"
|
|
64
|
+
- family-names: "Müller"
|
|
65
|
+
given-names: "Samuel"
|
|
66
|
+
- family-names: "Hutter"
|
|
67
|
+
given-names: "Frank"
|
|
68
|
+
- family-names: "Bakshy"
|
|
69
|
+
given-names: "Eytan"
|
alphapfn-0.0.1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 AutoML-Freiburg-Hannover
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
alphapfn-0.0.1/PKG-INFO
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: AlphaPFN
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Fast Entropy Search via In-Context Learning (PFN-based amortized acquisition functions for Bayesian Optimization)
|
|
5
|
+
Project-URL: Homepage, https://github.com/automl/AlphaPFN
|
|
6
|
+
Project-URL: Repository, https://github.com/automl/AlphaPFN
|
|
7
|
+
Project-URL: Issues, https://github.com/automl/AlphaPFN/issues
|
|
8
|
+
Project-URL: Paper, https://openreview.net/forum?id=7Oonij8oLU
|
|
9
|
+
Author: Herilalaina Rakotoarison, Steven Adriaensen, Tom Viering, Carl Hvarfner, Samuel Müller, Frank Hutter, Eytan Bakshy
|
|
10
|
+
Maintainer-email: Herilalaina Rakotoarison <rkt.herilalaina@gmail.com>
|
|
11
|
+
License: MIT License
|
|
12
|
+
|
|
13
|
+
Copyright (c) 2026 AutoML-Freiburg-Hannover
|
|
14
|
+
|
|
15
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
16
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
17
|
+
in the Software without restriction, including without limitation the rights
|
|
18
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
19
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
20
|
+
furnished to do so, subject to the following conditions:
|
|
21
|
+
|
|
22
|
+
The above copyright notice and this permission notice shall be included in all
|
|
23
|
+
copies or substantial portions of the Software.
|
|
24
|
+
|
|
25
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
26
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
27
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
28
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
29
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
30
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
31
|
+
SOFTWARE.
|
|
32
|
+
License-File: LICENSE
|
|
33
|
+
Keywords: acquisition-function,amortized-inference,bayesian-optimization,entropy-search,in-context-learning,pfn,prior-fitted-networks,pytorch
|
|
34
|
+
Classifier: Development Status :: 3 - Alpha
|
|
35
|
+
Classifier: Intended Audience :: Science/Research
|
|
36
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
37
|
+
Classifier: Operating System :: OS Independent
|
|
38
|
+
Classifier: Programming Language :: Python :: 3
|
|
39
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
40
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
41
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
42
|
+
Classifier: Topic :: Scientific/Engineering
|
|
43
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
44
|
+
Classifier: Topic :: Scientific/Engineering :: Mathematics
|
|
45
|
+
Requires-Python: >=3.10
|
|
46
|
+
Requires-Dist: einops
|
|
47
|
+
Requires-Dist: gpytorch>=1.5.0
|
|
48
|
+
Requires-Dist: networkx
|
|
49
|
+
Requires-Dist: numpy<2.0,>=1.21.2
|
|
50
|
+
Requires-Dist: packaging
|
|
51
|
+
Requires-Dist: platformdirs
|
|
52
|
+
Requires-Dist: safetensors
|
|
53
|
+
Requires-Dist: torch>=1.9.0
|
|
54
|
+
Requires-Dist: typing-extensions
|
|
55
|
+
Provides-Extra: botorch
|
|
56
|
+
Requires-Dist: botorch>=0.15.0; extra == 'botorch'
|
|
57
|
+
Description-Content-Type: text/markdown
|
|
58
|
+
|
|
59
|
+
# $\alpha$-PFN: Fast Entropy Search via In-Context Learning
|
|
60
|
+
|
|
61
|
+
[](https://pypi.org/project/AlphaPFN/)
|
|
62
|
+
[](https://www.python.org/downloads/)
|
|
63
|
+
[](LICENSE)
|
|
64
|
+
[](https://openreview.net/forum?id=7Oonij8oLU)
|
|
65
|
+
[](https://colab.research.google.com/github/automl/AlphaPFN/blob/main/examples/quickstart.ipynb)
|
|
66
|
+
|
|
67
|
+
**$\alpha$-PFN** is a Prior-Fitted Network that amortizes information-theoretic acquisition functions. Supported acquisition functions: Predictive Entropy Search (PES), Max-value Entropy Search (MES), and Joint Entropy Search (JES).
|
|
68
|
+
|
|
69
|
+
<p align="center">
|
|
70
|
+
<img src="images/hero.gif" alt="Traditional GP-based Entropy Search samples optima via RFF and averages conditional entropies over N MC samples; α-PFN approximates the same acquisition in a single transformer forward pass.">
|
|
71
|
+
</p>
|
|
72
|
+
|
|
73
|
+
> To reproduce our ICML 2026 paper experiments, see branch
|
|
74
|
+
> [`icml2026`](https://github.com/automl/AlphaPFN/tree/icml2026).
|
|
75
|
+
|
|
76
|
+
## Install
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
pip install AlphaPFN
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Or from source:
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
git clone https://github.com/automl/AlphaPFN
|
|
86
|
+
cd AlphaPFN
|
|
87
|
+
uv sync
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Pretrained checkpoints (~20 MB) download automatically on the first `from_pretrained` call and cache under `~/.cache/alphapfn/`.
|
|
91
|
+
|
|
92
|
+
## Quick start
|
|
93
|
+
|
|
94
|
+
A self-contained 6D BO loop on Hartmann, using `botorch.optim.optimize_acqf`. Requires the `[botorch]` extra — `pip install "AlphaPFN[botorch]"`:
|
|
95
|
+
|
|
96
|
+
```python
|
|
97
|
+
import torch
|
|
98
|
+
from botorch.optim import optimize_acqf
|
|
99
|
+
from botorch.test_functions import Hartmann
|
|
100
|
+
from alphapfn import AlphaPFN
|
|
101
|
+
|
|
102
|
+
# 1. Objective on the unit cube (α-PFN maximizes — `negate=True` flips Hartmann's sign).
|
|
103
|
+
hartmann = Hartmann(dim=6, negate=True)
|
|
104
|
+
|
|
105
|
+
# 2. Initial design.
|
|
106
|
+
torch.manual_seed(0)
|
|
107
|
+
d, n_init, num_steps = 6, 6, 30
|
|
108
|
+
X = torch.rand(n_init, d, dtype=torch.double)
|
|
109
|
+
y = hartmann(X)
|
|
110
|
+
bounds = torch.stack([torch.zeros(d), torch.ones(d)]).double()
|
|
111
|
+
|
|
112
|
+
# 3. Load the pretrained acquisition; checkpoints download on first call.
|
|
113
|
+
acqf = AlphaPFN.from_pretrained(acquisition="JES")
|
|
114
|
+
|
|
115
|
+
# 4. BO loop.
|
|
116
|
+
for step in range(num_steps):
|
|
117
|
+
acqf.fit(X, y) # fit() standardizes y internally
|
|
118
|
+
X_next, _ = optimize_acqf(acqf, bounds=bounds, q=1,
|
|
119
|
+
num_restarts=10, raw_samples=128)
|
|
120
|
+
y_next = hartmann(X_next.squeeze(0))
|
|
121
|
+
X = torch.cat([X, X_next.detach().double()])
|
|
122
|
+
y = torch.cat([y, y_next.detach().double().reshape(1)])
|
|
123
|
+
print(f"step {step+1:>2}: best so far = {y.max().item():.4f}")
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Runnable version: [`examples/bo_with_optimize_acqf.py`](examples/bo_with_optimize_acqf.py)
|
|
127
|
+
or open the [Colab notebook](https://colab.research.google.com/github/automl/AlphaPFN/blob/main/examples/quickstart.ipynb).
|
|
128
|
+
|
|
129
|
+
## API
|
|
130
|
+
|
|
131
|
+
```python
|
|
132
|
+
AlphaPFN.from_pretrained(
|
|
133
|
+
acquisition: str | None = None, # "PES" (default), "MES", or "JES"
|
|
134
|
+
version: str = "v1",
|
|
135
|
+
*,
|
|
136
|
+
load_base_model: bool = False,
|
|
137
|
+
ucb_beta: float = 2.0,
|
|
138
|
+
strict: bool = True, # pass strict=False to skip input checks
|
|
139
|
+
)
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
Before fitting, prepare your data so that:
|
|
143
|
+
- **You are maximizing.** To minimize instead, negate your objective.
|
|
144
|
+
This is NOT checked, so forgetting it silently gives wrong results.
|
|
145
|
+
- **Each input feature lies in `[0, 1]`.** Rescale your search space accordingly.
|
|
146
|
+
|
|
147
|
+
`fit()` standardizes targets internally (`standardize_y=True` by default) — pass raw $y$. Pass `standardize_y=False` if you have already standardized. `strict=True` (default) validates the unit-cube contract on every `fit`/`forward`; pass `strict=False` to skip.
|
|
148
|
+
|
|
149
|
+
## Cite
|
|
150
|
+
|
|
151
|
+
```bibtex
|
|
152
|
+
@inproceedings{
|
|
153
|
+
rakotoarison2026alphapfn,
|
|
154
|
+
title={{$\alpha$}-PFN: Fast Entropy Search via In-Context Learning},
|
|
155
|
+
author={Rakotoarison, Herilalaina and Adriaensen, Steven and Viering, Tom and Hvarfner, Carl and M{\"u}ller, Samuel and Hutter, Frank and Bakshy, Eytan},
|
|
156
|
+
booktitle={Forty-third International Conference on Machine Learning},
|
|
157
|
+
year={2026},
|
|
158
|
+
url={https://openreview.net/forum?id=7Oonij8oLU}
|
|
159
|
+
}
|
|
160
|
+
```
|
alphapfn-0.0.1/README.md
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# $\alpha$-PFN: Fast Entropy Search via In-Context Learning
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/AlphaPFN/)
|
|
4
|
+
[](https://www.python.org/downloads/)
|
|
5
|
+
[](LICENSE)
|
|
6
|
+
[](https://openreview.net/forum?id=7Oonij8oLU)
|
|
7
|
+
[](https://colab.research.google.com/github/automl/AlphaPFN/blob/main/examples/quickstart.ipynb)
|
|
8
|
+
|
|
9
|
+
**$\alpha$-PFN** is a Prior-Fitted Network that amortizes information-theoretic acquisition functions. Supported acquisition functions: Predictive Entropy Search (PES), Max-value Entropy Search (MES), and Joint Entropy Search (JES).
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
<img src="images/hero.gif" alt="Traditional GP-based Entropy Search samples optima via RFF and averages conditional entropies over N MC samples; α-PFN approximates the same acquisition in a single transformer forward pass.">
|
|
13
|
+
</p>
|
|
14
|
+
|
|
15
|
+
> To reproduce our ICML 2026 paper experiments, see branch
|
|
16
|
+
> [`icml2026`](https://github.com/automl/AlphaPFN/tree/icml2026).
|
|
17
|
+
|
|
18
|
+
## Install
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
pip install AlphaPFN
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Or from source:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
git clone https://github.com/automl/AlphaPFN
|
|
28
|
+
cd AlphaPFN
|
|
29
|
+
uv sync
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Pretrained checkpoints (~20 MB) download automatically on the first `from_pretrained` call and cache under `~/.cache/alphapfn/`.
|
|
33
|
+
|
|
34
|
+
## Quick start
|
|
35
|
+
|
|
36
|
+
A self-contained 6D BO loop on Hartmann, using `botorch.optim.optimize_acqf`. Requires the `[botorch]` extra — `pip install "AlphaPFN[botorch]"`:
|
|
37
|
+
|
|
38
|
+
```python
|
|
39
|
+
import torch
|
|
40
|
+
from botorch.optim import optimize_acqf
|
|
41
|
+
from botorch.test_functions import Hartmann
|
|
42
|
+
from alphapfn import AlphaPFN
|
|
43
|
+
|
|
44
|
+
# 1. Objective on the unit cube (α-PFN maximizes — `negate=True` flips Hartmann's sign).
|
|
45
|
+
hartmann = Hartmann(dim=6, negate=True)
|
|
46
|
+
|
|
47
|
+
# 2. Initial design.
|
|
48
|
+
torch.manual_seed(0)
|
|
49
|
+
d, n_init, num_steps = 6, 6, 30
|
|
50
|
+
X = torch.rand(n_init, d, dtype=torch.double)
|
|
51
|
+
y = hartmann(X)
|
|
52
|
+
bounds = torch.stack([torch.zeros(d), torch.ones(d)]).double()
|
|
53
|
+
|
|
54
|
+
# 3. Load the pretrained acquisition; checkpoints download on first call.
|
|
55
|
+
acqf = AlphaPFN.from_pretrained(acquisition="JES")
|
|
56
|
+
|
|
57
|
+
# 4. BO loop.
|
|
58
|
+
for step in range(num_steps):
|
|
59
|
+
acqf.fit(X, y) # fit() standardizes y internally
|
|
60
|
+
X_next, _ = optimize_acqf(acqf, bounds=bounds, q=1,
|
|
61
|
+
num_restarts=10, raw_samples=128)
|
|
62
|
+
y_next = hartmann(X_next.squeeze(0))
|
|
63
|
+
X = torch.cat([X, X_next.detach().double()])
|
|
64
|
+
y = torch.cat([y, y_next.detach().double().reshape(1)])
|
|
65
|
+
print(f"step {step+1:>2}: best so far = {y.max().item():.4f}")
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Runnable version: [`examples/bo_with_optimize_acqf.py`](examples/bo_with_optimize_acqf.py)
|
|
69
|
+
or open the [Colab notebook](https://colab.research.google.com/github/automl/AlphaPFN/blob/main/examples/quickstart.ipynb).
|
|
70
|
+
|
|
71
|
+
## API
|
|
72
|
+
|
|
73
|
+
```python
|
|
74
|
+
AlphaPFN.from_pretrained(
|
|
75
|
+
acquisition: str | None = None, # "PES" (default), "MES", or "JES"
|
|
76
|
+
version: str = "v1",
|
|
77
|
+
*,
|
|
78
|
+
load_base_model: bool = False,
|
|
79
|
+
ucb_beta: float = 2.0,
|
|
80
|
+
strict: bool = True, # pass strict=False to skip input checks
|
|
81
|
+
)
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Before fitting, prepare your data so that:
|
|
85
|
+
- **You are maximizing.** To minimize instead, negate your objective.
|
|
86
|
+
This is NOT checked, so forgetting it silently gives wrong results.
|
|
87
|
+
- **Each input feature lies in `[0, 1]`.** Rescale your search space accordingly.
|
|
88
|
+
|
|
89
|
+
`fit()` standardizes targets internally (`standardize_y=True` by default) — pass raw $y$. Pass `standardize_y=False` if you have already standardized. `strict=True` (default) validates the unit-cube contract on every `fit`/`forward`; pass `strict=False` to skip.
|
|
90
|
+
|
|
91
|
+
## Cite
|
|
92
|
+
|
|
93
|
+
```bibtex
|
|
94
|
+
@inproceedings{
|
|
95
|
+
rakotoarison2026alphapfn,
|
|
96
|
+
title={{$\alpha$}-PFN: Fast Entropy Search via In-Context Learning},
|
|
97
|
+
author={Rakotoarison, Herilalaina and Adriaensen, Steven and Viering, Tom and Hvarfner, Carl and M{\"u}ller, Samuel and Hutter, Frank and Bakshy, Eytan},
|
|
98
|
+
booktitle={Forty-third International Conference on Machine Learning},
|
|
99
|
+
year={2026},
|
|
100
|
+
url={https://openreview.net/forum?id=7Oonij8oLU}
|
|
101
|
+
}
|
|
102
|
+
```
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# Releasing AlphaPFN to PyPI
|
|
2
|
+
|
|
3
|
+
Steps for a new release (maintainers only).
|
|
4
|
+
|
|
5
|
+
## Prereqs (one-time)
|
|
6
|
+
|
|
7
|
+
1. Have a PyPI account with maintainer rights to the `AlphaPFN` package
|
|
8
|
+
(or TestPyPI for dry runs).
|
|
9
|
+
2. Create an API token in your PyPI account settings.
|
|
10
|
+
3. Install build tooling:
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
pip install --upgrade build twine
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Cut a release
|
|
17
|
+
|
|
18
|
+
1. Bump the version in two places:
|
|
19
|
+
- `pyproject.toml` → `version = "X.Y.Z"`
|
|
20
|
+
- `alphapfn/__init__.py` → `__version__ = "X.Y.Z"`
|
|
21
|
+
|
|
22
|
+
2. Tag and push:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
git commit -am "Release X.Y.Z"
|
|
26
|
+
git tag vX.Y.Z
|
|
27
|
+
git push && git push --tags
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
3. Build the distribution artifacts (cleans `dist/` first):
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
rm -rf dist/ build/ *.egg-info
|
|
34
|
+
python -m build
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
This produces `dist/alphapfn-X.Y.Z-py3-none-any.whl` and the sdist.
|
|
38
|
+
|
|
39
|
+
4. (Optional) Test on TestPyPI first:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
twine upload --repository testpypi dist/*
|
|
43
|
+
pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ AlphaPFN==X.Y.Z
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
5. Upload to PyPI:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
twine upload dist/*
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
6. Verify the install works in a clean env:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
python -m venv /tmp/alpha-pfn-check && source /tmp/alpha-pfn-check/bin/activate
|
|
56
|
+
pip install "AlphaPFN[botorch]==X.Y.Z"
|
|
57
|
+
python -c "from alphapfn import AlphaPFN, __version__; print(__version__)"
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
7. Create a GitHub release pointing at the tag, with a short changelog.
|
|
61
|
+
|
|
62
|
+
## Notes
|
|
63
|
+
|
|
64
|
+
- Checkpoints are downloaded at runtime by `alphapfn.checkpoints`, so they
|
|
65
|
+
don't need to be bundled in the wheel. `pyproject.toml` already excludes
|
|
66
|
+
`*.pt`, `*.gz`, `images/`, and `examples/*.ipynb` from the build.
|
|
67
|
+
- Test the wheel locally before publishing: `pip install dist/alphapfn-*.whl`.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"""alphapfn — fast entropy-search acquisition via in-context learning.
|
|
2
|
+
|
|
3
|
+
Public surface:
|
|
4
|
+
from alphapfn import AlphaPFN
|
|
5
|
+
model = AlphaPFN.from_pretrained(acquisition="JES")
|
|
6
|
+
model.fit(train_X, train_Y)
|
|
7
|
+
acq = model(X_test)
|
|
8
|
+
"""
|
|
9
|
+
from alphapfn.api import AlphaPFN, AlphaPFNPosteriorMean, ALLOWED_ACQUISITIONS
|
|
10
|
+
|
|
11
|
+
__version__ = "0.0.1"
|
|
12
|
+
__all__ = [
|
|
13
|
+
"AlphaPFN",
|
|
14
|
+
"AlphaPFNPosteriorMean",
|
|
15
|
+
"ALLOWED_ACQUISITIONS",
|
|
16
|
+
"__version__",
|
|
17
|
+
]
|