programasweights 0.4.1__tar.gz → 0.4.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. {programasweights-0.4.1 → programasweights-0.4.2}/PKG-INFO +1 -1
  2. programasweights-0.4.2/README.md +128 -0
  3. {programasweights-0.4.1 → programasweights-0.4.2}/programasweights/__init__.py +1 -1
  4. {programasweights-0.4.1 → programasweights-0.4.2}/pyproject.toml +1 -1
  5. programasweights-0.4.1/README.md +0 -186
  6. {programasweights-0.4.1 → programasweights-0.4.2}/.gitignore +0 -0
  7. {programasweights-0.4.1 → programasweights-0.4.2}/.readthedocs.yaml +0 -0
  8. {programasweights-0.4.1 → programasweights-0.4.2}/AGENTS.md +0 -0
  9. {programasweights-0.4.1 → programasweights-0.4.2}/CHANGELOG.md +0 -0
  10. {programasweights-0.4.1 → programasweights-0.4.2}/LICENSE +0 -0
  11. {programasweights-0.4.1 → programasweights-0.4.2}/PYPI_README.md +0 -0
  12. {programasweights-0.4.1 → programasweights-0.4.2}/docs/adr/001-llama-cpp-over-pytorch.md +0 -0
  13. {programasweights-0.4.1 → programasweights-0.4.2}/docs/adr/002-q4_0-adapter-format.md +0 -0
  14. {programasweights-0.4.1 → programasweights-0.4.2}/docs/adr/003-single-spec-field.md +0 -0
  15. {programasweights-0.4.1 → programasweights-0.4.2}/docs/adr/004-compiler-naming.md +0 -0
  16. {programasweights-0.4.1 → programasweights-0.4.2}/docs/adr/005-vllm-hidden-states.md +0 -0
  17. {programasweights-0.4.1 → programasweights-0.4.2}/docs/adr/006-email-api-key-auth.md +0 -0
  18. {programasweights-0.4.1 → programasweights-0.4.2}/docs/advanced/adrs.md +0 -0
  19. {programasweights-0.4.1 → programasweights-0.4.2}/docs/advanced/architecture.md +0 -0
  20. {programasweights-0.4.1 → programasweights-0.4.2}/docs/api-reference/cli.md +0 -0
  21. {programasweights-0.4.1 → programasweights-0.4.2}/docs/api-reference/python-sdk.md +0 -0
  22. {programasweights-0.4.1 → programasweights-0.4.2}/docs/api-reference/rest-api.md +0 -0
  23. {programasweights-0.4.1 → programasweights-0.4.2}/docs/architecture.md +0 -0
  24. {programasweights-0.4.1 → programasweights-0.4.2}/docs/case-studies/log-monitoring.md +0 -0
  25. {programasweights-0.4.1 → programasweights-0.4.2}/docs/case-studies/semantic-search.md +0 -0
  26. {programasweights-0.4.1 → programasweights-0.4.2}/docs/case-studies/site-navigation.md +0 -0
  27. {programasweights-0.4.1 → programasweights-0.4.2}/docs/case-studies/tool-calling.md +0 -0
  28. {programasweights-0.4.1 → programasweights-0.4.2}/docs/getting-started/first-program.md +0 -0
  29. {programasweights-0.4.1 → programasweights-0.4.2}/docs/getting-started/installation.md +0 -0
  30. {programasweights-0.4.1 → programasweights-0.4.2}/docs/getting-started/naming-programs.md +0 -0
  31. {programasweights-0.4.1 → programasweights-0.4.2}/docs/guide/browser-inference.md +0 -0
  32. {programasweights-0.4.1 → programasweights-0.4.2}/docs/guide/how-it-works.md +0 -0
  33. {programasweights-0.4.1 → programasweights-0.4.2}/docs/guide/local-inference.md +0 -0
  34. {programasweights-0.4.1 → programasweights-0.4.2}/docs/guide/writing-good-specs.md +0 -0
  35. {programasweights-0.4.1 → programasweights-0.4.2}/docs/hub/browsing-programs.md +0 -0
  36. {programasweights-0.4.1 → programasweights-0.4.2}/docs/hub/feedback-cases.md +0 -0
  37. {programasweights-0.4.1 → programasweights-0.4.2}/docs/hub/publishing-programs.md +0 -0
  38. {programasweights-0.4.1 → programasweights-0.4.2}/docs/index.md +0 -0
  39. {programasweights-0.4.1 → programasweights-0.4.2}/docs/requirements.txt +0 -0
  40. {programasweights-0.4.1 → programasweights-0.4.2}/examples/flask_app.py +0 -0
  41. {programasweights-0.4.1 → programasweights-0.4.2}/examples/jupyter_notebook.py +0 -0
  42. {programasweights-0.4.1 → programasweights-0.4.2}/examples/langchain_integration.py +0 -0
  43. {programasweights-0.4.1 → programasweights-0.4.2}/examples/paw_monitor.py +0 -0
  44. {programasweights-0.4.1 → programasweights-0.4.2}/examples/replace_openai.py +0 -0
  45. {programasweights-0.4.1 → programasweights-0.4.2}/mkdocs.yml +0 -0
  46. {programasweights-0.4.1 → programasweights-0.4.2}/programasweights/_output.py +0 -0
  47. {programasweights-0.4.1 → programasweights-0.4.2}/programasweights/artifacts.py +0 -0
  48. {programasweights-0.4.1 → programasweights-0.4.2}/programasweights/cache.py +0 -0
  49. {programasweights-0.4.1 → programasweights-0.4.2}/programasweights/cli.py +0 -0
  50. {programasweights-0.4.1 → programasweights-0.4.2}/programasweights/client.py +0 -0
  51. {programasweights-0.4.1 → programasweights-0.4.2}/programasweights/compiler/__init__.py +0 -0
  52. {programasweights-0.4.1 → programasweights-0.4.2}/programasweights/compiler/dummy.py +0 -0
  53. {programasweights-0.4.1 → programasweights-0.4.2}/programasweights/config.py +0 -0
  54. {programasweights-0.4.1 → programasweights-0.4.2}/programasweights/convert_peft_to_paw.py +0 -0
  55. {programasweights-0.4.1 → programasweights-0.4.2}/programasweights/paw_format.py +0 -0
  56. {programasweights-0.4.1 → programasweights-0.4.2}/programasweights/runtime/__init__.py +0 -0
  57. {programasweights-0.4.1 → programasweights-0.4.2}/programasweights/runtime/interpreter.py +0 -0
  58. {programasweights-0.4.1 → programasweights-0.4.2}/programasweights/runtime/interpreter_onnx.py +0 -0
  59. {programasweights-0.4.1 → programasweights-0.4.2}/programasweights/runtime_llamacpp.py +0 -0
  60. {programasweights-0.4.1 → programasweights-0.4.2}/tests/test_offline_cache.py +0 -0
  61. {programasweights-0.4.1 → programasweights-0.4.2}/tests/test_runtime_registry_sdk.py +0 -0
  62. {programasweights-0.4.1 → programasweights-0.4.2}/tests/test_sdk.py +0 -0
  63. {programasweights-0.4.1 → programasweights-0.4.2}/tests/test_sdk.sh +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: programasweights
3
- Version: 0.4.1
3
+ Version: 0.4.2
4
4
  Summary: Compile natural language specifications into neural programs that run locally via llama.cpp.
5
5
  Project-URL: Homepage, https://programasweights.com
6
6
  Project-URL: Repository, https://github.com/programasweights/programasweights-python
@@ -0,0 +1,128 @@
1
+ # ProgramAsWeights
2
+
3
+ **Compile natural language specs into tiny neural functions that run locally.**
4
+
5
+ Define what a function should do in plain English. PAW compiles it into a small neural program that runs on your machine — no API keys at runtime, no internet needed after setup, fully deterministic.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ pip install programasweights --extra-index-url https://pypi.programasweights.com/simple/
11
+ ```
12
+
13
+ ## Quick Start
14
+
15
+ ```python
16
+ import programasweights as paw
17
+
18
+ # Use a pre-compiled function (downloads once, runs locally forever)
19
+ fn = paw.function("email-triage")
20
+ fn("Urgent: the server is down!") # "immediate"
21
+ fn("Newsletter: spring picnic") # "wait"
22
+
23
+ # Compile your own from a description
24
+ program = paw.compile(
25
+ "Fix malformed JSON: repair missing quotes and trailing commas",
26
+ slug="json-fixer" # optional: creates username/json-fixer handle
27
+ )
28
+ fn = paw.function(program.slug) # or paw.function(program.id)
29
+ fn("{name: 'Alice',}") # '{"name":"Alice"}'
30
+
31
+ # Or compile and load in one step
32
+ fn = paw.compile_and_load("Classify sentiment as positive or negative")
33
+ fn("I love this!") # "positive"
34
+ ```
35
+
36
+ If you specifically want the smaller browser-compatible runtime, pass `compiler="paw-4b-gpt2"`. Otherwise, omit `compiler` and let the server default decide.
37
+
38
+ ## Current Public Compilers
39
+
40
+
41
+ | | Standard (Qwen3 0.6B) | Compact (GPT-2 124M) |
42
+ | --------------- | --------------------- | -------------------- |
43
+ | Compiler name | `paw-4b-qwen3-0.6b` | `paw-4b-gpt2` |
44
+ | Accuracy | Higher | Lower |
45
+ | Base model size | 594 MB | 134 MB |
46
+ | Program size | ~22 MB | ~5 MB |
47
+ | Local inference | ~0.05-0.5s per call | ~0.03-0.3s per call |
48
+ | Runs in browser | No | Yes (WebAssembly) |
49
+
50
+ The current server default is Standard (`paw-4b-qwen3-0.6b`). Use Compact (`paw-4b-gpt2`) when you need smaller files or browser deployment.
51
+
52
+ If you need to inspect available compiler aliases programmatically, use `paw.list_compilers()`.
53
+
54
+ GPU acceleration is enabled by default (Metal on Mac, CUDA on Linux, falls back to CPU). Set `PAW_GPU_LAYERS=0` to force CPU if GPU causes issues.
55
+
56
+ ## Browser SDK
57
+
58
+ Programs compiled with GPT-2 also run in the browser via WebAssembly. The initial model and program assets download automatically; inference then runs client-side.
59
+
60
+ ```bash
61
+ npm install @programasweights/web
62
+ ```
63
+
64
+ ```javascript
65
+ import paw from '@programasweights/web';
66
+
67
+ const fn = await paw.function('email-triage-browser');
68
+ const result = await fn('Urgent: the server is down!');
69
+ // result: "immediate"
70
+ ```
71
+
72
+ If you load by program ID, browser inference only depends on Hugging Face-hosted assets. Slugs still need one PAW API lookup.
73
+
74
+ New browser-compatible programs are uploaded to Hugging Face asynchronously after compile. They are usually ready within a minute or two, but under load can take a few minutes, so a freshly compiled browser program may need a short wait before the JS SDK can load it.
75
+
76
+ See the [browser SDK repo](https://github.com/programasweights/programasweights-js) for full documentation.
77
+
78
+ ## Use with AI Agents
79
+
80
+ PAW works with Cursor, Claude, Codex, and other AI coding assistants. Paste this into your agent's chat:
81
+
82
+ > I want to use ProgramAsWeights (PAW) to create fuzzy text functions that run locally. Read the instructions at [https://programasweights.com/AGENTS.md](https://programasweights.com/AGENTS.md) and help me integrate it.
83
+
84
+ Or save `[AGENTS.md](https://programasweights.com/agents)` to your project root — agents read it automatically.
85
+
86
+ ## When to Use PAW
87
+
88
+ - **Fuzzy search** — typo-tolerant matching, semantic search, near-duplicate detection
89
+ - **Format repair** — fix broken JSON, normalize dates, repair malformed inputs
90
+ - **Classification** — sentiment, urgency, categories defined in your own words
91
+ - **Extraction** — emails, names, dates from messy unstructured text
92
+ - **Log triage** — extract errors from verbose output, filter noise
93
+ - **Intent routing** — map user descriptions to the closest URL, menu item, or setting
94
+ - **Agent preprocessing** — parse tool calls, validate outputs, route tasks
95
+
96
+ ## Authentication
97
+
98
+ ```bash
99
+ # Option 1: environment variable (recommended)
100
+ export PAW_API_KEY=paw_sk_...
101
+
102
+ # Option 2: CLI login (opens browser to generate key)
103
+ paw login
104
+ ```
105
+
106
+ Generate API keys at [programasweights.com/settings](https://programasweights.com/settings). Authenticated users get higher rate limits.
107
+
108
+ ## CLI
109
+
110
+ ```bash
111
+ paw compile --spec "Extract error lines from logs" --json
112
+ paw run --program <program_id> --input "[ERROR] timeout" --json
113
+ paw login
114
+ ```
115
+
116
+ `--json` gives structured output for programmatic use.
117
+
118
+ ## Links
119
+
120
+ - **Website**: [programasweights.com](https://programasweights.com)
121
+ - **Documentation**: [programasweights.readthedocs.io](https://programasweights.readthedocs.io)
122
+ - **Python SDK**: [github.com/programasweights/programasweights-python](https://github.com/programasweights/programasweights-python)
123
+ - **Browser SDK**: [github.com/programasweights/programasweights-js](https://github.com/programasweights/programasweights-js)
124
+ - **Program Hub**: [programasweights.com/hub](https://programasweights.com/hub)
125
+
126
+ ## License
127
+
128
+ MIT
@@ -27,7 +27,7 @@ try:
27
27
  from importlib.metadata import version as _meta_version
28
28
  __version__ = _meta_version("programasweights")
29
29
  except Exception:
30
- __version__ = "0.4.1"
30
+ __version__ = "0.4.2"
31
31
 
32
32
  from .config import get_api_url, get_api_key, set_api_key
33
33
 
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "programasweights"
7
- version = "0.4.1"
7
+ version = "0.4.2"
8
8
  description = "Compile natural language specifications into neural programs that run locally via llama.cpp."
9
9
  readme = "PYPI_README.md"
10
10
  requires-python = ">=3.9"
@@ -1,186 +0,0 @@
1
- # ProgramAsWeights
2
-
3
- Programs as small weight blobs; a fixed interpreter runs them.
4
-
5
- ## Development
6
-
7
- ```
8
- pip install -e .
9
- ```
10
-
11
- ```
12
- python test_compile.py
13
- ```
14
-
15
- ```
16
- python test_execute.py
17
- ```
18
-
19
-
20
- ## Quickstart
21
-
22
- ```bash
23
- pip install programasweights
24
- ```
25
-
26
- ```python
27
- import programasweights
28
- f = programasweights.function("/path/to/weights")
29
- print(f("Hello"))
30
- ```
31
-
32
- - weights = programs; base model = interpreter.
33
- - Deterministic by default (greedy generation).
34
-
35
- ## 🌐 Web Interface
36
-
37
- ProgramAsWeights includes a modern web interface for easy interaction with the system. The web app provides a user-friendly way to compile specifications, test neural programs, and manage models without writing code.
38
-
39
- ### Features
40
-
41
- - **Interactive Model Selection**: Choose from available compiler and interpreter models
42
- - **Natural Language Specifications**: Describe your program in plain English
43
- - **GPT-Powered Examples**: Auto-generate test data using OpenAI's API
44
- - **Real-time Compilation**: Compile specs into neural programs instantly
45
- - **Interactive Testing**: Test compiled programs with custom inputs
46
- - **Model Downloads**: Download compiled models as `.tgz` files
47
- - **Community Sharing**: Publish and discover programs on the leaderboard
48
-
49
- ### Quick Start
50
-
51
- 1. **Prerequisites**: Ensure you have Python 3.8+, Node.js 16+, and npm installed
52
-
53
- 2. **Start the application**:
54
- ```bash
55
- cd web-app
56
- ./start.sh
57
- ```
58
-
59
- 3. **Access the interface**:
60
- - **Web App**: http://localhost:5173
61
- - **API Docs**: http://localhost:8000/docs
62
-
63
- The startup script automatically:
64
- - Installs Python and Node.js dependencies
65
- - Starts the FastAPI backend server
66
- - Starts the React frontend development server
67
-
68
- ### Manual Setup (Alternative)
69
-
70
- If you prefer manual setup:
71
-
72
- ```bash
73
- # Backend
74
- cd web-app/backend
75
- pip install -r requirements.txt
76
- python run_server.py
77
-
78
- # Frontend (in another terminal)
79
- cd web-app/frontend
80
- npm install
81
- npm run dev
82
- ```
83
-
84
- ### Configuration
85
-
86
- Create `web-app/backend/.env` with:
87
- ```bash
88
- OPENAI_API_KEY=your_openai_api_key_here # Optional: for GPT test generation
89
- CHECKPOINT_DIR=../../outputs_1spec/prefix_kv # Path to trained models
90
- ```
91
-
92
- ### Example Workflow
93
-
94
- 1. Select "Qwen 2.5 Coder 0.5B" as compiler and "PAW Interpreter" as interpreter
95
- 2. Enter specification: *"Parse a string like '(A) cat (B) dog' into a JSON list"*
96
- 3. Generate examples with GPT or add manually
97
- 4. Click "Compile" to create your neural program
98
- 5. Test with input: *"(A) red apple (B) green banana"*
99
- 6. Download or publish your compiled model
100
-
101
- For detailed documentation, see [`web-app/README.md`](web-app/README.md).
102
-
103
- ## Train a compiler→KV prefix→interpreter (defaults)
104
-
105
- ```bash
106
- # installs training extras
107
- pip install -e .[train]
108
-
109
- # trains on data/samples_train.jsonl with Qwen defaults
110
- paw-train
111
- ```
112
-
113
- - Produces checkpoint under `outputs/prefix_kv/checkpoint/`.
114
-
115
- ## Compile then run (qualitative eval)
116
-
117
- ```bash
118
- # compile a prompt into a KV-prefix artifact
119
- paw-eval
120
- ```
121
-
122
- Or programmatically:
123
-
124
- ```python
125
- import programasweights as paw
126
-
127
- prompt = (
128
- "Parse a string like '(A) ... (B) ... (C) ...' into a JSON list of options. "
129
- "Be robust to noise: extra spaces, bullets, and phrases like 'both (A) and (B)'."
130
- )
131
-
132
- artifact_dir = paw.compile(
133
- out_dir="outputs/prefix_kv/demo_program",
134
- spec=prompt,
135
- checkpoint_dir="outputs/prefix_kv/checkpoint",
136
- )
137
-
138
- f = paw.function(artifact_dir, interpreter_name="Qwen/Qwen2.5-Coder-0.5B-Instruct", max_new_tokens=128)
139
- print(f("(A) cat (B) dog (C) both (A) and (B) are possible"))
140
- ```
141
-
142
- - The dummy compiler is still available as `compile_dummy` for tests and demos.
143
-
144
- ## API
145
-
146
- ```python
147
- import programasweights
148
- parse_func = programasweights.function(
149
- "/path/to/weights.safetensors",
150
- interpreter_name="google/flan-t5-small",
151
- max_new_tokens=128,
152
- )
153
- output = parse_func("input string")
154
- ```
155
-
156
- - Accepts `str` or `List[str]` and returns the same shape.
157
- - Aliasing works: `import programasweights as paw`.
158
-
159
- ## Local development
160
-
161
- ```bash
162
- pip install -e .[test]
163
- pytest -q
164
- ```
165
-
166
- ```bash
167
- # smoke check
168
- python -c "import programasweights as paw; print(paw.__version__)"
169
- ```
170
-
171
- - `pip install -e .` installs in editable mode so code changes are picked up without reinstalling.
172
- - If you do not need editable mode: `pip install .` (you must reinstall after changes).
173
-
174
- ## Notes
175
-
176
- - MVP runtime uses a single in-process interpreter (loads the base model once and stays warm).
177
- - Program artifact can be a prompt/prefix (text file) or a KV-prefix directory with `program.json` and `kv_prefix.pt`.
178
- - Device selection: CUDA if available, else CPU. Override with env var `PROGRAMASWEIGHTS_DEVICE`.
179
- - Simple global lock around `generate()` for thread safety.
180
-
181
- ## Roadmap
182
-
183
- - Compiler: spec → weights
184
- - LoRA support
185
- - JSON-constrained decoding
186
- - Server mode (multi-tenant)