Composable function transformations for LLM programs
Project description
autoform
Trace once. Transform freely.
Composable function transformations for LM programs.
Think JAX, but for LM programs.
Quickstart - Transforms - Concurrency - Debugging - Docs
pip install git+https://github.com/ASEM000/autoform.git
Quickstart
import autoform as af
def explain(topic: str) -> str:
prompt = af.format("Explain {} in one paragraph.", topic)
msg = dict(role="user", content=prompt)
return af.lm_call([msg], model="gpt-5.2")
ir = af.trace(explain)("...") # capture structure, no execution
Now transform it:
# execute
output = ir.call("quantum entanglement")
# batch: n inputs
outputs = af.batch(ir).call(["DNA", "gravity", "recursion"])
# pushforward: propagate input perturbations forward
output, tangent = af.pushforward(ir).call(("quantum entanglement", "add more examples"))
# pullback: propagate output feedback backward
output, grad = af.pullback(ir).call(("quantum entanglement", "too technical"))
# compose: batched differentiation
topics = ["DNA", "gravity", "recursion"]
critiques = ["too technical", "too brief", "too abstract"]
outputs, hints = af.batch(af.pullback(ir)).call((topics, critiques))
The last line is the point: batch(pullback(ir)), transformations compose.
Transforms
| Transform | What it does |
|---|---|
batch |
Vectorize over inputs |
pushforward |
Forward-mode AD |
pullback |
Reverse-mode AD |
sched |
Auto-concurrent execution |
Concurrency
sched finds independent LM calls. acall runs them concurrently.
scheduled = af.sched(ir)
result = await scheduled.acall("input") # acall for async
Debugging
Checkpoint intermediate values. Substitute on re-execution.
def pipeline(x: str) -> str:
msg1 = dict(role="user", content=x)
step1 = af.lm_call([msg1], model="gpt-5.2")
step1 = af.checkpoint(step1, key="step1", collection="debug")
msg2 = dict(role="user", content=step1)
step2 = af.lm_call([msg2], model="gpt-5.2")
return step2
ir = af.trace(pipeline)("...")
# capture
with af.collect(collection="debug") as captured:
result = ir.call("input")
# substitute step1 value
with af.inject(collection="debug", values=dict(step1=["modified"])):
result = ir.call("input")
⚠️ Early development: API may change.
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
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 autoform-0.2.0.tar.gz.
File metadata
- Download URL: autoform-0.2.0.tar.gz
- Upload date:
- Size: 71.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","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 |
efef1d245b36b4f2571498727db01a6f3a5590e8fe539d33c3dbfa2c7077ef96
|
|
| MD5 |
09165385a9097bed37a8a37f26ba831d
|
|
| BLAKE2b-256 |
a2f88bc731fca4a49c25ffa6794ff4603c78f46cf46ea0d2ed422347c38d4ec2
|
File details
Details for the file autoform-0.2.0-py3-none-any.whl.
File metadata
- Download URL: autoform-0.2.0-py3-none-any.whl
- Upload date:
- Size: 43.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","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 |
9bbd07e4b82e22164ff702c2ef3c62e401ab5dc1fd83a0dc93013b0f40374e61
|
|
| MD5 |
6f8064f7bc307da91b98827fe5170f56
|
|
| BLAKE2b-256 |
5e0654012aaee503e0bffc343c077fa08c94e81dc552b3dfc8f53031c334db71
|