Skip to main content

Fast Entropy Search via In-Context Learning (PFN-based amortized acquisition functions for Bayesian Optimization)

Project description

$\alpha$-PFN: Fast Entropy Search via In-Context Learning

PyPI version Python License: MIT Paper Open In Colab

$\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).

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.

To reproduce our ICML 2026 paper experiments, see branch icml2026.

Install

pip install AlphaPFN

Or from source:

git clone https://github.com/automl/AlphaPFN
cd AlphaPFN
uv sync

Pretrained checkpoints (~20 MB) download automatically on the first from_pretrained call and cache under ~/.cache/alphapfn/.

Quick start

A self-contained 6D BO loop on Hartmann, using botorch.optim.optimize_acqf. Requires the [botorch] extra — pip install "AlphaPFN[botorch]":

import torch
from botorch.optim import optimize_acqf
from botorch.test_functions import Hartmann
from alphapfn import AlphaPFN

# 1. Objective on the unit cube (α-PFN maximizes — `negate=True` flips Hartmann's sign).
hartmann = Hartmann(dim=6, negate=True)

# 2. Initial design.
torch.manual_seed(0)
d, n_init, num_steps = 6, 6, 30
X = torch.rand(n_init, d, dtype=torch.double)
y = hartmann(X)
bounds = torch.stack([torch.zeros(d), torch.ones(d)]).double()

# 3. Load the pretrained acquisition; checkpoints download on first call.
acqf = AlphaPFN.from_pretrained(acquisition="JES")

# 4. BO loop.
for step in range(num_steps):
    acqf.fit(X, y)                            # fit() standardizes y internally
    X_next, _ = optimize_acqf(acqf, bounds=bounds, q=1,
                              num_restarts=10, raw_samples=128)
    y_next = hartmann(X_next.squeeze(0))
    X = torch.cat([X, X_next.detach().double()])
    y = torch.cat([y, y_next.detach().double().reshape(1)])
    print(f"step {step+1:>2}: best so far = {y.max().item():.4f}")

Runnable version: examples/bo_with_optimize_acqf.py or open the Colab notebook.

API

AlphaPFN.from_pretrained(
    acquisition: str | None = None,   # "PES" (default), "MES", or "JES"
    version: str = "v1",
    *,
    load_base_model: bool = False,
    ucb_beta: float = 2.0,
    strict: bool = True,              # pass strict=False to skip input checks
)

Before fitting, prepare your data so that:

  • You are maximizing. To minimize instead, negate your objective. This is NOT checked, so forgetting it silently gives wrong results.
  • Each input feature lies in [0, 1]. Rescale your search space accordingly.

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.

Cite

@inproceedings{
  rakotoarison2026alphapfn,
  title={{$\alpha$}-PFN: Fast Entropy Search via In-Context Learning},
  author={Rakotoarison, Herilalaina and Adriaensen, Steven and Viering, Tom and Hvarfner, Carl and M{\"u}ller, Samuel and Hutter, Frank and Bakshy, Eytan},
  booktitle={Forty-third International Conference on Machine Learning},
  year={2026},
  url={https://openreview.net/forum?id=7Oonij8oLU}
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

alphapfn-0.0.1.tar.gz (53.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

alphapfn-0.0.1-py3-none-any.whl (60.3 kB view details)

Uploaded Python 3

File details

Details for the file alphapfn-0.0.1.tar.gz.

File metadata

  • Download URL: alphapfn-0.0.1.tar.gz
  • Upload date:
  • Size: 53.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for alphapfn-0.0.1.tar.gz
Algorithm Hash digest
SHA256 f3710b29fe869ed12f8cbd03a5b6747f2a8f45efe7fac5dfce2c3ac5adc36835
MD5 43999d160684c0b0aead21ebb298b65f
BLAKE2b-256 067c11d28ef7c116414bed9b329f164ca1e69e39d47ae8a8a500059fbdb376ac

See more details on using hashes here.

File details

Details for the file alphapfn-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: alphapfn-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 60.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for alphapfn-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f7f9cfd1bea8ca7b3f25d965aac7bb490926678c3590a407cb0e064428295c4b
MD5 1ebbc4d5e5432500ca4461ea3400c2e9
BLAKE2b-256 f75f19d52f0044cc2bc45b5a61d859ed8758b0f60cf882e412130cf9ea31f0e0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page