Evolvable AI programs: define a function + criteria, let an LLM iteratively improve it
Project description
evolvers
Evolvable AI programs: define a Python function + criteria of success, the bound LLM iteratively rewrites the function body to maximize the criteria score.
Status: early PoC. APIs will change.
Idea
A program is a Python function with an injected llm. Criteria are either natural-language LLM judges or plain code, each scoring outputs in [-1, 1]. An LLM-driven optimizer proposes mutations to the function body; mutations that improve the weighted score are accepted, the rest are reverted. Artifacts are saved as a directory (manifest.json + program.py + criteria/) and loadable by URI.
Quick look
import evolvers as ev
def tldr(input_text: str, llm) -> str:
return input_text[:130] + "..." # naive baseline; the optimizer rewrites this
llm = ev.LLM(model="claude-opus-4-7") # or any OpenAI-compatible endpoint
evo = ev.Evolvable(
tldr,
criteria=[
ev.judge("Does it directly summarize the main points as a TLDR?"),
ev.code(lambda output_text:
max(-1.0, 1 - 2 * max(0, (len(output_text) - 140) / 140))),
],
llm=llm,
)
evo.train(dataset, budget=10)
evo.save("you/tldr-v1:claude-opus-4-7")
reloaded = ev.Evolvable.load("you/tldr-v1:claude-opus-4-7")
print(reloaded("very long text"))
Install (from source)
git clone https://github.com/tiramisu-sh/evolvers
cd evolvers
uv sync
What works today
ev.LLMagainst Anthropic and OpenAI-compatible endpoints (vLLM, Ollama, OpenAI, Azure)- Structured output via pydantic schemas (
schema=) ev.judge(question)+ev.code(callable)criteria; lambdas captured asdeffor round-trippingEvolvable.train(budget=N)— propose-test-accept-or-revert loop driven by the bound LLMEvolvable.save("owner/name:variant")/Evolvable.load(...)to/from~/.cache/evolvers/Evolvable.clone().set_llm(other)for variants
Validated end-to-end against a local Qwen3.5-27B reasoning model: naive truncation baseline → optimized LLM-using TLDR in one mutation attempt.
License
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 evolvers-0.1.0.tar.gz.
File metadata
- Download URL: evolvers-0.1.0.tar.gz
- Upload date:
- Size: 52.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.13 {"installer":{"name":"uv","version":"0.11.13","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
000b4846111d13bec7ffb570c7a595169d92f7b79a7ad564e3f4cd7d27df754a
|
|
| MD5 |
7ed3f8ea5e14ea09b077d30d69e416a3
|
|
| BLAKE2b-256 |
e0a102733af7d27a3bf9c65e2480ed6c6b9e55fd0a7f6e9b1fc1148835228d1a
|
File details
Details for the file evolvers-0.1.0-py3-none-any.whl.
File metadata
- Download URL: evolvers-0.1.0-py3-none-any.whl
- Upload date:
- Size: 20.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.13 {"installer":{"name":"uv","version":"0.11.13","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e96877db816591d6387c05907fb2dd326dd7dc173711ee9f722267d6a463ddff
|
|
| MD5 |
8792a764d0dd185e22e6cf18ac456313
|
|
| BLAKE2b-256 |
f163e0002bf114bf7b6c7483aa926636b4c72bf42c0a6ab808d8b79a5f797366
|