Skip to main content

ProgramAsWeights

Compile natural language specs into tiny neural functions that run locally.

Define what a function should do in plain English. PAW compiles it into a small neural program that runs on your machine — no API keys at runtime, no internet needed after setup, fully deterministic.

Install

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

Quick Start

import programasweights as paw

# Use a pre-compiled function (downloads once, runs locally forever)
fn = paw.function("email-triage")
fn("Urgent: the server is down!")        # "immediate"
fn("Newsletter: spring picnic")          # "wait"

# Compile your own from a description
program = paw.compile(
    "Fix malformed JSON: repair missing quotes and trailing commas",
    slug="json-fixer"              # optional: creates username/json-fixer handle
)
fn = paw.function(program.slug)    # or paw.function(program.id)
fn("{name: 'Alice',}")  # '{"name":"Alice"}'

# Or compile and load in one step
fn = paw.compile_and_load("Classify sentiment as positive or negative")
fn("I love this!")  # "positive"

If you specifically want the smaller browser-compatible runtime, pass compiler="paw-4b-gpt2". Otherwise, omit compiler and let the server default decide.

Current Public Compilers

Standard (Qwen3 0.6B) Compact (GPT-2 124M)
Compiler name paw-4b-qwen3-0.6b paw-4b-gpt2
Accuracy Higher Lower
Base model size 594 MB 134 MB
Program size ~22 MB ~5 MB
Local inference ~0.05-0.5s per call ~0.03-0.3s per call
Runs in browser No Yes (WebAssembly)

The current server default is Standard (paw-4b-qwen3-0.6b). Use Compact (paw-4b-gpt2) when you need smaller files or browser deployment.

If you need to inspect available compiler aliases programmatically, use paw.list_compilers().

GPU acceleration is enabled by default (Metal on Mac, CUDA on Linux, falls back to CPU). Set PAW_GPU_LAYERS=0 to force CPU if GPU causes issues.

Desktop and Offline Workflows

Prepare and inspect validated local assets without keeping a model loaded:

prepared = paw.prepare_program("da03/my-classifier")
assert prepared["offline_ready"]

fn = paw.function("da03/my-classifier", offline=True)
cached = paw.list_cached_programs()

offline=True (or PAW_OFFLINE=1) makes zero network calls and fails clearly if a required validated program, runtime, adapter, or base model is missing. Long-running finetune compiles can be queued with paw.compile_async(spec, compiler="paw-ft-bs48"); an explicit finetune compiler is required.

Advanced adapter-free inference is available with paw.function(None, interpreter="gpt2"); see the Python API reference for its intentionally strict semantics.

Browser SDK

Programs compiled with GPT-2 also run in the browser via WebAssembly. The initial model and program assets download automatically; inference then runs client-side.

npm install @programasweights/web
import paw from '@programasweights/web';

const fn = await paw.function('email-triage-browser');
const result = await fn('Urgent: the server is down!');
// result: "immediate"

If you load by program ID, browser inference only depends on Hugging Face-hosted assets. Slugs still need one PAW API lookup.

New browser-compatible programs are uploaded to Hugging Face asynchronously after compile. They are usually ready within a minute or two, but under load can take a few minutes, so a freshly compiled browser program may need a short wait before the JS SDK can load it.

See the browser SDK repo for full documentation.

Use with AI Agents

PAW works with Cursor, Claude, Codex, and other AI coding assistants. Paste this into your agent's chat:

I want to use ProgramAsWeights (PAW) to create fuzzy text functions that run locally. Read the instructions at https://programasweights.com/AGENTS.md and help me integrate it.

Or save [AGENTS.md](https://programasweights.com/agents) to your project root — agents read it automatically.

When to Use PAW

  • Fuzzy search — typo-tolerant matching, semantic search, near-duplicate detection
  • Format repair — fix broken JSON, normalize dates, repair malformed inputs
  • Classification — sentiment, urgency, categories defined in your own words
  • Extraction — emails, names, dates from messy unstructured text
  • Log triage — extract errors from verbose output, filter noise
  • Intent routing — map user descriptions to the closest URL, menu item, or setting
  • Agent preprocessing — parse tool calls, validate outputs, route tasks

Authentication

# Option 1: environment variable (recommended)
export PAW_API_KEY=paw_sk_...

# Option 2: CLI login (opens browser to generate key)
paw login

Generate API keys at programasweights.com/settings. Authenticated users get higher rate limits.

CLI

paw compile --spec "Extract error lines from logs" --json
paw run --program <program_id> --input "[ERROR] timeout" --json
paw run --program <program_id> --input "[ERROR] timeout" --offline --json
paw login

--json gives structured output for programmatic use.

Links

License

MIT

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

programasweights-0.4.4.tar.gz (115.4 kB view details)

Uploaded Source

Built Distribution

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

programasweights-0.4.4-py3-none-any.whl (56.7 kB view details)

Uploaded Python 3

File details

Details for the file programasweights-0.4.4.tar.gz.

File metadata

  • Download URL: programasweights-0.4.4.tar.gz
  • Upload date:
  • Size: 115.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for programasweights-0.4.4.tar.gz
Algorithm Hash digest
SHA256 1d57da13bed1658cf7bf4fb6b8329bac9e148d41c91090ae8d9f3f257ea11670
MD5 0bf352180686eb408b549fa459624af1
BLAKE2b-256 536c991eb5a595443be8d3febcd8235e16a151947d09832625ef13988e3c9a3f

See more details on using hashes here.

File details

Details for the file programasweights-0.4.4-py3-none-any.whl.

File metadata

File hashes

Hashes for programasweights-0.4.4-py3-none-any.whl
Algorithm Hash digest
SHA256 c1d8bc54bc4225ff882722cc4986e7b29912225bcd5ebe215297e5dcf8cfa68c
MD5 c5c6d3cc148526d4dd97b8174d3f2fe3
BLAKE2b-256 d687211d2898dea4514abe65e474c66593047b1d1214c31075475fee13528280

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.4.4 This release

2 files

0.4.3

2 files

0.4.2

2 files

0.4.1

2 files

0.4.0

2 files

0.3.2

2 files

0.3.1

2 files

0.3.0

2 files

0.2.8

2 files

0.2.7

2 files

0.2.5

2 files

0.2.4

2 files

0.2.3

2 files

0.2.2

2 files

0.2.1

2 files

0.2.0

2 files

Supported by

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