programasweights/compile-by-training

Compile natural-language function descriptions into reusable local PAW programs.

Python

15

2 commits

updated Sep 4, 2026

See the code
llm
local-inference
lora
neural-programs
programasweights

See what people are saying (1)

SourceMessageScoreDate

ProgramAsWeights: compile English function descriptions into neural programs that run locally [R] (r/MachineLearning)

Given the recent interest in tools like Jev, I wanted to share ProgramAsWeights (PAW), an open-source research project I'm working on at the University of Waterloo. You describe a text function in English, compile it into a reusable neural program, and run it locally, including on a CPU. For…

4

Sep 19, 2026

README

Compile by Training

Turn a natural-language function description into a reusable neural program.

Compile by Training uses teacher models to generate examples, finetunes a small PAW interpreter, and produces a .paw function that runs locally without further teacher calls.

Requires Python 3.10+, uv, and an OpenAI API key. The default recipe is intended for an accelerator with about 40 GB of available memory; use a lower --micro-batch-size or --gradient-checkpointing on smaller devices.

Compile

Set an OpenAI API key and run the script:

export OPENAI_API_KEY=...
uv run compile.py "Classify sentiment. Return only positive, negative, or neutral." -o sentiment.paw

The script saves sentiment.paw, installs it in the local PAW cache, and prints its program ID. Use the ID with the PAW Python package:

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

sentiment = paw.function("<program-id>")
print(sentiment("I loved it."))

The program downloads the shared 0.6B interpreter once, then runs locally. A PAW API key is optional; setting PAW_API_KEY provides higher hosted compile limits.

Mapper assets and completed teacher synthesis are cached, so rerunning the same specification and recipe reuses finished work.

Customize

The defaults reproduce the released Compile by Training recipe. Every major choice can be changed from the command line:

uv run compile.py "Classify sentiment. Return only positive or negative." \
  --teacher gpt-5.4-mini=800 \
  --teacher gpt-5.5=400 \
  --steps 80 \
  --batch-size 32 \
  --micro-batch-size 8 \
  --learning-rate 1e-4 \
  -o sentiment.paw
uv run compile.py --print-config
uv run compile.py --help

How it works

  1. Compile the specification once with the fast PAW compiler to initialize the neural program.
  2. Ask teacher models to generate task-specific input-output examples.
  3. Finetune the local interpreter on those examples.
  4. Package the result as a reusable .paw function.

The implementation is contained in compile.py.

Paper

Compile by Training: Turning Natural-Language Specifications into Local Neural Functions, Yuntian Deng, Pengyu Nie, and Stuart Shieber.

License

MIT

Contributors

da03

2 commits

programasweights/compile-by-training

Compile natural-language function descriptions into reusable local PAW programs.

Python

15

2 commits

updated Sep 4, 2026

See the code
llm
local-inference
lora
neural-programs
programasweights

See what people are saying (1)

SourceMessageScoreDate

ProgramAsWeights: compile English function descriptions into neural programs that run locally [R] (r/MachineLearning)

Given the recent interest in tools like Jev, I wanted to share ProgramAsWeights (PAW), an open-source research project I'm working on at the University of Waterloo. You describe a text function in English, compile it into a reusable neural program, and run it locally, including on a CPU. For…

4

Sep 19, 2026

README

Compile by Training

Turn a natural-language function description into a reusable neural program.

Compile by Training uses teacher models to generate examples, finetunes a small PAW interpreter, and produces a .paw function that runs locally without further teacher calls.

Requires Python 3.10+, uv, and an OpenAI API key. The default recipe is intended for an accelerator with about 40 GB of available memory; use a lower --micro-batch-size or --gradient-checkpointing on smaller devices.

Compile

Set an OpenAI API key and run the script:

export OPENAI_API_KEY=...
uv run compile.py "Classify sentiment. Return only positive, negative, or neutral." -o sentiment.paw

The script saves sentiment.paw, installs it in the local PAW cache, and prints its program ID. Use the ID with the PAW Python package:

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

sentiment = paw.function("<program-id>")
print(sentiment("I loved it."))

The program downloads the shared 0.6B interpreter once, then runs locally. A PAW API key is optional; setting PAW_API_KEY provides higher hosted compile limits.

Mapper assets and completed teacher synthesis are cached, so rerunning the same specification and recipe reuses finished work.

Customize

The defaults reproduce the released Compile by Training recipe. Every major choice can be changed from the command line:

uv run compile.py "Classify sentiment. Return only positive or negative." \
  --teacher gpt-5.4-mini=800 \
  --teacher gpt-5.5=400 \
  --steps 80 \
  --batch-size 32 \
  --micro-batch-size 8 \
  --learning-rate 1e-4 \
  -o sentiment.paw
uv run compile.py --print-config
uv run compile.py --help

How it works

  1. Compile the specification once with the fast PAW compiler to initialize the neural program.
  2. Ask teacher models to generate task-specific input-output examples.
  3. Finetune the local interpreter on those examples.
  4. Package the result as a reusable .paw function.

The implementation is contained in compile.py.

Paper

Compile by Training: Turning Natural-Language Specifications into Local Neural Functions, Yuntian Deng, Pengyu Nie, and Stuart Shieber.

License

MIT

Contributors

da03

2 commits

Languages

Python

100.0%