Search the guide

Start with a guide

Lesson 8 of 14 · Construct programs · PAW tutorial

Compile a fuzzy function

Turn an email policy into a reusable PAW function.

Specify behavior in words#

A fuzzy function handles a task whose meaning matters. An urgent email asks for action; an email quoting an old urgent request can describe work that is already finished. Program-as-Weights lets you specify this behavior, compile it, and call the resulting neural function.

Email urgency test cases1 / 5
Please approve the submission by 5 p.m. today so we can meet the deadline.
Expected labelURGENT

The function reads the meaning of the request, including whether action is still needed.

Try the function in ProgramAsWeights

Compile the specification#

python
import programasweights as paw

spec = "Classify whether this email needs prompt action from its recipient. Return exactly URGENT or ROUTINE. An imminent deadline or an immediate blocker is URGENT. Newsletters, completed work, and FYI updates are ROUTINE."
program = paw.compile(spec, compiler="paw-4b-qwen3-0.6b")
print(program.id)

with paw.function(program.id) as urgency:
    print(urgency("The release is waiting for your approval."))

Open the PAW playground to compile a specification and try your own messages. The cards above show expected labels; the playground returns the actual function output.

The compiler creates the program#

PAW specifically trains a compiler to generate LoRA adapters that edit the interpreter’s weights. The saved program also contains readable task text. The shared interpreter uses both when it executes a new input.

Sources and resources

Course contents