Minimal open-source AlphaEvolve: LLM-driven program evolution with MAP-Elites islands, cascade evaluation, and a local Ollama ensemble.
Project description
fastevolve
Minimal open-source AlphaEvolve: LLM-driven program evolution with MAP-Elites islands, cascade evaluation, and a local Ollama ensemble.
Install
uv sync
The core install ships with Ollama support only. OpenAI and Anthropic SDKs are optional extras — install whichever you need:
uv sync --extra openai # adds the OpenAI SDK
uv sync --extra anthropic # adds the Anthropic SDK
uv sync --extra all # both
If you only use Ollama, skip the extras — neither SDK will be imported.
Quick start in code
Local (with Ollama)
Assumes ollama serve is running and you've pulled the model.
from fastevolve import Config, Controller
from fastevolve.llm_ensemble import ModelConfig
INITIAL = "def solve(x):\n return x\n"
def correctness(p):
ns = {}
try: exec(p.code, ns)
except Exception: return 0.0
fn = ns.get("solve")
cases = [(2, 4), (3, 9), (4, 16), (5, 25)]
return sum(1 for x, y in cases if fn and fn(x) == y) / len(cases)
cfg = Config()
cfg.iterations = 20
cfg.checkpoint_path = "run.log" # optional — resume if killed mid-run
cfg.ensemble.models = [
ModelConfig(name="gemma3:e4b", provider="ollama", temperature=0.7, weight=1.0, role="fast"),
]
cfg.evaluator.cascade = [(correctness, 0.0)]
result = Controller(cfg, initial_program=INITIAL).run()
print(result.best.code)
Google Colab (with OpenAI or Anthropic)
Ollama isn't practical on Colab — use an API provider instead. Paste this into a Colab cell:
!pip install -q "fastevolve[openai]"
import os
from google.colab import userdata
os.environ["OPENAI_API_KEY"] = userdata.get("OPENAI_API_KEY") # store in Colab Secrets first
from fastevolve import Config, Controller
from fastevolve.llm_ensemble import ModelConfig
INITIAL = "def solve(x):\n return x\n"
def correctness(p):
ns = {}
try: exec(p.code, ns)
except Exception: return 0.0
fn = ns.get("solve")
cases = [(2, 4), (3, 9), (4, 16), (5, 25)]
return sum(1 for x, y in cases if fn and fn(x) == y) / len(cases)
cfg = Config()
cfg.iterations = 20
cfg.ensemble.models = [
ModelConfig(name="gpt-4o-mini", provider="openai", temperature=0.7, weight=1.0, role="fast"),
]
cfg.evaluator.cascade = [(correctness, 0.0)]
result = Controller(cfg, initial_program=INITIAL).run()
print(result.best.code)
Google Colab (with Claude)
!pip install -q "fastevolve[anthropic]"
import os
from google.colab import userdata
os.environ["ANTHROPIC_API_KEY"] = userdata.get("ANTHROPIC_API_KEY") # store in Colab Secrets first
from fastevolve import Config, Controller
from fastevolve.llm_ensemble import ModelConfig
INITIAL = "def solve(x):\n return x\n"
def correctness(p):
ns = {}
try: exec(p.code, ns)
except Exception: return 0.0
fn = ns.get("solve")
cases = [(2, 4), (3, 9), (4, 16), (5, 25)]
return sum(1 for x, y in cases if fn and fn(x) == y) / len(cases)
cfg = Config()
cfg.iterations = 20
cfg.ensemble.models = [
ModelConfig(name="claude-haiku-4-5-20251001", provider="anthropic",
temperature=0.7, weight=1.0, role="fast",
options={"max_tokens": 4096}),
]
cfg.evaluator.cascade = [(correctness, 0.0)]
result = Controller(cfg, initial_program=INITIAL).run()
print(result.best.code)
Google Colab (with Ollama)
Ollama can run on Colab if you install it, start the daemon in the background, and pull a small model. Use a GPU runtime (Runtime → Change runtime type → T4 GPU) for any model bigger than ~1B parameters.
# 1. Install ollama and fastevolve
!curl -fsSL https://ollama.com/install.sh | sh
!pip install -q fastevolve
# 2. Start the ollama daemon in the background
import subprocess, time
subprocess.Popen(["ollama", "serve"])
time.sleep(5) # give it a moment to bind to port 11434
# 3. Pull a small model (qwen2.5:0.5b is ~400 MB and fits the free CPU runtime)
!ollama pull qwen2.5:0.5b
# 4. Run fastevolve as usual
from fastevolve import Config, Controller
from fastevolve.llm_ensemble import ModelConfig
INITIAL = "def solve(x):\n return x\n"
def correctness(p):
ns = {}
try: exec(p.code, ns)
except Exception: return 0.0
fn = ns.get("solve")
cases = [(2, 4), (3, 9), (4, 16), (5, 25)]
return sum(1 for x, y in cases if fn and fn(x) == y) / len(cases)
cfg = Config()
cfg.iterations = 20
cfg.ensemble.models = [
ModelConfig(name="qwen2.5:0.5b", provider="ollama",
temperature=0.7, weight=1.0, role="fast"),
]
cfg.evaluator.cascade = [(correctness, 0.0)]
result = Controller(cfg, initial_program=INITIAL).run()
print(result.best.code)
Colab sessions are disconnected after ~90 min idle and the VM is wiped — set cfg.checkpoint_path = "/content/drive/MyDrive/run.log" after mounting Drive if you want resume across sessions.
Run the demo
Start Ollama and pull the model first:
ollama serve
ollama pull gemma3:e4b
Then:
uv run python main.py
Using OpenAI or Claude in the ensemble
Set the API key for whichever provider(s) you plan to use:
export OPENAI_API_KEY=sk-...
export ANTHROPIC_API_KEY=sk-ant-...
On Windows (cmd.exe): set OPENAI_API_KEY=sk-...
Then pick a provider per model in your config. You can freely mix providers in one ensemble:
from fastevolve.llm_ensemble import ModelConfig
cfg.ensemble.models = [
ModelConfig(name="gemma3:e4b", provider="ollama", temperature=0.6, weight=1.0, role="fast"),
ModelConfig(name="gpt-4o-mini", provider="openai", temperature=0.6, weight=1.0, role="fast"),
ModelConfig(name="claude-opus-4-7", provider="anthropic", temperature=0.7, weight=1.0,
role="deep", options={"max_tokens": 4096}),
]
provider defaults to "ollama", so existing configs keep working unchanged.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fastevolve-0.3.0.tar.gz.
File metadata
- Download URL: fastevolve-0.3.0.tar.gz
- Upload date:
- Size: 32.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cf8f7f92236a99fb4c9c30931b4e1bcd01062d03e858a4e93da6f29b4076c2b1
|
|
| MD5 |
cc65c36a74728e659fed7f18c87aada9
|
|
| BLAKE2b-256 |
2556438467e342dfd99e04aab94353009294a62ded523417ff3b5526c411a19f
|
File details
Details for the file fastevolve-0.3.0-py3-none-any.whl.
File metadata
- Download URL: fastevolve-0.3.0-py3-none-any.whl
- Upload date:
- Size: 16.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
395b0e42c48b1fc0bd8c7ab7ce3f4e2363e161b3455bbd7370ee5e8bbf0822ed
|
|
| MD5 |
5dbce607da52db711e20f41b3e4b530c
|
|
| BLAKE2b-256 |
f4da04376f0c77bac8d41562b09b1388b029abb0354641f21e5eb6bd3aac514f
|