programasweights 0.1.0__tar.gz → 0.1.0.dev1__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 (325) hide show
  1. programasweights-0.1.0.dev1/.gitignore +76 -0
  2. programasweights-0.1.0.dev1/.hatch_build.toml +28 -0
  3. programasweights-0.1.0.dev1/.readthedocs.yaml +13 -0
  4. programasweights-0.1.0.dev1/1apple.jpg +0 -0
  5. programasweights-0.1.0.dev1/1apple2.jpg +0 -0
  6. programasweights-0.1.0.dev1/2apples.jpg +0 -0
  7. programasweights-0.1.0.dev1/2apples2.jpg +0 -0
  8. programasweights-0.1.0.dev1/3apples.jpg +0 -0
  9. programasweights-0.1.0.dev1/3apples2.jpg +0 -0
  10. programasweights-0.1.0.dev1/479400.png +0 -0
  11. programasweights-0.1.0.dev1/4apples.jpg +0 -0
  12. programasweights-0.1.0.dev1/4apples2.jpg +0 -0
  13. programasweights-0.1.0.dev1/4apples3.jpg +0 -0
  14. programasweights-0.1.0.dev1/4apples4.jpg +0 -0
  15. programasweights-0.1.0.dev1/5apples.jpg +0 -0
  16. programasweights-0.1.0.dev1/6apples.jpg +0 -0
  17. programasweights-0.1.0.dev1/8apples.jpg +0 -0
  18. programasweights-0.1.0.dev1/9apples.jpg +0 -0
  19. programasweights-0.1.0.dev1/FLOW_SUMMARY.md +202 -0
  20. {programasweights-0.1.0 → programasweights-0.1.0.dev1}/MANIFEST.in +1 -0
  21. programasweights-0.1.0.dev1/ONNX_MIGRATION_PLAN.md +84 -0
  22. programasweights-0.1.0.dev1/PKG-INFO +127 -0
  23. programasweights-0.1.0.dev1/PREFIX_TOKENS_DESIGN.md +176 -0
  24. programasweights-0.1.0.dev1/PYPI_README.md +102 -0
  25. {programasweights-0.1.0 → programasweights-0.1.0.dev1}/README.md +70 -10
  26. programasweights-0.1.0.dev1/TRUNCATION_CHANGES.md +185 -0
  27. programasweights-0.1.0.dev1/VERIFICATION_USAGE.md +282 -0
  28. programasweights-0.1.0.dev1/analyze_dataset.py +372 -0
  29. programasweights-0.1.0.dev1/analyze_lengths.py +246 -0
  30. programasweights-0.1.0.dev1/baselines/code_prompt.md +21 -0
  31. programasweights-0.1.0.dev1/baselines/evaluate_openai_python_code_baseline.py +296 -0
  32. programasweights-0.1.0.dev1/baselines/openai_batch_request.py +218 -0
  33. programasweights-0.1.0.dev1/baselines/prepare_alchemist_data.py +194 -0
  34. programasweights-0.1.0.dev1/baselines/prepare_var_bench_data.py +53 -0
  35. programasweights-0.1.0.dev1/baselines/python_code_sandbox.py +302 -0
  36. programasweights-0.1.0.dev1/baselines/script_evaluation_var_bench.sh +3 -0
  37. programasweights-0.1.0.dev1/baselines/script_evalution_evaluation.sh +8 -0
  38. programasweights-0.1.0.dev1/baselines/script_evalution_request.sh +8 -0
  39. programasweights-0.1.0.dev1/baselines/script_evalution_statistics.sh +8 -0
  40. programasweights-0.1.0.dev1/benchmark_pytorch_vs_onnx.py +315 -0
  41. programasweights-0.1.0.dev1/benchmark_user_experience.py +375 -0
  42. programasweights-0.1.0.dev1/check_dataset.py +31 -0
  43. programasweights-0.1.0.dev1/combine_datasets.py +157 -0
  44. programasweights-0.1.0.dev1/compare_datasets.py +268 -0
  45. programasweights-0.1.0.dev1/compare_old_vs_regen.py +227 -0
  46. programasweights-0.1.0.dev1/convert_paw_to_svg.py +119 -0
  47. programasweights-0.1.0.dev1/create_favicon_sizes.py +86 -0
  48. programasweights-0.1.0.dev1/create_visualization_from_log.py +269 -0
  49. programasweights-0.1.0.dev1/create_vqa_dataset.py +217 -0
  50. programasweights-0.1.0.dev1/debug_cache.py +80 -0
  51. programasweights-0.1.0.dev1/debug_eos_example.sh +22 -0
  52. programasweights-0.1.0.dev1/docs/Makefile +20 -0
  53. programasweights-0.1.0.dev1/docs/adr/001-llama-cpp-over-pytorch.md +21 -0
  54. programasweights-0.1.0.dev1/docs/adr/002-q4_0-adapter-format.md +32 -0
  55. programasweights-0.1.0.dev1/docs/adr/003-single-spec-field.md +26 -0
  56. programasweights-0.1.0.dev1/docs/adr/004-compiler-naming.md +32 -0
  57. programasweights-0.1.0.dev1/docs/adr/005-vllm-hidden-states.md +24 -0
  58. programasweights-0.1.0.dev1/docs/adr/006-email-api-key-auth.md +41 -0
  59. programasweights-0.1.0.dev1/docs/api-reference.rst +180 -0
  60. programasweights-0.1.0.dev1/docs/architecture.md +38 -0
  61. programasweights-0.1.0.dev1/docs/conf.py +27 -0
  62. programasweights-0.1.0.dev1/docs/examples/evaluation-tasks.rst +206 -0
  63. programasweights-0.1.0.dev1/docs/index.rst +73 -0
  64. programasweights-0.1.0.dev1/docs/installation.rst +65 -0
  65. programasweights-0.1.0.dev1/docs/make.bat +35 -0
  66. programasweights-0.1.0.dev1/docs/quickstart.rst +120 -0
  67. programasweights-0.1.0.dev1/docs/requirements.txt +3 -0
  68. programasweights-0.1.0.dev1/docs/using-pretrained.rst +223 -0
  69. programasweights-0.1.0.dev1/estimate_data_gen_cost.py +273 -0
  70. programasweights-0.1.0.dev1/eval.py +739 -0
  71. programasweights-0.1.0.dev1/examples/flask_app.py +48 -0
  72. programasweights-0.1.0.dev1/examples/jupyter_notebook.py +60 -0
  73. programasweights-0.1.0.dev1/examples/langchain_integration.py +103 -0
  74. programasweights-0.1.0.dev1/examples/replace_openai.py +72 -0
  75. programasweights-0.1.0.dev1/export_to_onnx.py +485 -0
  76. programasweights-0.1.0.dev1/extract_models.py +193 -0
  77. programasweights-0.1.0.dev1/inspect_data_dirs.py +384 -0
  78. programasweights-0.1.0.dev1/latest_export.csv +230 -0
  79. programasweights-0.1.0.dev1/log.train.81920.morecategories.extraprefix +14928 -0
  80. programasweights-0.1.0.dev1/main_no_spec_direct_ans_mix_continuous_sampleref_shorterprompt_vllm.py +1546 -0
  81. programasweights-0.1.0.dev1/merge_datasets.py +303 -0
  82. programasweights-0.1.0.dev1/paw.png +0 -0
  83. programasweights-0.1.0.dev1/paw.svg +34 -0
  84. programasweights-0.1.0.dev1/process_im2latex_dataset.py +207 -0
  85. programasweights-0.1.0.dev1/programasweights/__init__.py +168 -0
  86. programasweights-0.1.0.dev1/programasweights/artifacts.py +51 -0
  87. programasweights-0.1.0.dev1/programasweights/cache.py +82 -0
  88. programasweights-0.1.0.dev1/programasweights/cli.py +136 -0
  89. programasweights-0.1.0.dev1/programasweights/client.py +134 -0
  90. programasweights-0.1.0.dev1/programasweights/compiler/__init__.py +263 -0
  91. programasweights-0.1.0.dev1/programasweights/compiler/dummy.py +24 -0
  92. programasweights-0.1.0.dev1/programasweights/config.py +62 -0
  93. programasweights-0.1.0.dev1/programasweights/convert_peft_to_paw.py +187 -0
  94. programasweights-0.1.0.dev1/programasweights/paw_format.py +330 -0
  95. programasweights-0.1.0.dev1/programasweights/runtime/__init__.py +22 -0
  96. programasweights-0.1.0.dev1/programasweights/runtime/interpreter.py +485 -0
  97. programasweights-0.1.0.dev1/programasweights/runtime/interpreter_onnx.py +534 -0
  98. programasweights-0.1.0.dev1/programasweights/runtime_llamacpp.py +126 -0
  99. programasweights-0.1.0.dev1/programasweights_lora/__init__.py +28 -0
  100. programasweights-0.1.0.dev1/programasweights_lora/compiler/__init__.py +112 -0
  101. programasweights-0.1.0.dev1/programasweights_lora/lora_format.py +193 -0
  102. programasweights-0.1.0.dev1/programasweights_lora/runtime/__init__.py +6 -0
  103. programasweights-0.1.0.dev1/programasweights_lora/runtime/interpreter_lora.py +267 -0
  104. programasweights-0.1.0.dev1/programasweights_lora/tests/test_compile_and_run.py +67 -0
  105. programasweights-0.1.0.dev1/programasweights_lora/tests/test_lora_format.py +91 -0
  106. programasweights-0.1.0.dev1/programasweights_lora/tests/test_training.py +153 -0
  107. programasweights-0.1.0.dev1/programasweights_lora/train_lora.py +101 -0
  108. programasweights-0.1.0.dev1/programasweights_lora/training/__init__.py +6 -0
  109. programasweights-0.1.0.dev1/programasweights_lora/training/loops/lora_tuning_sft.py +655 -0
  110. programasweights-0.1.0.dev1/pyproject.toml +46 -0
  111. programasweights-0.1.0.dev1/run_eval.sh +95 -0
  112. programasweights-0.1.0.dev1/run_training.sh +70 -0
  113. programasweights-0.1.0.dev1/scripts/filter_table_by_length.py +150 -0
  114. programasweights-0.1.0.dev1/server/.env.example +47 -0
  115. programasweights-0.1.0.dev1/server/api/__init__.py +0 -0
  116. programasweights-0.1.0.dev1/server/api/config.py +73 -0
  117. programasweights-0.1.0.dev1/server/api/logging_config.py +74 -0
  118. programasweights-0.1.0.dev1/server/api/main.py +119 -0
  119. programasweights-0.1.0.dev1/server/api/models/__init__.py +0 -0
  120. programasweights-0.1.0.dev1/server/api/models/schemas.py +211 -0
  121. programasweights-0.1.0.dev1/server/api/routes/__init__.py +0 -0
  122. programasweights-0.1.0.dev1/server/api/routes/auth.py +77 -0
  123. programasweights-0.1.0.dev1/server/api/routes/compile.py +161 -0
  124. programasweights-0.1.0.dev1/server/api/routes/health.py +24 -0
  125. programasweights-0.1.0.dev1/server/api/routes/infer.py +87 -0
  126. programasweights-0.1.0.dev1/server/api/routes/models_info.py +24 -0
  127. programasweights-0.1.0.dev1/server/api/routes/programs.py +47 -0
  128. programasweights-0.1.0.dev1/server/api/services/__init__.py +0 -0
  129. programasweights-0.1.0.dev1/server/api/services/compile_service.py +454 -0
  130. programasweights-0.1.0.dev1/server/api/services/infer_service.py +263 -0
  131. programasweights-0.1.0.dev1/server/benchmarks/benchmark_api.py +301 -0
  132. programasweights-0.1.0.dev1/server/benchmarks/handcrafted_specs.json +130 -0
  133. programasweights-0.1.0.dev1/server/benchmarks/last_benchmark_results.json +266 -0
  134. programasweights-0.1.0.dev1/server/benchmarks/last_stress_results.json +92 -0
  135. programasweights-0.1.0.dev1/server/benchmarks/stress_test.py +696 -0
  136. programasweights-0.1.0.dev1/server/requirements.txt +25 -0
  137. programasweights-0.1.0.dev1/server/scripts/start_services.sh +85 -0
  138. programasweights-0.1.0.dev1/server/tests/__init__.py +0 -0
  139. programasweights-0.1.0.dev1/server/tests/conftest.py +86 -0
  140. programasweights-0.1.0.dev1/server/tests/test_auth.py +52 -0
  141. programasweights-0.1.0.dev1/server/tests/test_compile.py +97 -0
  142. programasweights-0.1.0.dev1/server/tests/test_errors.py +60 -0
  143. programasweights-0.1.0.dev1/server/tests/test_infer.py +72 -0
  144. programasweights-0.1.0.dev1/server/tests/test_integration_gpu.py +183 -0
  145. programasweights-0.1.0.dev1/server/tests/test_rate_limit.py +59 -0
  146. programasweights-0.1.0.dev1/server/vllm_models/__init__.py +0 -0
  147. programasweights-0.1.0.dev1/server/vllm_models/paw_compiler.py +397 -0
  148. programasweights-0.1.0.dev1/server/vllm_models/prepare_checkpoint.py +143 -0
  149. programasweights-0.1.0.dev1/server/vllm_models/register.py +17 -0
  150. programasweights-0.1.0.dev1/stage2_firstpromptqwen_512_e1_generate_lora_e2grpo_overfit_one_debug.reward_plot.rollout_ppl.png +0 -0
  151. programasweights-0.1.0.dev1/stage2_firstpromptqwen_512_e1_generate_lora_e2grpo_overfit_one_debug.reward_plot.train_gt_logprob.em_es.png +0 -0
  152. programasweights-0.1.0.dev1/stage2_firstpromptqwen_512_e1_generate_lora_e2grpo_overfit_one_debug.reward_plot.train_gt_logprob.ppl.png +0 -0
  153. programasweights-0.1.0.dev1/stage2_firstpromptqwen_512_e1_generate_lora_e2grpo_overfit_one_debug.reward_plot.train_gt_logprob.reward.png +0 -0
  154. programasweights-0.1.0.dev1/test_1spec.py +18 -0
  155. programasweights-0.1.0.dev1/test_all_caching.py +167 -0
  156. programasweights-0.1.0.dev1/test_apple_count.py +84 -0
  157. programasweights-0.1.0.dev1/test_batch_pilot.py +593 -0
  158. programasweights-0.1.0.dev1/test_compile.py +10 -0
  159. programasweights-0.1.0.dev1/test_e2e.py +363 -0
  160. programasweights-0.1.0.dev1/test_execute.py +6 -0
  161. programasweights-0.1.0.dev1/test_nspecs.py +18 -0
  162. programasweights-0.1.0.dev1/test_one_vs_two_step.py +149 -0
  163. programasweights-0.1.0.dev1/test_onnx_correctness.py +430 -0
  164. programasweights-0.1.0.dev1/test_onnx_hf_model.py +39 -0
  165. programasweights-0.1.0.dev1/test_onnx_hf_with_images.py +158 -0
  166. programasweights-0.1.0.dev1/test_paw_format.py +144 -0
  167. programasweights-0.1.0.dev1/test_thinking_comparison.py +542 -0
  168. programasweights-0.1.0.dev1/tests/test_programasweights.py +239 -0
  169. programasweights-0.1.0.dev1/train.py +153 -0
  170. programasweights-0.1.0.dev1/train_no_spec_direct_ans_mix_continuous_sampleref_trainonly_shorterprompt_withregularizer_generate_lora.py +3581 -0
  171. programasweights-0.1.0.dev1/training/README.md +45 -0
  172. programasweights-0.1.0.dev1/training/__init__.py +42 -0
  173. programasweights-0.1.0.dev1/training/data_generation/DATASET_CHANGELOG.md +1791 -0
  174. programasweights-0.1.0.dev1/training/data_generation/README.md +74 -0
  175. programasweights-0.1.0.dev1/training/data_generation/VERIFICATION_PIPELINE.md +259 -0
  176. programasweights-0.1.0.dev1/training/data_generation/dry_run_batch.py +248 -0
  177. programasweights-0.1.0.dev1/training/data_generation/filter_test_data.py +397 -0
  178. programasweights-0.1.0.dev1/training/data_generation/generate_specs.py +716 -0
  179. programasweights-0.1.0.dev1/training/data_generation/generate_specs_batch.py +368 -0
  180. programasweights-0.1.0.dev1/training/data_generation/incremental_merge.py +397 -0
  181. programasweights-0.1.0.dev1/training/data_generation/merge_and_upload.py +383 -0
  182. programasweights-0.1.0.dev1/training/data_generation/regenerate_outputs_batch.py +522 -0
  183. programasweights-0.1.0.dev1/training/data_generation/synthesize_data.py +536 -0
  184. programasweights-0.1.0.dev1/training/data_generation/synthesize_data_batch.py +389 -0
  185. programasweights-0.1.0.dev1/training/data_generation/templates/filter_system.txt +10 -0
  186. programasweights-0.1.0.dev1/training/data_generation/templates/filter_user.txt +9 -0
  187. programasweights-0.1.0.dev1/training/data_generation/templates/pairs_system.txt +3 -0
  188. programasweights-0.1.0.dev1/training/data_generation/templates/pairs_user.txt +14 -0
  189. programasweights-0.1.0.dev1/training/data_generation/templates/specs_system.txt +1 -0
  190. programasweights-0.1.0.dev1/training/data_generation/templates/specs_user.txt +11 -0
  191. programasweights-0.1.0.dev1/training/data_generation/templates/specs_user_freeform.txt +8 -0
  192. programasweights-0.1.0.dev1/training/data_generation/templates/specs_user_freeform_with_examples.txt +8 -0
  193. programasweights-0.1.0.dev1/training/data_generation/templates/specs_user_with_examples.txt +11 -0
  194. programasweights-0.1.0.dev1/training/data_generation/templates/verify_system.txt +10 -0
  195. programasweights-0.1.0.dev1/training/data_generation/templates/verify_user.txt +3 -0
  196. programasweights-0.1.0.dev1/training/data_generation/templates_old/filter_system.txt +10 -0
  197. programasweights-0.1.0.dev1/training/data_generation/templates_old/filter_user.txt +9 -0
  198. programasweights-0.1.0.dev1/training/data_generation/templates_old/pairs_system.txt +3 -0
  199. programasweights-0.1.0.dev1/training/data_generation/templates_old/pairs_user.txt +10 -0
  200. programasweights-0.1.0.dev1/training/data_generation/templates_old/specs_system.txt +1 -0
  201. programasweights-0.1.0.dev1/training/data_generation/templates_old/specs_user.txt +9 -0
  202. programasweights-0.1.0.dev1/training/data_generation/templates_old/specs_user_freeform.txt +8 -0
  203. programasweights-0.1.0.dev1/training/data_generation/templates_old/specs_user_freeform_with_examples.txt +8 -0
  204. programasweights-0.1.0.dev1/training/data_generation/templates_old/specs_user_with_examples.txt +10 -0
  205. programasweights-0.1.0.dev1/training/data_generation/templates_old/verify_system.txt +10 -0
  206. programasweights-0.1.0.dev1/training/data_generation/templates_old/verify_user.txt +3 -0
  207. programasweights-0.1.0.dev1/training/data_generation/verify_test_data.py +377 -0
  208. programasweights-0.1.0.dev1/training/datasets/__init__.py +1 -0
  209. programasweights-0.1.0.dev1/training/datasets/jsonl_text_pairs.py +186 -0
  210. programasweights-0.1.0.dev1/training/loops/__init__.py +1 -0
  211. programasweights-0.1.0.dev1/training/loops/prefix_tuning_sft.py +1297 -0
  212. programasweights-0.1.0.dev1/ttt.py +11 -0
  213. programasweights-0.1.0.dev1/upload_model.py +95 -0
  214. programasweights-0.1.0.dev1/upload_onnx_to_huggingface.py +242 -0
  215. programasweights-0.1.0.dev1/upload_onnx_to_huggingface_with_token.py +264 -0
  216. programasweights-0.1.0.dev1/utils.py +100 -0
  217. programasweights-0.1.0.dev1/web-app/HANDOFF.md +237 -0
  218. programasweights-0.1.0.dev1/web-app/README.md +187 -0
  219. programasweights-0.1.0.dev1/web-app/backend/app/__init__.py +1 -0
  220. programasweights-0.1.0.dev1/web-app/backend/app/config.py +71 -0
  221. programasweights-0.1.0.dev1/web-app/backend/app/main.py +1463 -0
  222. programasweights-0.1.0.dev1/web-app/backend/app/middleware/__init__.py +1 -0
  223. programasweights-0.1.0.dev1/web-app/backend/app/middleware/rate_limit.py +58 -0
  224. programasweights-0.1.0.dev1/web-app/backend/app/models.py +123 -0
  225. programasweights-0.1.0.dev1/web-app/backend/app/services/__init__.py +13 -0
  226. programasweights-0.1.0.dev1/web-app/backend/app/services/auth_service.py +172 -0
  227. programasweights-0.1.0.dev1/web-app/backend/app/services/case_service.py +201 -0
  228. programasweights-0.1.0.dev1/web-app/backend/app/services/compiler_service.py +202 -0
  229. programasweights-0.1.0.dev1/web-app/backend/app/services/gpt_service.py +166 -0
  230. programasweights-0.1.0.dev1/web-app/backend/app/services/hub_service.py +291 -0
  231. programasweights-0.1.0.dev1/web-app/backend/app/services/image_service.py +127 -0
  232. programasweights-0.1.0.dev1/web-app/backend/app/services/interpreter_service.py +179 -0
  233. programasweights-0.1.0.dev1/web-app/backend/app/services/sql_manager.py +1324 -0
  234. programasweights-0.1.0.dev1/web-app/backend/app/templates/gpt_test_generation.txt +42 -0
  235. programasweights-0.1.0.dev1/web-app/backend/app/utils/__init__.py +1 -0
  236. programasweights-0.1.0.dev1/web-app/backend/app/utils/image_placeholders.py +147 -0
  237. programasweights-0.1.0.dev1/web-app/backend/app/utils/program_hash.py +211 -0
  238. programasweights-0.1.0.dev1/web-app/backend/clear_db.sh +62 -0
  239. programasweights-0.1.0.dev1/web-app/backend/clear_tables.sql +29 -0
  240. programasweights-0.1.0.dev1/web-app/backend/data/programs.db +0 -0
  241. programasweights-0.1.0.dev1/web-app/backend/env_example.txt +24 -0
  242. programasweights-0.1.0.dev1/web-app/backend/example_images/README.md +140 -0
  243. programasweights-0.1.0.dev1/web-app/backend/get_data_examples.py +55 -0
  244. programasweights-0.1.0.dev1/web-app/backend/requirements.txt +10 -0
  245. programasweights-0.1.0.dev1/web-app/backend/run_server.py +27 -0
  246. programasweights-0.1.0.dev1/web-app/backend/setup_analytics_tables.sql +16 -0
  247. programasweights-0.1.0.dev1/web-app/backend/setup_auth_tables.sql +30 -0
  248. programasweights-0.1.0.dev1/web-app/backend/setup_cache_tables.sql +73 -0
  249. programasweights-0.1.0.dev1/web-app/backend/setup_cases_tables.sql +36 -0
  250. programasweights-0.1.0.dev1/web-app/backend/setup_database.sql +248 -0
  251. programasweights-0.1.0.dev1/web-app/backend/setup_database_simple.sql +113 -0
  252. programasweights-0.1.0.dev1/web-app/backend/setup_db.sh +52 -0
  253. programasweights-0.1.0.dev1/web-app/backend/setup_example_images.py +166 -0
  254. programasweights-0.1.0.dev1/web-app/backend/setup_hub_tables.sql +74 -0
  255. programasweights-0.1.0.dev1/web-app/backend/test_compilation_cache.py +85 -0
  256. programasweights-0.1.0.dev1/web-app/frontend/README.md +73 -0
  257. programasweights-0.1.0.dev1/web-app/frontend/eslint.config.js +23 -0
  258. programasweights-0.1.0.dev1/web-app/frontend/index.html +39 -0
  259. programasweights-0.1.0.dev1/web-app/frontend/package-lock.json +5181 -0
  260. programasweights-0.1.0.dev1/web-app/frontend/package.json +39 -0
  261. programasweights-0.1.0.dev1/web-app/frontend/postcss.config.js +6 -0
  262. programasweights-0.1.0.dev1/web-app/frontend/public/apple-touch-icon.png +0 -0
  263. programasweights-0.1.0.dev1/web-app/frontend/public/favicon-16x16.png +0 -0
  264. programasweights-0.1.0.dev1/web-app/frontend/public/favicon-32x32.png +0 -0
  265. programasweights-0.1.0.dev1/web-app/frontend/public/paw-192.png +0 -0
  266. programasweights-0.1.0.dev1/web-app/frontend/public/paw-512.png +0 -0
  267. programasweights-0.1.0.dev1/web-app/frontend/public/paw.svg +34 -0
  268. programasweights-0.1.0.dev1/web-app/frontend/public/react-test.html +112 -0
  269. programasweights-0.1.0.dev1/web-app/frontend/public/test.html +40 -0
  270. programasweights-0.1.0.dev1/web-app/frontend/public/vite.svg +1 -0
  271. programasweights-0.1.0.dev1/web-app/frontend/src/App.css +42 -0
  272. programasweights-0.1.0.dev1/web-app/frontend/src/App.tsx +58 -0
  273. programasweights-0.1.0.dev1/web-app/frontend/src/assets/react.svg +1 -0
  274. programasweights-0.1.0.dev1/web-app/frontend/src/components/AboutPage.tsx +177 -0
  275. programasweights-0.1.0.dev1/web-app/frontend/src/components/AutoTestSection.tsx +537 -0
  276. programasweights-0.1.0.dev1/web-app/frontend/src/components/CasesSection.tsx +406 -0
  277. programasweights-0.1.0.dev1/web-app/frontend/src/components/CollapsibleExamples.tsx +160 -0
  278. programasweights-0.1.0.dev1/web-app/frontend/src/components/CompileButtonWithConfig.tsx +115 -0
  279. programasweights-0.1.0.dev1/web-app/frontend/src/components/CompileSection.tsx +74 -0
  280. programasweights-0.1.0.dev1/web-app/frontend/src/components/CopyCodeSection.tsx +316 -0
  281. programasweights-0.1.0.dev1/web-app/frontend/src/components/DocsPage.tsx +294 -0
  282. programasweights-0.1.0.dev1/web-app/frontend/src/components/ExampleRow/ExampleRowEditor.tsx +169 -0
  283. programasweights-0.1.0.dev1/web-app/frontend/src/components/ExamplesInput.tsx +74 -0
  284. programasweights-0.1.0.dev1/web-app/frontend/src/components/Footer.tsx +88 -0
  285. programasweights-0.1.0.dev1/web-app/frontend/src/components/Header.tsx +211 -0
  286. programasweights-0.1.0.dev1/web-app/frontend/src/components/HubPage.tsx +293 -0
  287. programasweights-0.1.0.dev1/web-app/frontend/src/components/HubProgramPage.tsx +389 -0
  288. programasweights-0.1.0.dev1/web-app/frontend/src/components/HubUploadPage.tsx +222 -0
  289. programasweights-0.1.0.dev1/web-app/frontend/src/components/ImageUpload.tsx +206 -0
  290. programasweights-0.1.0.dev1/web-app/frontend/src/components/InputBlocks/ImageBlock.tsx +153 -0
  291. programasweights-0.1.0.dev1/web-app/frontend/src/components/InputBlocks/InputBlockList.tsx +151 -0
  292. programasweights-0.1.0.dev1/web-app/frontend/src/components/InputBlocks/TextBlock.tsx +80 -0
  293. programasweights-0.1.0.dev1/web-app/frontend/src/components/LandingPage.tsx +529 -0
  294. programasweights-0.1.0.dev1/web-app/frontend/src/components/LeaderboardPage.tsx +354 -0
  295. programasweights-0.1.0.dev1/web-app/frontend/src/components/MainInterface.tsx +568 -0
  296. programasweights-0.1.0.dev1/web-app/frontend/src/components/ModelSelector.tsx +55 -0
  297. programasweights-0.1.0.dev1/web-app/frontend/src/components/MultiImageUpload.tsx +210 -0
  298. programasweights-0.1.0.dev1/web-app/frontend/src/components/PricingPage.tsx +192 -0
  299. programasweights-0.1.0.dev1/web-app/frontend/src/components/PrivacyPage.tsx +101 -0
  300. programasweights-0.1.0.dev1/web-app/frontend/src/components/ProfilePage.tsx +272 -0
  301. programasweights-0.1.0.dev1/web-app/frontend/src/components/ProgramDetailPage.tsx +449 -0
  302. programasweights-0.1.0.dev1/web-app/frontend/src/components/PublishProgramPage.tsx +494 -0
  303. programasweights-0.1.0.dev1/web-app/frontend/src/components/SpecInput.tsx +499 -0
  304. programasweights-0.1.0.dev1/web-app/frontend/src/components/TermsPage.tsx +101 -0
  305. programasweights-0.1.0.dev1/web-app/frontend/src/components/TestSection.tsx +122 -0
  306. programasweights-0.1.0.dev1/web-app/frontend/src/index.css +48 -0
  307. programasweights-0.1.0.dev1/web-app/frontend/src/main.tsx +13 -0
  308. programasweights-0.1.0.dev1/web-app/frontend/src/types/index.ts +182 -0
  309. programasweights-0.1.0.dev1/web-app/frontend/src/utils/api.ts +84 -0
  310. programasweights-0.1.0.dev1/web-app/frontend/tailwind.config.js +67 -0
  311. programasweights-0.1.0.dev1/web-app/frontend/tsconfig.app.json +28 -0
  312. programasweights-0.1.0.dev1/web-app/frontend/tsconfig.json +7 -0
  313. programasweights-0.1.0.dev1/web-app/frontend/tsconfig.node.json +26 -0
  314. programasweights-0.1.0.dev1/web-app/frontend/vite.config.ts +17 -0
  315. programasweights-0.1.0.dev1/web-app/nginx-paw.conf +42 -0
  316. programasweights-0.1.0.dev1/web-app/nginx.conf +111 -0
  317. programasweights-0.1.0.dev1/web-app/setup_mysql.sh +145 -0
  318. programasweights-0.1.0.dev1/web-app/start.sh +102 -0
  319. programasweights-0.1.0.dev1/web-app/test_setup.py +160 -0
  320. programasweights-0.1.0.dev1/web-app/ttt.py +26 -0
  321. programasweights-0.1.0/.gitignore +0 -5
  322. programasweights-0.1.0/PKG-INFO +0 -19
  323. programasweights-0.1.0/PYPI_README.md +0 -7
  324. programasweights-0.1.0/programasweights/__init__.py +0 -13
  325. programasweights-0.1.0/pyproject.toml +0 -38
@@ -0,0 +1,76 @@
1
+ # Dependencies
2
+ node_modules/
3
+ npm-debug.log*
4
+ yarn-debug.log*
5
+ yarn-error.log*
6
+
7
+ # Build outputs
8
+ dist/
9
+ build/
10
+
11
+ # Cache directories
12
+ .vite/
13
+ .cache/
14
+
15
+ # Python
16
+ __pycache__/
17
+ *.pyc
18
+ *.pyo
19
+ .venv
20
+ .env
21
+
22
+ # System files
23
+ .DS_Store
24
+ Thumbs.db
25
+
26
+ # IDE
27
+ .vscode/
28
+ .idea/
29
+ *.swp
30
+ *.swo
31
+ *.swm
32
+ *.swn
33
+
34
+ # Compiled models and temp files
35
+ web-app/backend/compiled_models/
36
+ web-app/backend/temp/
37
+ web-app/backend/uploads/
38
+ outputs/
39
+ outputs_onnx/
40
+
41
+ # SQLite caches
42
+ cache.sqlite3
43
+ verify_cache.sqlite3
44
+ filter_cache.sqlite3
45
+
46
+ # Training data (large generated files)
47
+ data/batch_gpt52*/
48
+ data/merged_gpt52*/
49
+ data/regen_fuzzy_bench/
50
+ data/dry_run_gpt52/
51
+ data/pilot_test/
52
+ data/vqa_images/
53
+ data/ocr_data/
54
+ *.jsonl
55
+
56
+ # ONNX models
57
+ *.onnx
58
+ *.onnx_data
59
+
60
+ # Compiled neural programs
61
+ *.paw
62
+
63
+ # Log files
64
+ *.log
65
+
66
+ # Handwriting/OCR data
67
+ *.inkml
68
+
69
+ # Private config
70
+ init_private.sh
71
+
72
+ # Playground scratch space
73
+ playground/
74
+
75
+ # Large inspection logs (generated on server)
76
+ inspect_*.txt
@@ -0,0 +1,28 @@
1
+ [targets.sdist]
2
+ # Explicitly include only the source package folder
3
+ include = ["programasweights"]
4
+
5
+ # Exclude large or non-source folders
6
+ exclude = [
7
+ "outputs",
8
+ "outputs_1spec",
9
+ "outputs_1spec_bak",
10
+ "demo_weights.safetensors",
11
+ "dist",
12
+ "training",
13
+ "web-app",
14
+ "tests",
15
+ "data",
16
+ "__pycache__",
17
+ "*.egg-info",
18
+ "*.pt",
19
+ "*.safetensors",
20
+ "*.sqlite3",
21
+ "eval.py",
22
+ "train.py",
23
+ "upload_model.py",
24
+ "test_*.py",
25
+ ".git",
26
+ ".gitignore",
27
+ ".DS_Store"
28
+ ]
@@ -0,0 +1,13 @@
1
+ version: 2
2
+
3
+ build:
4
+ os: ubuntu-22.04
5
+ tools:
6
+ python: "3.11" # avoid 3.13 for now; many packages lag support
7
+
8
+ sphinx:
9
+ configuration: docs/conf.py
10
+
11
+ python:
12
+ install:
13
+ - requirements: docs/requirements.txt
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,202 @@
1
+ # ProgramAsWeights Data Flow Summary
2
+
3
+ ## Overview
4
+
5
+ This document explains how prefix tokens flow through training, compilation, and inference.
6
+
7
+ ## Three Stages
8
+
9
+ ### 1. Training (`train.py` → `training/loops/prefix_tuning_sft.py`)
10
+
11
+ **Purpose**: Learn to map specs to KV caches via prefix tokens
12
+
13
+ ```python
14
+ # Stage: TRAINING
15
+ spec = "Parse (A) (B) (C) into JSON list"
16
+ input = "(A) cat (B) dog"
17
+ output = '["cat", "dog"]'
18
+
19
+ # Flow:
20
+ 1. Add prefix tokens to spec:
21
+ spec_tokens = tokenize(spec) # [tok1, tok2, ..., tokN]
22
+ spec_with_prefix = spec_tokens + [<PREFIX_0>, <PREFIX_1>, ..., <PREFIX_4>]
23
+
24
+ 2. Run through compiler:
25
+ hidden = compiler(spec_with_prefix) # [batch, seq_len, hidden_dim]
26
+
27
+ 3. Extract prefix token hidden states:
28
+ prefix_hiddens = hidden[:, -5:, :] # Last 5 positions
29
+
30
+ 4. Map to KV cache:
31
+ kv_cache = mapper(prefix_hiddens) # [batch, layers, 2, heads, prefix_steps, head_dim]
32
+
33
+ 5. Use KV cache in interpreter:
34
+ logits = interpreter(input_tokens, past_key_values=kv_cache)
35
+
36
+ 6. Compute loss against output:
37
+ loss = cross_entropy(logits, output_tokens)
38
+
39
+ 7. Backprop through entire chain:
40
+ loss.backward() # Updates: compiler embeddings, mapper, (optionally) models
41
+ ```
42
+
43
+ **Saves**:
44
+ - `checkpoint/compiler/` - Compiler model with prefix token embeddings
45
+ - `checkpoint/interpreter/` - Interpreter model
46
+ - `checkpoint/compiler/mapper.pt` - Mapper weights + metadata
47
+
48
+ ---
49
+
50
+ ### 2. Compilation (`eval.py` or `paw.compile()`)
51
+
52
+ **Purpose**: Convert a new spec into a standalone `.paw` file
53
+
54
+ ```python
55
+ # Stage: COMPILATION
56
+ spec = "Extract numbers from text" # New, unseen spec
57
+
58
+ # Flow:
59
+ 1. Load trained model:
60
+ model = JointCompilerInterpreter(
61
+ compiler_model_name="checkpoint/compiler", # Has prefix tokens!
62
+ interpreter_model_name="checkpoint/interpreter",
63
+ prefix_steps=5
64
+ )
65
+ # Note: Tokenizer loaded from checkpoint already has prefix tokens
66
+
67
+ 2. Add prefix tokens to new spec:
68
+ spec_tokens = tokenize(spec)
69
+ spec_with_prefix = spec_tokens + model.prefix_token_ids
70
+
71
+ 3. Run through trained compiler:
72
+ hidden = model.compiler(spec_with_prefix)
73
+
74
+ 4. Extract prefix token hidden states:
75
+ prefix_hiddens = hidden[:, -5:, :]
76
+
77
+ 5. Map to KV cache using trained mapper:
78
+ kv_cache = model.mapper(prefix_hiddens)
79
+
80
+ 6. Save KV cache to .paw file:
81
+ save_paw_program(
82
+ filepath="program.paw",
83
+ kv_layers=kv_cache,
84
+ spec=spec, # For reference only
85
+ base_model="interpreter_model_name",
86
+ prefix_steps=5
87
+ )
88
+ ```
89
+
90
+ **Saves**:
91
+ - `program.paw` - Contains only the KV cache (not the spec with prefix tokens!)
92
+
93
+ ---
94
+
95
+ ### 3. Inference (`paw.function()`)
96
+
97
+ **Purpose**: Run a compiled program on new inputs
98
+
99
+ ```python
100
+ # Stage: INFERENCE
101
+ f = paw.function("program.paw")
102
+ output = f("Extract from: 123 and 456")
103
+
104
+ # Flow:
105
+ 1. Load .paw file:
106
+ kv_cache = load_paw_program("program.paw")
107
+ # kv_cache = precomputed KV prefix from compilation
108
+ # NO spec, NO prefix tokens - just the cache!
109
+
110
+ 2. Tokenize input and add separator:
111
+ input_tokens = tokenize(input) + [<BOS>] # Separator for generation
112
+
113
+ 3. Run through interpreter with KV cache:
114
+ logits = interpreter(input_tokens, past_key_values=kv_cache)
115
+
116
+ 4. Generate output:
117
+ output_tokens = generate(logits, max_new_tokens=128)
118
+ output = detokenize(output_tokens)
119
+ ```
120
+
121
+ **No compilation needed** - the KV cache is already computed and saved!
122
+
123
+ ---
124
+
125
+ ## Key Points
126
+
127
+ ### Prefix Tokens:
128
+ - ✅ **Training**: Added to every spec, embeddings learned
129
+ - ✅ **Compilation**: Added to new spec, uses learned embeddings
130
+ - ❌ **Inference**: NOT used - we use precomputed KV cache
131
+
132
+ ### What Gets Saved:
133
+ - **Training checkpoint**: Compiler (with prefix tokens) + Interpreter + Mapper
134
+ - **.paw file**: Only KV cache (no spec, no prefix tokens)
135
+
136
+ ### Why This Works:
137
+ ```
138
+ Training: spec + prefix_tokens → compiler → hidden → mapper → KV cache
139
+
140
+ Compilation: new_spec + prefix_tokens → trained_compiler → hidden → trained_mapper → KV cache → save to .paw
141
+
142
+ Inference: input → interpreter(past_kv=loaded_from_.paw) → output
143
+ ```
144
+
145
+ The prefix tokens are a **compilation-time mechanism** to create good KV caches. Once compiled, the KV cache is all you need!
146
+
147
+ ---
148
+
149
+ ## Checkpoint Loading
150
+
151
+ When loading from checkpoint during compilation:
152
+
153
+ ```python
154
+ # 1. Create model (loads tokenizer from checkpoint directory)
155
+ model = JointCompilerInterpreter(
156
+ compiler_model_name="checkpoint/compiler", # Directory path
157
+ ...
158
+ )
159
+
160
+ # 2. Tokenizer already has prefix tokens (saved during training)
161
+ # 3. Model detects this and skips adding them again:
162
+ if tokens_already_exist:
163
+ print("Prefix tokens already exist in tokenizer (loaded from checkpoint)")
164
+ num_added = 0
165
+ else:
166
+ # Only happens during initial training
167
+ num_added = tokenizer.add_special_tokens(...)
168
+ compiler.resize_token_embeddings(len(tokenizer))
169
+ ```
170
+
171
+ ---
172
+
173
+ ## Summary Table
174
+
175
+ | Stage | Uses Prefix Tokens? | Uses Compiler? | Uses Interpreter? | Input | Output |
176
+ |-------------|---------------------|----------------|-------------------|----------------------|---------------------|
177
+ | Training | ✅ Yes | ✅ Yes | ✅ Yes | spec, input, output | Updated models |
178
+ | Compilation | ✅ Yes | ✅ Yes | ❌ No | spec | .paw file (KV cache)|
179
+ | Inference | ❌ No | ❌ No | ✅ Yes | input | output |
180
+
181
+ ---
182
+
183
+ ## Example End-to-End
184
+
185
+ ```python
186
+ # 1. TRAINING (once)
187
+ python train.py --train-jsonl data/samples_train.jsonl
188
+ # → Creates checkpoint/ with compiler+interpreter+mapper
189
+
190
+ # 2. COMPILATION (per program)
191
+ import programasweights as paw
192
+ paw.compile("my_parser.paw", spec="Parse (A)(B)(C) format", checkpoint_dir="checkpoint/")
193
+ # → Creates my_parser.paw with KV cache
194
+
195
+ # 3. INFERENCE (many times)
196
+ f = paw.function("my_parser.paw")
197
+ result = f("(A) apple (B) banana (C) cherry")
198
+ print(result) # ["apple", "banana", "cherry"]
199
+ # → Fast! No compilation, just interpreter + cached KV
200
+ ```
201
+
202
+ The magic: **Train once, compile many programs, run them infinitely fast!**
@@ -22,3 +22,4 @@ exclude upload_model.py
22
22
  exclude *.pt
23
23
  exclude *.safetensors
24
24
  exclude *.sqlite3
25
+ exclude outputs/*
@@ -0,0 +1,84 @@
1
+ # ONNX Migration Plan
2
+
3
+ Complete plan for migrating programasweights to ONNX Runtime.
4
+
5
+ ## Goals
6
+
7
+ - **10-15x faster Time-to-First-Result** (2 min vs 15-20 min)
8
+ - **5-10x smaller disk usage** (500MB vs 3-4GB)
9
+ - **Maintain correctness** (outputs match PyTorch exactly)
10
+ - **Backward compatible** (same API: `paw.function()`)
11
+
12
+ ## Architecture
13
+
14
+ ### Three ONNX Models:
15
+
16
+ **1. Text Embeddings (`text_embeddings.onnx`)**
17
+ - Input: `input_ids` [batch, seq_len] int64
18
+ - Output: `embeddings` [batch, seq_len, hidden_size] float32
19
+ - Source: `model.get_input_embeddings()`
20
+
21
+ **2. Image Encoder (`image_encoder.onnx`)**
22
+ - Input: `pixel_values` [batch, 3, 224, 224] float32
23
+ - Output: `image_embeddings` [batch, 196, hidden_size] float32
24
+ - Source: CLIP vision encoder
25
+
26
+ **3. Interpreter (`interpreter.onnx`)**
27
+ - Inputs:
28
+ - `embeddings` [batch, seq_len, hidden_size] float32
29
+ - `past_key_values` [2*num_layers, batch, num_heads, past_len, head_dim] float32
30
+ - Outputs:
31
+ - `logits` [batch, seq_len, vocab_size] float32
32
+ - `new_key_values` [2*num_layers, batch, num_heads, NEW_seq_len, head_dim] float32
33
+ - Source: Interpreter model (forward pass only, KV handled externally)
34
+
35
+ ### KV Cache Strategy:
36
+
37
+ **Return NEW cache only** (not full updated cache):
38
+ ```python
39
+ # Python handles concatenation
40
+ past_kv = initial_kv # [2*L, B, H, 5, D] (prefix)
41
+ new_kv = interpreter(emb, past_kv) # [2*L, B, H, 1, D] (new token)
42
+ updated_kv = concat(past_kv, new_kv, axis=3) # [2*L, B, H, 6, D]
43
+ ```
44
+
45
+ This matches transformers' behavior and is memory-efficient.
46
+
47
+ ## Implementation Steps
48
+
49
+ ### Phase 1: Export Models (Text-only)
50
+ 1. Export text embeddings model
51
+ 2. Export interpreter model (with KV cache I/O)
52
+ 3. Test correctness (compare PyTorch vs ONNX outputs)
53
+
54
+ ### Phase 2: ONNX Runtime
55
+ 1. Create ONNX-based interpreter class
56
+ 2. Implement KV cache management
57
+ 3. Implement generation loop
58
+ 4. Test end-to-end
59
+
60
+ ### Phase 3: Image Support
61
+ 1. Export image encoder
62
+ 2. Update runtime to handle images
63
+ 3. Test multimodal programs
64
+
65
+ ### Phase 4: Optimization
66
+ 1. Quantization (INT8)
67
+ 2. Graph optimization
68
+ 3. Benchmark improvements
69
+
70
+ ## Scripts to Create
71
+
72
+ 1. `export_to_onnx.py` - Export PyTorch models to ONNX
73
+ 2. `test_onnx_correctness.py` - Verify ONNX outputs match PyTorch
74
+ 3. `onnx_runtime/interpreter.py` - ONNX-based runtime
75
+ 4. `benchmark_onnx.py` - Benchmark ONNX version
76
+
77
+ ## Success Criteria
78
+
79
+ - ✅ All tests pass (outputs match within 1e-5)
80
+ - ✅ Time-to-First-Result < 2 minutes
81
+ - ✅ Disk usage < 500MB
82
+ - ✅ Inference latency < 100ms
83
+ - ✅ API unchanged (backward compatible)
84
+
@@ -0,0 +1,127 @@
1
+ Metadata-Version: 2.4
2
+ Name: programasweights
3
+ Version: 0.1.0.dev1
4
+ Summary: Compile natural language specifications into neural programs that run locally via llama.cpp.
5
+ Author-email: ProgramAsWeights <support@programasweights.com>
6
+ License: MIT
7
+ Keywords: inference,llama-cpp,lora,neural-programs,nlp
8
+ Classifier: Development Status :: 3 - Alpha
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: Intended Audience :: Science/Research
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.9
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
18
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
19
+ Requires-Python: >=3.9
20
+ Requires-Dist: httpx>=0.27.0
21
+ Requires-Dist: llama-cpp-python>=0.3.0
22
+ Provides-Extra: test
23
+ Requires-Dist: pytest; extra == 'test'
24
+ Description-Content-Type: text/markdown
25
+
26
+ # ProgramAsWeights
27
+
28
+ **Compile natural language specifications into neural programs (.paw files) that run locally.**
29
+
30
+ 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.
31
+
32
+ ## Installation
33
+
34
+ ```bash
35
+ pip install programasweights
36
+ ```
37
+
38
+ ## Quick Start
39
+
40
+ ### Run a Program
41
+
42
+ ```python
43
+ import programasweights as paw
44
+
45
+ # Load and run a compiled program
46
+ fn = paw.function("program_id_or_path.paw")
47
+ result = fn("Contact alice@company.com or bob@example.org")
48
+ print(result) # ["alice@company.com", "bob@example.org"]
49
+ ```
50
+
51
+ ### Compile a Program
52
+
53
+ ```python
54
+ import programasweights as paw
55
+
56
+ # Compile from natural language specification
57
+ paw.compile(
58
+ "output.paw",
59
+ spec="Extract all email addresses from text and return as JSON list",
60
+ checkpoint_dir="path/to/trained/compiler",
61
+ )
62
+ ```
63
+
64
+ ## LoRA Support (PEFT Compatible)
65
+
66
+ Already using PEFT for LoRA training? Convert to .paw in one line:
67
+
68
+ ```python
69
+ import programasweights as paw
70
+
71
+ # Standard PEFT workflow:
72
+ # model = get_peft_model(base_model, LoraConfig(r=16, target_modules=["q_proj", "v_proj"]))
73
+ # trainer.train()
74
+ # model.save_pretrained("my_adapter/")
75
+
76
+ # Convert to .paw:
77
+ paw.from_peft(
78
+ "my_adapter/", # Your PEFT checkpoint
79
+ "sentiment.paw", # Output .paw file
80
+ spec="Classify sentiment as positive or negative",
81
+ tags=["sentiment", "classification"],
82
+ examples=[
83
+ {"input": "Great movie!", "output": "positive"},
84
+ {"input": "Terrible film.", "output": "negative"},
85
+ ],
86
+ )
87
+
88
+ # Use it:
89
+ fn = paw.function("sentiment.paw")
90
+ print(fn("This is amazing!")) # → "positive"
91
+ ```
92
+
93
+ Load LoRA from a .paw file:
94
+
95
+ ```python
96
+ lora_weights, lora_config = paw.load_paw_lora("sentiment.paw")
97
+ print(lora_config) # {"rank": 16, "alpha": 32, ...}
98
+ ```
99
+
100
+ Or use `save_lora_to_paw()` directly if you have raw tensors instead of a PEFT checkpoint.
101
+
102
+ ## .paw File Format v2
103
+
104
+ A `.paw` file is a self-contained neural program that includes:
105
+
106
+ | Component | Description | Required |
107
+ |-----------|-------------|----------|
108
+ | KV cache prefix | Continuous program (prefix weights) | Optional |
109
+ | Pseudo-program | Discrete text instructions | Optional |
110
+ | LoRA adapter | Fine-tuned adapter weights | Optional |
111
+ | Generation config | Temperature, top_p, max_tokens | Optional |
112
+ | Metadata | Interpreter model, spec, author, tags | Required |
113
+
114
+ ## Program Hub
115
+
116
+ Browse and share programs at [hub.programasweights.com](https://hub.programasweights.com)
117
+
118
+ ## Links
119
+
120
+ - **Website**: [programasweights.com](https://programasweights.com)
121
+ - **Documentation**: [programasweights.readthedocs.io](https://programasweights.readthedocs.io)
122
+ - **GitHub**: [github.com/programasweights/programasweights](https://github.com/programasweights/programasweights)
123
+ - **Program Hub**: [hub.programasweights.com](https://hub.programasweights.com)
124
+
125
+ ## License
126
+
127
+ MIT