Composable function transformations for LLM programs
Project description
autoform
JAX-style function transformations for LLM programs
⚠️ Early Development: API may change.
Install
pip install autoform
Example
Write an LLM pipeline once. Transform it — batch (parallel batch_completion), backprop (semantic gradients), or both.
import autoform as af
def research_and_write(topic: str) -> str:
# step 1: research
prompt1 = af.format("List 3 key facts about: {}", topic)
notes = af.lm_call([dict(role="user", content=prompt1)], model="gpt-4.1")
# step 2: write using the research
prompt2 = af.format("Write a paragraph using: {}", notes)
article = af.lm_call([dict(role="user", content=prompt2)], model="gpt-4.1")
return article
# trace the program
ir = af.build_ir(research_and_write, "example")
# transform: batch (uses litellm.batch_completion, not a loop)
batch_ir = af.batch_ir(ir, in_axes=list)
articles = af.run_ir(batch_ir, ["AI safety", "quantum computing", "climate"])
# compose transforms: batched semantic backprop
pb_ir = af.pullback_ir(ir)
batch_pb_ir = af.batch_ir(pb_ir, in_axes=(list, list))
topics = ["AI safety", "quantum computing", "climate"]
feedbacks = ["too brief", "good", "needs examples"]
outputs, input_grads = af.run_ir(batch_pb_ir, (topics, feedbacks))
More Examples
- examples/research_and_write.py: multi-step pipeline with batching
- examples/semantic_backprop.py: TextGrad-style custom backward passes
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
autoform-0.0.3.tar.gz
(43.5 kB
view details)
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
autoform-0.0.3-py3-none-any.whl
(23.2 kB
view details)
File details
Details for the file autoform-0.0.3.tar.gz.
File metadata
- Download URL: autoform-0.0.3.tar.gz
- Upload date:
- Size: 43.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","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 |
50ac46bdf609c1f54d29ac98aa7e4834228132d049cf371b2e222a5acb6726f2
|
|
| MD5 |
ec4c9f1524e9bea10314b3b576d09131
|
|
| BLAKE2b-256 |
7a6ee96fb34f2d8a17041ef55a632e3afe9587f2d35ba5f3ace548daaebb9608
|
File details
Details for the file autoform-0.0.3-py3-none-any.whl.
File metadata
- Download URL: autoform-0.0.3-py3-none-any.whl
- Upload date:
- Size: 23.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","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 |
b07c0a57cf1278f0f149def8176669f892cd44e2f1fc2dcd33bfeda5c7600772
|
|
| MD5 |
18aedc814673471d37148bad2ee1940f
|
|
| BLAKE2b-256 |
07941c0403798af087281f5e9a1d81029c3abacbdc51503101cc115d8e862eeb
|