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

Uploaded Python 3

File details

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

File metadata

  • Download URL: programasweights-0.1.0.dev2.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.dev2.tar.gz
Algorithm Hash digest
SHA256 484b93a5896578d254e9a90c267f7e2a30095d72216931b766198e19ec1aebd2
MD5 4a4941674278d3859c6761173a28ed7c
BLAKE2b-256 dde35a488cfc681b60e758d9985b5afb1940309f5e2b289d285a687754ffab90

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for programasweights-0.1.0.dev2-py3-none-any.whl
Algorithm Hash digest
SHA256 4441fad3731747a3b88c2fcfd2a7f61042e1ebda767190cce65eff69227672c9
MD5 1ca94a5d148107843a97281f91fb8864
BLAKE2b-256 b4b9808451686cdd81fcf2039043e30ea8c592c82d8f1ecac3a55632ac24812c

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