Skip to main content

Compile natural language specifications into neural programs that run locally via llama.cpp.

Project description

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

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",
    compiler="paw-4b-qwen3-0.6b"  # or "paw-4b-gpt2" for smaller/faster
)
fn = paw.function(program.id)
fn("{name: 'Alice',}")  # '{"name": "Alice"}'

Two Compilers

Qwen3 0.6B GPT-2 124M
Compiler name paw-4b-qwen3-0.6b paw-4b-gpt2
Accuracy Higher Lower
Base model size 594 MB 105 MB
Program size ~22 MB ~5 MB
Inference speed ~90ms (server) ~50ms (server)
Runs in browser No Yes

Default is Qwen3 0.6B. Use GPT-2 when you need smaller files or browser deployment.

Browser SDK

Programs compiled with GPT-2 also run entirely in the browser via WebAssembly — no server needed, data never leaves the user's device.

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

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

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 and help me integrate it.

Or save AGENTS.md 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
  • 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 login

--json gives structured output for programmatic use.

Links

License

MIT

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

programasweights-0.1.0.dev7.tar.gz (9.3 MB view details)

Uploaded Source

Built Distribution

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

programasweights-0.1.0.dev7-py3-none-any.whl (34.8 kB view details)

Uploaded Python 3

File details

Details for the file programasweights-0.1.0.dev7.tar.gz.

File metadata

  • Download URL: programasweights-0.1.0.dev7.tar.gz
  • Upload date:
  • Size: 9.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for programasweights-0.1.0.dev7.tar.gz
Algorithm Hash digest
SHA256 8e4b79aa9eebbcc83f769265b353f0be38c597e80253271800360e510e4c44a1
MD5 c8a5738fb7c6f890ce9af718d8a3cbbd
BLAKE2b-256 f02a23d04a7e1c3ea70e3b2c137aca8649070dd6ac192d7e66b0e9a872e391e4

See more details on using hashes here.

File details

Details for the file programasweights-0.1.0.dev7-py3-none-any.whl.

File metadata

File hashes

Hashes for programasweights-0.1.0.dev7-py3-none-any.whl
Algorithm Hash digest
SHA256 656d3cde597f4f96039ab73f6d3eea5dc383fc44163dac9dad40d4956ac62fea
MD5 4eb88d4ac4313d6c7caf459ebe25f647
BLAKE2b-256 658800ce6fbb51ddca6ed7fae01466e2834b40512ef4eb3a7f80d9ab134c5c4e

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