Skip to main content

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

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.2.tar.gz (41.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

autoform-0.0.2-py3-none-any.whl (22.3 kB view details)

Uploaded Python 3

File details

Details for the file autoform-0.0.2.tar.gz.

File metadata

  • Download URL: autoform-0.0.2.tar.gz
  • Upload date:
  • Size: 41.1 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

Hashes for autoform-0.0.2.tar.gz
Algorithm Hash digest
SHA256 720d371270908d37d38acf996b3f2cac6c6bf5a3586f362d4a49702195094af5
MD5 a2d64c2fba0331d3739d333328acbda9
BLAKE2b-256 d67a0e54586bf784a57c6702a229cbf832cd7c6be3de20e5f11b286b231a603e

See more details on using hashes here.

File details

Details for the file autoform-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: autoform-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 22.3 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

Hashes for autoform-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a554accca1919994a974f8d550fd656f58517e5364a46ff2661415ede21b753a
MD5 e05ed30d5ee0be51f16053f2312f52a3
BLAKE2b-256 68e17131d0d174b629b451ea4dc5cb3bd52b4ed3f9c997a58035c389187ba201

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page