Compile natural-language function descriptions into reusable local PAW programs.
See the codeTurn 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.
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.
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
.paw function.The implementation is contained in compile.py.
Compile by Training: Turning Natural-Language Specifications into Local Neural Functions, Yuntian Deng, Pengyu Nie, and Stuart Shieber.
MIT
2 commits
Python
100.0%
Compile natural-language function descriptions into reusable local PAW programs.
See the codeTurn 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.
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.
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
.paw function.The implementation is contained in compile.py.
Compile by Training: Turning Natural-Language Specifications into Local Neural Functions, Yuntian Deng, Pengyu Nie, and Stuart Shieber.
MIT
2 commits
Python
100.0%