Skip to content

ProgramAsWeights (PAW)

Compile natural language specifications into neural programs that run locally.

ProgramAsWeights lets you define functions in English and compile them into tiny neural programs (.paw files) that run on your machine. Once compiled, they work as regular Python functions -- no internet connection, no external service, no per-call fees.

Quick Start

pip install programasweights --extra-index-url https://pypi.programasweights.com/simple/
import programasweights as paw

# Load an official program by name
fn = paw.function("email-triage")

result = fn("Thesis defense committee needs your signature by EOD")
print(result)  # "immediate"

result = fn("Department newsletter: spring picnic next Friday")
print(result)  # "wait"

Compile Your Own

import programasweights as paw

# Describe what you want in English
program = paw.compile(
    "Fix malformed JSON: repair missing quotes and trailing commas"
)

# Use the compiled program
fn = paw.function(program.id)
fn("{name: 'Alice', age: 30,}")  # '{"name":"Alice","age":30}'

What Can You Build?

PAW is for functions that are easy to describe but hard to code as rules:

  • Fuzzy search -- typo-tolerant matching, semantic search, near-duplicate detection
  • Format repair -- fix broken JSON, normalize dates, repair malformed API inputs
  • Log triage -- extract errors from verbose output, detect anomalies
  • Custom classification -- define "important" or "urgent" in your own words
  • Smart notifications -- classify emails/messages by your own urgency rules
  • Agent preprocessing -- parse tool calls, route tasks, validate outputs

How It Works

Each compiled program has two parts:

  1. Discrete pseudo-program -- text instructions generated by the neural compiler
  2. Continuous neural adapter -- LoRA weights (~23 MB) that tune the interpreter model

At runtime, the SDK loads a quantized base model (Q6_K ~594 MB for Qwen3, Q8_0 ~134 MB for GPT-2, downloaded once) and applies the LoRA adapter. Inference runs entirely locally via llama.cpp.

Browser Inference

Programs compiled with the compact interpreter (GPT-2 124M) also run directly in the browser via WebAssembly -- no custom server needed for inference:

<script type="module">
  import paw from '@programasweights/web';
  const fn = await paw.function('email-triage-browser');
  const result = await fn('Urgent: server is down!');
</script>

See the Browser Inference guide for details.

Next Steps