New: Introducing PHP and Composer Support.Read the Announcement
Socket
Book a DemoInstallSign in
Socket

autoform

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

autoform

Composable function transformations for LLM programs

pipPyPI
Version
0.0.7
Maintainers
1

autoform

Trace once. Transform freely.

Composable function transformations for LM programs.

Think JAX, but for LM programs.

Python 3.12+ CI codecov

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

TransformWhat it does
batchVectorize over inputs
pushforwardForward-mode AD
pullbackReverse-mode AD
schedAuto-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.

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts