Skip to content

instadeepai/alf

Repository files navigation

ALF cover

uv Python Version License Documentation Core Coverage Tools Coverage pre-commit Tests and Linters πŸ§ͺ

⚠️ 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.

ALF active-learning loop overview

Why ALF?

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

πŸ“– Documentation

https://instadeepai.github.io/alf/ β€” full docs including API reference, tutorials, and how-to guides.

πŸ“¦ Package Architecture

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.

πŸ“¦ Installation

# Core package only (no PyTorch required)
pip install alf-core

# Tools package (includes PyTorch, models, and datasets)
pip install alf-tools

For GPU support, optional extras (ESM2, Chemprop), and development setup, see the Installation Guide.

πŸš€ Quick Start

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.

🐳 Run with Docker

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:8888

See the Run with Docker guide for benchmark examples, volume mounts, and GPU support.

πŸŽ“ Tutorials

Start with an experiment

Go deeper on models

  • 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

Lightweight (alf-core only)

  • 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

Extend ALF

πŸ› οΈ Development

git clone git@github.com:instadeepai/alf.git
cd alf
uv sync
uv 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 hooks

See the Installation Guide for GPU configuration and optional extras.

🀝 Contributing

Read our Contributing Guide for development guidelines and the PR process. For questions or discussions, open an issue.

πŸ“ Project Structure

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.

πŸ“š Building Documentation Locally

uv sync --group docs
uv run sphinx-build -b html docs/source docs/build/html
open docs/build/html/index.html  # macOS

πŸ“„ License

This project is licensed under the Apache License 2.0 β€” see the LICENSE file for details.

About

Active learning framework for iterative optimisation of biological and chemical design targets

Resources

License

Contributing

Stars

4 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors