Skip to content

Commit 0fb2038

Browse files
committed
update readme
1 parent de341ca commit 0fb2038

5 files changed

Lines changed: 172 additions & 39 deletions

File tree

CITATION.cff

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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"

README.md

Lines changed: 57 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,103 @@
11
# $\alpha$-PFN: Fast Entropy Search via In-Context Learning
22

3-
Lightweight package for $\alpha$-PFN, a Prior-Fitted Network for fast entropy search. Supported acquisitions: Predictive Entropy Search (PES), Max Value Entropy Search (MES), Joint-Entropy Search (JES).
3+
[![PyPI version](https://img.shields.io/pypi/v/alphapfn.svg)](https://pypi.org/project/alphapfn/)
4+
[![Python](https://img.shields.io/badge/python-3.10%2B-blue.svg)](https://www.python.org/downloads/)
5+
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
6+
[![Paper](https://img.shields.io/badge/Paper-OpenReview-b31b1b.svg)](https://openreview.net/forum?id=7Oonij8oLU)
7+
[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/automl/AlphaPFN/blob/main/examples/quickstart.ipynb)
48

5-
> To reproduce our ICML paper experiments, see branch
9+
**$\alpha$-PFN** is a Prior-Fitted Network that amortizes information-theoretic acquisition functions for Bayesian Optimization. It replaces the slow Monte-Carlo sampling used by classical entropy-search methods with a single transformer forward pass — yielding **1.6× – 70× speed-ups** over fully-Bayesian GP entropy search while matching its optimization quality. Drop-in compatible with `botorch.optim.optimize_acqf`. Supported acquisitions: **PES**, **MES**, **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
616
> [`icml2026`](https://github.com/automl/AlphaPFN/tree/icml2026).
717
818
## Install
919

20+
```bash
21+
pip install "alphapfn[botorch]"
22+
```
23+
24+
Or from source:
25+
1026
```bash
1127
git clone https://github.com/automl/AlphaPFN
1228
cd AlphaPFN
13-
uv sync
29+
uv sync --extra botorch
1430
```
1531

16-
PyPI release: TODO.
32+
Pretrained checkpoints (~20 MB) download automatically on the first `from_pretrained` call and cache under `~/.cache/alphapfn/`.
1733

1834
## Quick start
1935

20-
A minimal BO loop driven by `botorch.optim.optimize_acqf`:
36+
A self-contained 2D BO loop on Branin, using `botorch.optim.optimize_acqf`:
2137

2238
```python
39+
import math
2340
import torch
24-
from botorch.optim import optimize_acqf # needs botorch
41+
from botorch.optim import optimize_acqf
2542
from alphapfn import AlphaPFN
2643

44+
# 1. Define the objective on the unit cube (α-PFN maximizes — we negate Branin).
45+
def branin(X):
46+
x1 = 15.0 * X[..., 0] - 5.0
47+
x2 = 15.0 * X[..., 1]
48+
a, b, c = 1.0, 5.1 / (4 * math.pi**2), 5.0 / math.pi
49+
r, s, t = 6.0, 10.0, 1.0 / (8 * math.pi)
50+
return -(a * (x2 - b * x1**2 + c * x1 - r) ** 2
51+
+ s * (1 - t) * torch.cos(x1) + s)
52+
53+
# 2. Initial design.
54+
torch.manual_seed(0)
55+
d, n_init, num_steps = 2, 5, 15
56+
X = torch.rand(n_init, d, dtype=torch.double)
57+
y = branin(X)
2758
bounds = torch.stack([torch.zeros(d), torch.ones(d)]).double()
59+
60+
# 3. Load the pretrained acquisition; checkpoints download on first call.
2861
acqf = AlphaPFN.from_pretrained(acquisition="JES")
2962

63+
# 4. BO loop.
3064
for step in range(num_steps):
31-
# $\alpha$-PFN expects standardized targets.
32-
y_std = (y - y.mean()) / (y.std() + 1e-8)
65+
y_std = (y - y.mean()) / (y.std() + 1e-8) # standardize targets
3366
acqf.fit(X, y_std)
34-
35-
X_next, acq_value = optimize_acqf(
36-
acq_function=acqf,
37-
bounds=bounds,
38-
q=1,
39-
num_restarts=5,
40-
raw_samples=128,
41-
)
42-
y_next = objective(X_next.squeeze(0))
43-
X = torch.cat([X, X_next.detach().double()], dim=0)
67+
X_next, _ = optimize_acqf(acqf, bounds=bounds, q=1, num_restarts=5, raw_samples=128)
68+
y_next = branin(X_next.squeeze(0))
69+
X = torch.cat([X, X_next.detach().double()])
4470
y = torch.cat([y, y_next.detach().double().reshape(1)])
71+
print(f"step {step+1:>2}: best so far = {y.max().item():.4f}")
4572
```
4673

47-
A runnable version lives at
48-
[`examples/bo_with_optimize_acqf.py`](examples/bo_with_optimize_acqf.py):
49-
50-
```bash
51-
.venv/bin/python examples/bo_with_optimize_acqf.py --acquisition JES --steps 15
52-
```
74+
Runnable version: [`examples/bo_with_optimize_acqf.py`](examples/bo_with_optimize_acqf.py)
75+
or open the [Colab notebook](https://colab.research.google.com/github/automl/AlphaPFN/blob/main/examples/quickstart.ipynb).
5376

5477
## API
5578

5679
```python
5780
AlphaPFN.from_pretrained(
58-
acquisition: str | None = None, # or "MES", "JES"
81+
acquisition: str | None = None, # "PES" (default), "MES", or "JES"
5982
version: str = "v1",
6083
*,
6184
load_base_model: bool = False,
6285
ucb_beta: float = 2.0,
63-
strict: bool = True, # Pass strict=False to skip the input-range and standardization checks.
86+
strict: bool = True, # pass strict=False to skip input checks
6487
)
6588
```
6689

6790
Before fitting, prepare your data so that:
68-
- You are maximizing. To minimize instead, negate your objective.
69-
This is NOT checked, so forgetting it silently gives wrong results.
70-
- Each input feature is rescaled to lie between 0 and 1.
71-
- Targets are roughly standardized (subtract the mean, divide by the std).
91+
- **You are maximizing.** To minimize instead, negate your objective.
92+
This is NOT checked, so forgetting it silently gives wrong results.
93+
- **Each input feature lies in `[0, 1]`.** Rescale your search space accordingly.
94+
- **Targets are roughly standardized** (subtract the mean, divide by the std).
7295

96+
`strict=True` (default) validates the cube and standardization on every `fit`/`forward`; pass `strict=False` to skip.
7397

74-
# Cite
98+
## Cite
7599

76-
```latex
100+
```bibtex
77101
@inproceedings{
78102
rakotoarison2026alphapfn,
79103
title={{$\alpha$}-PFN: Fast Entropy Search via In-Context Learning},
@@ -82,4 +106,4 @@ Before fitting, prepare your data so that:
82106
year={2026},
83107
url={https://openreview.net/forum?id=7Oonij8oLU}
84108
}
85-
```
109+
```

alphapfn/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@
88
"""
99
from alphapfn.api import AlphaPFN, ALLOWED_ACQUISITIONS
1010

11-
__all__ = ["AlphaPFN", "ALLOWED_ACQUISITIONS"]
11+
__version__ = "0.0.1"
12+
__all__ = ["AlphaPFN", "ALLOWED_ACQUISITIONS", "__version__"]

images/hero.gif

429 KB
Loading

pyproject.toml

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,34 @@ build-backend = "hatchling.build"
55
[project]
66
name = "alphapfn"
77
version = "0.0.1"
8-
authors = [
9-
{name = "ML Freiburg"},
10-
]
11-
description = "Fast Entropy Search via In-Context Learning"
8+
description = "Fast Entropy Search via In-Context Learning (PFN-based amortized acquisition functions for Bayesian Optimization)"
129
readme = "README.md"
10+
license = { file = "LICENSE" }
1311
requires-python = ">=3.10"
12+
authors = [
13+
{ name = "Herilalaina Rakotoarison" },
14+
{ name = "Steven Adriaensen" },
15+
{ name = "Tom Viering" },
16+
{ name = "Carl Hvarfner" },
17+
{ name = "Samuel Müller" },
18+
{ name = "Frank Hutter" },
19+
{ name = "Eytan Bakshy" },
20+
]
21+
maintainers = [
22+
{ name = "Herilalaina Rakotoarison", email = "rakoheri@ad.helsinki.fi" },
23+
{ name = "Steven Adriaensen", email = "adriaens@cs.uni-freiburg.de" },
24+
{ name = "Tom Viering", email = "t.j.viering@tudelft.nl" },
25+
]
26+
keywords = [
27+
"bayesian-optimization",
28+
"entropy-search",
29+
"prior-fitted-networks",
30+
"pfn",
31+
"in-context-learning",
32+
"amortized-inference",
33+
"acquisition-function",
34+
"pytorch",
35+
]
1436
dependencies = [
1537
"torch>=1.9.0",
1638
"numpy>=1.21.2,<2.0",
@@ -23,17 +45,34 @@ dependencies = [
2345
"platformdirs",
2446
]
2547
classifiers = [
26-
"Programming Language :: Python :: 3",
48+
"Development Status :: 3 - Alpha",
49+
"Intended Audience :: Science/Research",
50+
"License :: OSI Approved :: MIT License",
2751
"Operating System :: OS Independent",
52+
"Programming Language :: Python :: 3",
53+
"Programming Language :: Python :: 3.10",
54+
"Programming Language :: Python :: 3.11",
55+
"Programming Language :: Python :: 3.12",
56+
"Topic :: Scientific/Engineering",
57+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
58+
"Topic :: Scientific/Engineering :: Mathematics",
2859
]
2960

61+
[project.urls]
62+
Homepage = "https://github.com/automl/AlphaPFN"
63+
Repository = "https://github.com/automl/AlphaPFN"
64+
Issues = "https://github.com/automl/AlphaPFN/issues"
65+
Paper = "https://openreview.net/forum?id=7Oonij8oLU"
66+
3067
[project.optional-dependencies]
3168
botorch = ["botorch>=0.15.0"]
3269

3370
[tool.hatch.build]
3471
exclude = [
3572
"*.gz",
3673
"*.pt",
74+
"images/*",
75+
"examples/*.ipynb",
3776
]
3877

3978
[tool.hatch.build.targets.wheel]

0 commit comments

Comments
 (0)