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.dev5.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.dev5-py3-none-any.whl (33.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: programasweights-0.1.0.dev5.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.dev5.tar.gz
Algorithm Hash digest
SHA256 c90625d47671b1715a0b2236974c5c66934908569ecf37246975e50c2728fc08
MD5 7faa0940fe04ad2e938c6eaa5cf666d1
BLAKE2b-256 9273516b3829a09ba15d77deb8f6ade1eabc0f495853f18067ae305d7f6582a3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for programasweights-0.1.0.dev5-py3-none-any.whl
Algorithm Hash digest
SHA256 40745a90ddacb37189dffe6b3c6afa30829d307ca624cf1c72fb1bfd488e4600
MD5 65c35e0bff9b92e25e26056bacf79cd8
BLAKE2b-256 ac077184db862b563df103c22f30c5c663b0dd6287dad3d66154713ea7a5ed36

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