Skip to main content

Composable function transformations for LLM programs

Project description

autoform

Composable 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.4.tar.gz (46.3 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.4-py3-none-any.whl (31.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: autoform-0.0.4.tar.gz
  • Upload date:
  • Size: 46.3 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.4.tar.gz
Algorithm Hash digest
SHA256 5e88b5b0c48b443b0b1869dec814bd4b339720629a2542deb3150fee7e301f85
MD5 dc46e1787346f8a78993b57b34d0f882
BLAKE2b-256 ef9d4f6749cdb245fbf0449b0c6ad171ad24920dd504da3d2626bfd77f953845

See more details on using hashes here.

File details

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

File metadata

  • Download URL: autoform-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 31.0 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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 5af5445a0c5157503a173d1f7814655269605ec308618c20f2634ec9ab924de7
MD5 14ec89d30cb1db0207a6fba491ab8c1e
BLAKE2b-256 606d35bd58b025f0c39106afbe4fc5d9324971ec8cbc56cee477940b18ac48d0

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