Skip to main content

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

Project description

ProgramAsWeights

Compile natural language specifications into neural programs (.paw files) that run locally.

Programs are stored as weight blobs (KV cache prefix + optional LoRA adapters) interpreted by a small fixed model. No API calls needed at runtime — fully deterministic, local execution.

Installation

pip install programasweights

Quick Start

Run a Program

import programasweights as paw

# Load and run a compiled program
fn = paw.function("program_id_or_path.paw")
result = fn("Contact alice@company.com or bob@example.org")
print(result)  # ["alice@company.com", "bob@example.org"]

Compile a Program

import programasweights as paw

# Compile from natural language specification
paw.compile(
    "output.paw",
    spec="Extract all email addresses from text and return as JSON list",
    checkpoint_dir="path/to/trained/compiler",
)

LoRA Support (PEFT Compatible)

Already using PEFT for LoRA training? Convert to .paw in one line:

import programasweights as paw

# Standard PEFT workflow:
# model = get_peft_model(base_model, LoraConfig(r=16, target_modules=["q_proj", "v_proj"]))
# trainer.train()
# model.save_pretrained("my_adapter/")

# Convert to .paw:
paw.from_peft(
    "my_adapter/",       # Your PEFT checkpoint
    "sentiment.paw",     # Output .paw file
    spec="Classify sentiment as positive or negative",
    tags=["sentiment", "classification"],
    examples=[
        {"input": "Great movie!", "output": "positive"},
        {"input": "Terrible film.", "output": "negative"},
    ],
)

# Use it:
fn = paw.function("sentiment.paw")
print(fn("This is amazing!"))  # → "positive"

Load LoRA from a .paw file:

lora_weights, lora_config = paw.load_paw_lora("sentiment.paw")
print(lora_config)  # {"rank": 16, "alpha": 32, ...}

Or use save_lora_to_paw() directly if you have raw tensors instead of a PEFT checkpoint.

.paw File Format v2

A .paw file is a self-contained neural program that includes:

Component Description Required
KV cache prefix Continuous program (prefix weights) Optional
Pseudo-program Discrete text instructions Optional
LoRA adapter Fine-tuned adapter weights Optional
Generation config Temperature, top_p, max_tokens Optional
Metadata Interpreter model, spec, author, tags Required

Program Hub

Browse and share programs at hub.programasweights.com

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.dev4.tar.gz (7.4 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.dev4-py3-none-any.whl (33.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: programasweights-0.1.0.dev4.tar.gz
  • Upload date:
  • Size: 7.4 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.dev4.tar.gz
Algorithm Hash digest
SHA256 92b1824a6caa1b9903dfc69996927a57fdb5dee6df0bc365f34793e18bea9460
MD5 b7f1642b8ebc44d31365c1774b0dee88
BLAKE2b-256 31d0c01b9bd02fd0851a3fa9d74cc141eddc21ac2031fd3f1f082f10620730aa

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for programasweights-0.1.0.dev4-py3-none-any.whl
Algorithm Hash digest
SHA256 86d4245cc9cf17358f8a858dc72da3bf3d4f89b6e654e6f6c0fe33cbb7e731ff
MD5 f2400da90b86eaea1145938e3ee26a62
BLAKE2b-256 a5b36dc946a808edf8ef64020b99315662cb671a708d18fd30fbc3378ed5260d

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