Composable function transformations for LLM programs
Project description
autoform
JAX-style function transformations for LLM programs
⚠️ Early Development: API may change.
Install
git clone https://github.com/ASEM000/autoform.git
cd autoform
uv sync
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.1.tar.gz
(39.4 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.1-py3-none-any.whl
(21.4 kB
view details)
File details
Details for the file autoform-0.0.1.tar.gz.
File metadata
- Download URL: autoform-0.0.1.tar.gz
- Upload date:
- Size: 39.4 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 |
bdfe895f3011173ea9ccc32a2f1fa9035a820f5b03e96c4762ca2b8483bbd18a
|
|
| MD5 |
9378e664b9ba15b0ac564125e3a7b966
|
|
| BLAKE2b-256 |
dfde90b515028b011e9ec8b31e8114ee750d2bfdc37ef7ba14a0571eafdb7135
|
File details
Details for the file autoform-0.0.1-py3-none-any.whl.
File metadata
- Download URL: autoform-0.0.1-py3-none-any.whl
- Upload date:
- Size: 21.4 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 |
5722d60caf42974738ba7f248e7087720b0a91fc5cba3176c8f6a454097a2692
|
|
| MD5 |
46d31e2907827aceca61c8e5aa08ecbf
|
|
| BLAKE2b-256 |
15ec2ae0df6ab49fb3520434777b23b8d17057e09e342eb89c949796f53ee68a
|