β οΈ Please note: this is a beta release, the main release will follow shortly.
ALF is an active learning framework for optimising expensive, high-dimensional search spaces in computational science β settings where every label costs a wet-lab experiment, a physical measurement, or a long simulation, and the candidate space (protein sequences, small molecules, materials) is far too large to screen exhaustively. It runs the full loop of search, surrogate modelling, and acquisition through modular components you can swap independently.
In scientific discovery, the bottleneck is rarely computeβit's the experiment. Each label costs a wet-lab assay, a simulation, or a measurement, and you can only afford a handful of rounds. ALF runs the full active-learning loop for you: train a surrogate on what you've measured, use an acquisition function to select the most informative next batch, score it, and repeatβall with modular, swappable components so you can change any one part without rewriting the rest.
β Full motivation and design rationale
https://instadeepai.github.io/alf/ β full docs including API reference, tutorials, and how-to guides.
- π₯ Installation Guide
- π οΈ Contributing Guide
ALF is split into two packages:
alf-core β Lightweight framework with base classes, core data structures, and minimal dependencies (numpy, pandas, scipy). No ML framework dependencies. It is standalone and domain-agnostic β see the ALF Core Quickstart for an example. Use this for custom implementations or when integrating into existing systems.
alf-tools β Ready-to-use datasets, models, and acquisition functions with heavier dependencies (PyTorch). Depends on alf-core. Use this for quick-start and prototyping.
# Core package only (no PyTorch required)
pip install alf-core
# Tools package (includes PyTorch, models, and datasets)
pip install alf-toolsFor GPU support, optional extras (ESM2, Chemprop), and development setup, see the Installation Guide.
from alf_core import (
BaseDatasetConfig,
DatasetSearch,
DesignTask,
Optimizer,
Oracle,
Surrogate,
TerminalStateLogger,
)
from alf_tools.datasets.gfp import GFP
from alf_tools.models.cnn import CNNModel
from alf_tools.optimizer.acquisition_functions.greedy import Greedy
# A dataset wraps your candidates and their known labels. A small train_ratio
# leaves a large candidate pool for the active-learning loop to acquire from.
config = BaseDatasetConfig(
name="gfp",
modality="sequence",
seed=42,
train_ratio=0.1,
validation_frac=0.5,
test_ratio=0.2,
split_type="random",
problem_type="regression",
)
dataset = GFP(config)
# The surrogate is a cheap probabilistic model trained on observed labels
surrogate = Surrogate(model=CNNModel())
# The optimizer picks the next batch: acquisition function scores candidates,
# search function selects from them
optimizer = Optimizer(acquisition_fn=Greedy(), search_fn=DatasetSearch())
# The oracle scores selected candidates (here, it queries the held-out dataset)
oracle = Oracle(scorer=dataset)
# Run the active learning loop for 5 rounds, acquiring 100 candidates per round
task = DesignTask(num_acq_rounds=5, acq_batch_size=100)
state = task.setup(dataset=dataset, surrogate=surrogate)
task.run(
state=state,
state_loggers=[TerminalStateLogger()],
optimizer=optimizer,
oracle=oracle,
)New to active learning? Start with Why ALF?, then work through the Tutorials.
Prefer a zero-setup environment? The repository ships a Dockerfile that bundles the tutorials
and benchmark examples with CPU PyTorch:
docker build -t alf .
docker run --rm -p 8888:8888 alf # JupyterLab with the tutorials at http://localhost:8888See the Run with Docker guide for benchmark examples, volume mounts, and GPU support.
- Offline Design Tutorial β end-to-end active learning loop with labels from a held-out pool. The best entry point.
- Online Design Tutorial β the same loop, with labels from a live scorer.
- GP Tutorial β Gaussian Process surrogate and kernel cheat-sheet
- CNN Tutorial β convolutional sequence surrogate
- Ensemble Tutorial β seed ensembles, MC dropout, and combined ensembles for uncertainty-aware prediction
- ESM-2 Tutorial β protein language model as surrogate or zero-shot scorer
- Chemprop MPNN Tutorial β active learning for small molecules with SMILES inputs
- ALF Core Quickstart β active learning on MNIST digit classification, with a softmax-regression surrogate and uncertainty-sampling acquisition function implemented from scratch with numpy/scipy
- Models β create custom models for oracle/surrogate/generator roles
- Datasets β add custom data sources
- Search Functions β implement custom search strategies
- Acquisition Functions β create custom acquisition strategies
git clone git@github.com:instadeepai/alf.git
cd alf
uv syncuv run pytest # run all tests
uv run pytest --cov=alf_core --cov-report term-missing # with coverage
uv run pre-commit install # install pre-commit hooksSee the Installation Guide for GPU configuration and optional extras.
Read our Contributing Guide for development guidelines and the PR process. For questions or discussions, open an issue.
alf/
βββ core/ # alf-core package (base classes, tasks, utilities)
βββ tools/ # alf-tools package (models, datasets, acquisition functions)
βββ tutorials/ # Tutorial notebooks
βββ docs/ # Documentation source
See core/README.md and tools/README.md for package-level details.
uv sync --group docs
uv run sphinx-build -b html docs/source docs/build/html
open docs/build/html/index.html # macOSThis project is licensed under the Apache License 2.0 β see the LICENSE file for details.

