@synsci/cli-darwin-x64 1.1.49

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 (373) hide show
  1. package/bin/skills/accelerate/SKILL.md +332 -0
  2. package/bin/skills/accelerate/references/custom-plugins.md +453 -0
  3. package/bin/skills/accelerate/references/megatron-integration.md +489 -0
  4. package/bin/skills/accelerate/references/performance.md +525 -0
  5. package/bin/skills/audiocraft/SKILL.md +564 -0
  6. package/bin/skills/audiocraft/references/advanced-usage.md +666 -0
  7. package/bin/skills/audiocraft/references/troubleshooting.md +504 -0
  8. package/bin/skills/autogpt/SKILL.md +403 -0
  9. package/bin/skills/autogpt/references/advanced-usage.md +535 -0
  10. package/bin/skills/autogpt/references/troubleshooting.md +420 -0
  11. package/bin/skills/awq/SKILL.md +310 -0
  12. package/bin/skills/awq/references/advanced-usage.md +324 -0
  13. package/bin/skills/awq/references/troubleshooting.md +344 -0
  14. package/bin/skills/axolotl/SKILL.md +158 -0
  15. package/bin/skills/axolotl/references/api.md +5548 -0
  16. package/bin/skills/axolotl/references/dataset-formats.md +1029 -0
  17. package/bin/skills/axolotl/references/index.md +15 -0
  18. package/bin/skills/axolotl/references/other.md +3563 -0
  19. package/bin/skills/bigcode-evaluation-harness/SKILL.md +405 -0
  20. package/bin/skills/bigcode-evaluation-harness/references/benchmarks.md +393 -0
  21. package/bin/skills/bigcode-evaluation-harness/references/custom-tasks.md +424 -0
  22. package/bin/skills/bigcode-evaluation-harness/references/issues.md +394 -0
  23. package/bin/skills/bitsandbytes/SKILL.md +411 -0
  24. package/bin/skills/bitsandbytes/references/memory-optimization.md +521 -0
  25. package/bin/skills/bitsandbytes/references/qlora-training.md +521 -0
  26. package/bin/skills/bitsandbytes/references/quantization-formats.md +447 -0
  27. package/bin/skills/blip-2/SKILL.md +564 -0
  28. package/bin/skills/blip-2/references/advanced-usage.md +680 -0
  29. package/bin/skills/blip-2/references/troubleshooting.md +526 -0
  30. package/bin/skills/chroma/SKILL.md +406 -0
  31. package/bin/skills/chroma/references/integration.md +38 -0
  32. package/bin/skills/clip/SKILL.md +253 -0
  33. package/bin/skills/clip/references/applications.md +207 -0
  34. package/bin/skills/constitutional-ai/SKILL.md +290 -0
  35. package/bin/skills/crewai/SKILL.md +498 -0
  36. package/bin/skills/crewai/references/flows.md +438 -0
  37. package/bin/skills/crewai/references/tools.md +429 -0
  38. package/bin/skills/crewai/references/troubleshooting.md +480 -0
  39. package/bin/skills/deepspeed/SKILL.md +141 -0
  40. package/bin/skills/deepspeed/references/08.md +17 -0
  41. package/bin/skills/deepspeed/references/09.md +173 -0
  42. package/bin/skills/deepspeed/references/2020.md +378 -0
  43. package/bin/skills/deepspeed/references/2023.md +279 -0
  44. package/bin/skills/deepspeed/references/assets.md +179 -0
  45. package/bin/skills/deepspeed/references/index.md +35 -0
  46. package/bin/skills/deepspeed/references/mii.md +118 -0
  47. package/bin/skills/deepspeed/references/other.md +1191 -0
  48. package/bin/skills/deepspeed/references/tutorials.md +6554 -0
  49. package/bin/skills/dspy/SKILL.md +590 -0
  50. package/bin/skills/dspy/references/examples.md +663 -0
  51. package/bin/skills/dspy/references/modules.md +475 -0
  52. package/bin/skills/dspy/references/optimizers.md +566 -0
  53. package/bin/skills/faiss/SKILL.md +221 -0
  54. package/bin/skills/faiss/references/index_types.md +280 -0
  55. package/bin/skills/flash-attention/SKILL.md +367 -0
  56. package/bin/skills/flash-attention/references/benchmarks.md +215 -0
  57. package/bin/skills/flash-attention/references/transformers-integration.md +293 -0
  58. package/bin/skills/gguf/SKILL.md +427 -0
  59. package/bin/skills/gguf/references/advanced-usage.md +504 -0
  60. package/bin/skills/gguf/references/troubleshooting.md +442 -0
  61. package/bin/skills/gptq/SKILL.md +450 -0
  62. package/bin/skills/gptq/references/calibration.md +337 -0
  63. package/bin/skills/gptq/references/integration.md +129 -0
  64. package/bin/skills/gptq/references/troubleshooting.md +95 -0
  65. package/bin/skills/grpo-rl-training/README.md +97 -0
  66. package/bin/skills/grpo-rl-training/SKILL.md +572 -0
  67. package/bin/skills/grpo-rl-training/examples/reward_functions_library.py +393 -0
  68. package/bin/skills/grpo-rl-training/templates/basic_grpo_training.py +228 -0
  69. package/bin/skills/guidance/SKILL.md +572 -0
  70. package/bin/skills/guidance/references/backends.md +554 -0
  71. package/bin/skills/guidance/references/constraints.md +674 -0
  72. package/bin/skills/guidance/references/examples.md +767 -0
  73. package/bin/skills/hqq/SKILL.md +445 -0
  74. package/bin/skills/hqq/references/advanced-usage.md +528 -0
  75. package/bin/skills/hqq/references/troubleshooting.md +503 -0
  76. package/bin/skills/hugging-face-cli/SKILL.md +191 -0
  77. package/bin/skills/hugging-face-cli/references/commands.md +954 -0
  78. package/bin/skills/hugging-face-cli/references/examples.md +374 -0
  79. package/bin/skills/hugging-face-datasets/SKILL.md +547 -0
  80. package/bin/skills/hugging-face-datasets/examples/diverse_training_examples.json +239 -0
  81. package/bin/skills/hugging-face-datasets/examples/system_prompt_template.txt +196 -0
  82. package/bin/skills/hugging-face-datasets/examples/training_examples.json +176 -0
  83. package/bin/skills/hugging-face-datasets/scripts/dataset_manager.py +522 -0
  84. package/bin/skills/hugging-face-datasets/scripts/sql_manager.py +844 -0
  85. package/bin/skills/hugging-face-datasets/templates/chat.json +55 -0
  86. package/bin/skills/hugging-face-datasets/templates/classification.json +62 -0
  87. package/bin/skills/hugging-face-datasets/templates/completion.json +51 -0
  88. package/bin/skills/hugging-face-datasets/templates/custom.json +75 -0
  89. package/bin/skills/hugging-face-datasets/templates/qa.json +54 -0
  90. package/bin/skills/hugging-face-datasets/templates/tabular.json +81 -0
  91. package/bin/skills/hugging-face-evaluation/SKILL.md +656 -0
  92. package/bin/skills/hugging-face-evaluation/examples/USAGE_EXAMPLES.md +382 -0
  93. package/bin/skills/hugging-face-evaluation/examples/artificial_analysis_to_hub.py +141 -0
  94. package/bin/skills/hugging-face-evaluation/examples/example_readme_tables.md +135 -0
  95. package/bin/skills/hugging-face-evaluation/examples/metric_mapping.json +50 -0
  96. package/bin/skills/hugging-face-evaluation/requirements.txt +20 -0
  97. package/bin/skills/hugging-face-evaluation/scripts/evaluation_manager.py +1374 -0
  98. package/bin/skills/hugging-face-evaluation/scripts/inspect_eval_uv.py +104 -0
  99. package/bin/skills/hugging-face-evaluation/scripts/inspect_vllm_uv.py +317 -0
  100. package/bin/skills/hugging-face-evaluation/scripts/lighteval_vllm_uv.py +303 -0
  101. package/bin/skills/hugging-face-evaluation/scripts/run_eval_job.py +98 -0
  102. package/bin/skills/hugging-face-evaluation/scripts/run_vllm_eval_job.py +331 -0
  103. package/bin/skills/hugging-face-evaluation/scripts/test_extraction.py +206 -0
  104. package/bin/skills/hugging-face-jobs/SKILL.md +1041 -0
  105. package/bin/skills/hugging-face-jobs/index.html +216 -0
  106. package/bin/skills/hugging-face-jobs/references/hardware_guide.md +336 -0
  107. package/bin/skills/hugging-face-jobs/references/hub_saving.md +352 -0
  108. package/bin/skills/hugging-face-jobs/references/token_usage.md +546 -0
  109. package/bin/skills/hugging-face-jobs/references/troubleshooting.md +475 -0
  110. package/bin/skills/hugging-face-jobs/scripts/cot-self-instruct.py +718 -0
  111. package/bin/skills/hugging-face-jobs/scripts/finepdfs-stats.py +546 -0
  112. package/bin/skills/hugging-face-jobs/scripts/generate-responses.py +587 -0
  113. package/bin/skills/hugging-face-model-trainer/SKILL.md +711 -0
  114. package/bin/skills/hugging-face-model-trainer/references/gguf_conversion.md +296 -0
  115. package/bin/skills/hugging-face-model-trainer/references/hardware_guide.md +283 -0
  116. package/bin/skills/hugging-face-model-trainer/references/hub_saving.md +364 -0
  117. package/bin/skills/hugging-face-model-trainer/references/reliability_principles.md +371 -0
  118. package/bin/skills/hugging-face-model-trainer/references/trackio_guide.md +189 -0
  119. package/bin/skills/hugging-face-model-trainer/references/training_methods.md +150 -0
  120. package/bin/skills/hugging-face-model-trainer/references/training_patterns.md +203 -0
  121. package/bin/skills/hugging-face-model-trainer/references/troubleshooting.md +282 -0
  122. package/bin/skills/hugging-face-model-trainer/scripts/convert_to_gguf.py +424 -0
  123. package/bin/skills/hugging-face-model-trainer/scripts/dataset_inspector.py +417 -0
  124. package/bin/skills/hugging-face-model-trainer/scripts/estimate_cost.py +150 -0
  125. package/bin/skills/hugging-face-model-trainer/scripts/train_dpo_example.py +106 -0
  126. package/bin/skills/hugging-face-model-trainer/scripts/train_grpo_example.py +89 -0
  127. package/bin/skills/hugging-face-model-trainer/scripts/train_sft_example.py +122 -0
  128. package/bin/skills/hugging-face-paper-publisher/SKILL.md +627 -0
  129. package/bin/skills/hugging-face-paper-publisher/examples/example_usage.md +327 -0
  130. package/bin/skills/hugging-face-paper-publisher/references/quick_reference.md +216 -0
  131. package/bin/skills/hugging-face-paper-publisher/scripts/paper_manager.py +508 -0
  132. package/bin/skills/hugging-face-paper-publisher/templates/arxiv.md +299 -0
  133. package/bin/skills/hugging-face-paper-publisher/templates/ml-report.md +358 -0
  134. package/bin/skills/hugging-face-paper-publisher/templates/modern.md +319 -0
  135. package/bin/skills/hugging-face-paper-publisher/templates/standard.md +201 -0
  136. package/bin/skills/hugging-face-tool-builder/SKILL.md +115 -0
  137. package/bin/skills/hugging-face-tool-builder/references/baseline_hf_api.py +57 -0
  138. package/bin/skills/hugging-face-tool-builder/references/baseline_hf_api.sh +40 -0
  139. package/bin/skills/hugging-face-tool-builder/references/baseline_hf_api.tsx +57 -0
  140. package/bin/skills/hugging-face-tool-builder/references/find_models_by_paper.sh +230 -0
  141. package/bin/skills/hugging-face-tool-builder/references/hf_enrich_models.sh +96 -0
  142. package/bin/skills/hugging-face-tool-builder/references/hf_model_card_frontmatter.sh +188 -0
  143. package/bin/skills/hugging-face-tool-builder/references/hf_model_papers_auth.sh +171 -0
  144. package/bin/skills/hugging-face-trackio/SKILL.md +65 -0
  145. package/bin/skills/hugging-face-trackio/references/logging_metrics.md +206 -0
  146. package/bin/skills/hugging-face-trackio/references/retrieving_metrics.md +223 -0
  147. package/bin/skills/huggingface-tokenizers/SKILL.md +516 -0
  148. package/bin/skills/huggingface-tokenizers/references/algorithms.md +653 -0
  149. package/bin/skills/huggingface-tokenizers/references/integration.md +637 -0
  150. package/bin/skills/huggingface-tokenizers/references/pipeline.md +723 -0
  151. package/bin/skills/huggingface-tokenizers/references/training.md +565 -0
  152. package/bin/skills/instructor/SKILL.md +740 -0
  153. package/bin/skills/instructor/references/examples.md +107 -0
  154. package/bin/skills/instructor/references/providers.md +70 -0
  155. package/bin/skills/instructor/references/validation.md +606 -0
  156. package/bin/skills/knowledge-distillation/SKILL.md +458 -0
  157. package/bin/skills/knowledge-distillation/references/minillm.md +334 -0
  158. package/bin/skills/lambda-labs/SKILL.md +545 -0
  159. package/bin/skills/lambda-labs/references/advanced-usage.md +611 -0
  160. package/bin/skills/lambda-labs/references/troubleshooting.md +530 -0
  161. package/bin/skills/langchain/SKILL.md +480 -0
  162. package/bin/skills/langchain/references/agents.md +499 -0
  163. package/bin/skills/langchain/references/integration.md +562 -0
  164. package/bin/skills/langchain/references/rag.md +600 -0
  165. package/bin/skills/langsmith/SKILL.md +422 -0
  166. package/bin/skills/langsmith/references/advanced-usage.md +548 -0
  167. package/bin/skills/langsmith/references/troubleshooting.md +537 -0
  168. package/bin/skills/litgpt/SKILL.md +469 -0
  169. package/bin/skills/litgpt/references/custom-models.md +568 -0
  170. package/bin/skills/litgpt/references/distributed-training.md +451 -0
  171. package/bin/skills/litgpt/references/supported-models.md +336 -0
  172. package/bin/skills/litgpt/references/training-recipes.md +619 -0
  173. package/bin/skills/llama-cpp/SKILL.md +258 -0
  174. package/bin/skills/llama-cpp/references/optimization.md +89 -0
  175. package/bin/skills/llama-cpp/references/quantization.md +213 -0
  176. package/bin/skills/llama-cpp/references/server.md +125 -0
  177. package/bin/skills/llama-factory/SKILL.md +80 -0
  178. package/bin/skills/llama-factory/references/_images.md +23 -0
  179. package/bin/skills/llama-factory/references/advanced.md +1055 -0
  180. package/bin/skills/llama-factory/references/getting_started.md +349 -0
  181. package/bin/skills/llama-factory/references/index.md +19 -0
  182. package/bin/skills/llama-factory/references/other.md +31 -0
  183. package/bin/skills/llamaguard/SKILL.md +337 -0
  184. package/bin/skills/llamaindex/SKILL.md +569 -0
  185. package/bin/skills/llamaindex/references/agents.md +83 -0
  186. package/bin/skills/llamaindex/references/data_connectors.md +108 -0
  187. package/bin/skills/llamaindex/references/query_engines.md +406 -0
  188. package/bin/skills/llava/SKILL.md +304 -0
  189. package/bin/skills/llava/references/training.md +197 -0
  190. package/bin/skills/lm-evaluation-harness/SKILL.md +490 -0
  191. package/bin/skills/lm-evaluation-harness/references/api-evaluation.md +490 -0
  192. package/bin/skills/lm-evaluation-harness/references/benchmark-guide.md +488 -0
  193. package/bin/skills/lm-evaluation-harness/references/custom-tasks.md +602 -0
  194. package/bin/skills/lm-evaluation-harness/references/distributed-eval.md +519 -0
  195. package/bin/skills/long-context/SKILL.md +536 -0
  196. package/bin/skills/long-context/references/extension_methods.md +468 -0
  197. package/bin/skills/long-context/references/fine_tuning.md +611 -0
  198. package/bin/skills/long-context/references/rope.md +402 -0
  199. package/bin/skills/mamba/SKILL.md +260 -0
  200. package/bin/skills/mamba/references/architecture-details.md +206 -0
  201. package/bin/skills/mamba/references/benchmarks.md +255 -0
  202. package/bin/skills/mamba/references/training-guide.md +388 -0
  203. package/bin/skills/megatron-core/SKILL.md +366 -0
  204. package/bin/skills/megatron-core/references/benchmarks.md +249 -0
  205. package/bin/skills/megatron-core/references/parallelism-guide.md +404 -0
  206. package/bin/skills/megatron-core/references/production-examples.md +473 -0
  207. package/bin/skills/megatron-core/references/training-recipes.md +547 -0
  208. package/bin/skills/miles/SKILL.md +315 -0
  209. package/bin/skills/miles/references/api-reference.md +141 -0
  210. package/bin/skills/miles/references/troubleshooting.md +352 -0
  211. package/bin/skills/mlflow/SKILL.md +704 -0
  212. package/bin/skills/mlflow/references/deployment.md +744 -0
  213. package/bin/skills/mlflow/references/model-registry.md +770 -0
  214. package/bin/skills/mlflow/references/tracking.md +680 -0
  215. package/bin/skills/modal/SKILL.md +341 -0
  216. package/bin/skills/modal/references/advanced-usage.md +503 -0
  217. package/bin/skills/modal/references/troubleshooting.md +494 -0
  218. package/bin/skills/model-merging/SKILL.md +539 -0
  219. package/bin/skills/model-merging/references/evaluation.md +462 -0
  220. package/bin/skills/model-merging/references/examples.md +428 -0
  221. package/bin/skills/model-merging/references/methods.md +352 -0
  222. package/bin/skills/model-pruning/SKILL.md +495 -0
  223. package/bin/skills/model-pruning/references/wanda.md +347 -0
  224. package/bin/skills/moe-training/SKILL.md +526 -0
  225. package/bin/skills/moe-training/references/architectures.md +432 -0
  226. package/bin/skills/moe-training/references/inference.md +348 -0
  227. package/bin/skills/moe-training/references/training.md +425 -0
  228. package/bin/skills/nanogpt/SKILL.md +290 -0
  229. package/bin/skills/nanogpt/references/architecture.md +382 -0
  230. package/bin/skills/nanogpt/references/data.md +476 -0
  231. package/bin/skills/nanogpt/references/training.md +564 -0
  232. package/bin/skills/nemo-curator/SKILL.md +383 -0
  233. package/bin/skills/nemo-curator/references/deduplication.md +87 -0
  234. package/bin/skills/nemo-curator/references/filtering.md +102 -0
  235. package/bin/skills/nemo-evaluator/SKILL.md +494 -0
  236. package/bin/skills/nemo-evaluator/references/adapter-system.md +340 -0
  237. package/bin/skills/nemo-evaluator/references/configuration.md +447 -0
  238. package/bin/skills/nemo-evaluator/references/custom-benchmarks.md +315 -0
  239. package/bin/skills/nemo-evaluator/references/execution-backends.md +361 -0
  240. package/bin/skills/nemo-guardrails/SKILL.md +297 -0
  241. package/bin/skills/nnsight/SKILL.md +436 -0
  242. package/bin/skills/nnsight/references/README.md +78 -0
  243. package/bin/skills/nnsight/references/api.md +344 -0
  244. package/bin/skills/nnsight/references/tutorials.md +300 -0
  245. package/bin/skills/openrlhf/SKILL.md +249 -0
  246. package/bin/skills/openrlhf/references/algorithm-comparison.md +404 -0
  247. package/bin/skills/openrlhf/references/custom-rewards.md +530 -0
  248. package/bin/skills/openrlhf/references/hybrid-engine.md +287 -0
  249. package/bin/skills/openrlhf/references/multi-node-training.md +454 -0
  250. package/bin/skills/outlines/SKILL.md +652 -0
  251. package/bin/skills/outlines/references/backends.md +615 -0
  252. package/bin/skills/outlines/references/examples.md +773 -0
  253. package/bin/skills/outlines/references/json_generation.md +652 -0
  254. package/bin/skills/peft/SKILL.md +431 -0
  255. package/bin/skills/peft/references/advanced-usage.md +514 -0
  256. package/bin/skills/peft/references/troubleshooting.md +480 -0
  257. package/bin/skills/phoenix/SKILL.md +475 -0
  258. package/bin/skills/phoenix/references/advanced-usage.md +619 -0
  259. package/bin/skills/phoenix/references/troubleshooting.md +538 -0
  260. package/bin/skills/pinecone/SKILL.md +358 -0
  261. package/bin/skills/pinecone/references/deployment.md +181 -0
  262. package/bin/skills/pytorch-fsdp/SKILL.md +126 -0
  263. package/bin/skills/pytorch-fsdp/references/index.md +7 -0
  264. package/bin/skills/pytorch-fsdp/references/other.md +4249 -0
  265. package/bin/skills/pytorch-lightning/SKILL.md +346 -0
  266. package/bin/skills/pytorch-lightning/references/callbacks.md +436 -0
  267. package/bin/skills/pytorch-lightning/references/distributed.md +490 -0
  268. package/bin/skills/pytorch-lightning/references/hyperparameter-tuning.md +556 -0
  269. package/bin/skills/pyvene/SKILL.md +473 -0
  270. package/bin/skills/pyvene/references/README.md +73 -0
  271. package/bin/skills/pyvene/references/api.md +383 -0
  272. package/bin/skills/pyvene/references/tutorials.md +376 -0
  273. package/bin/skills/qdrant/SKILL.md +493 -0
  274. package/bin/skills/qdrant/references/advanced-usage.md +648 -0
  275. package/bin/skills/qdrant/references/troubleshooting.md +631 -0
  276. package/bin/skills/ray-data/SKILL.md +326 -0
  277. package/bin/skills/ray-data/references/integration.md +82 -0
  278. package/bin/skills/ray-data/references/transformations.md +83 -0
  279. package/bin/skills/ray-train/SKILL.md +406 -0
  280. package/bin/skills/ray-train/references/multi-node.md +628 -0
  281. package/bin/skills/rwkv/SKILL.md +260 -0
  282. package/bin/skills/rwkv/references/architecture-details.md +344 -0
  283. package/bin/skills/rwkv/references/rwkv7.md +386 -0
  284. package/bin/skills/rwkv/references/state-management.md +369 -0
  285. package/bin/skills/saelens/SKILL.md +386 -0
  286. package/bin/skills/saelens/references/README.md +70 -0
  287. package/bin/skills/saelens/references/api.md +333 -0
  288. package/bin/skills/saelens/references/tutorials.md +318 -0
  289. package/bin/skills/segment-anything/SKILL.md +500 -0
  290. package/bin/skills/segment-anything/references/advanced-usage.md +589 -0
  291. package/bin/skills/segment-anything/references/troubleshooting.md +484 -0
  292. package/bin/skills/sentence-transformers/SKILL.md +255 -0
  293. package/bin/skills/sentence-transformers/references/models.md +123 -0
  294. package/bin/skills/sentencepiece/SKILL.md +235 -0
  295. package/bin/skills/sentencepiece/references/algorithms.md +200 -0
  296. package/bin/skills/sentencepiece/references/training.md +304 -0
  297. package/bin/skills/sglang/SKILL.md +442 -0
  298. package/bin/skills/sglang/references/deployment.md +490 -0
  299. package/bin/skills/sglang/references/radix-attention.md +413 -0
  300. package/bin/skills/sglang/references/structured-generation.md +541 -0
  301. package/bin/skills/simpo/SKILL.md +219 -0
  302. package/bin/skills/simpo/references/datasets.md +478 -0
  303. package/bin/skills/simpo/references/hyperparameters.md +452 -0
  304. package/bin/skills/simpo/references/loss-functions.md +350 -0
  305. package/bin/skills/skypilot/SKILL.md +509 -0
  306. package/bin/skills/skypilot/references/advanced-usage.md +491 -0
  307. package/bin/skills/skypilot/references/troubleshooting.md +570 -0
  308. package/bin/skills/slime/SKILL.md +464 -0
  309. package/bin/skills/slime/references/api-reference.md +392 -0
  310. package/bin/skills/slime/references/troubleshooting.md +386 -0
  311. package/bin/skills/speculative-decoding/SKILL.md +467 -0
  312. package/bin/skills/speculative-decoding/references/lookahead.md +309 -0
  313. package/bin/skills/speculative-decoding/references/medusa.md +350 -0
  314. package/bin/skills/stable-diffusion/SKILL.md +519 -0
  315. package/bin/skills/stable-diffusion/references/advanced-usage.md +716 -0
  316. package/bin/skills/stable-diffusion/references/troubleshooting.md +555 -0
  317. package/bin/skills/tensorboard/SKILL.md +629 -0
  318. package/bin/skills/tensorboard/references/integrations.md +638 -0
  319. package/bin/skills/tensorboard/references/profiling.md +545 -0
  320. package/bin/skills/tensorboard/references/visualization.md +620 -0
  321. package/bin/skills/tensorrt-llm/SKILL.md +187 -0
  322. package/bin/skills/tensorrt-llm/references/multi-gpu.md +298 -0
  323. package/bin/skills/tensorrt-llm/references/optimization.md +242 -0
  324. package/bin/skills/tensorrt-llm/references/serving.md +470 -0
  325. package/bin/skills/tinker/SKILL.md +362 -0
  326. package/bin/skills/tinker/references/api-reference.md +168 -0
  327. package/bin/skills/tinker/references/getting-started.md +157 -0
  328. package/bin/skills/tinker/references/loss-functions.md +163 -0
  329. package/bin/skills/tinker/references/models-and-lora.md +139 -0
  330. package/bin/skills/tinker/references/recipes.md +280 -0
  331. package/bin/skills/tinker/references/reinforcement-learning.md +212 -0
  332. package/bin/skills/tinker/references/rendering.md +243 -0
  333. package/bin/skills/tinker/references/supervised-learning.md +232 -0
  334. package/bin/skills/tinker-training-cost/SKILL.md +187 -0
  335. package/bin/skills/tinker-training-cost/scripts/calculate_cost.py +123 -0
  336. package/bin/skills/torchforge/SKILL.md +433 -0
  337. package/bin/skills/torchforge/references/api-reference.md +327 -0
  338. package/bin/skills/torchforge/references/troubleshooting.md +409 -0
  339. package/bin/skills/torchtitan/SKILL.md +358 -0
  340. package/bin/skills/torchtitan/references/checkpoint.md +181 -0
  341. package/bin/skills/torchtitan/references/custom-models.md +258 -0
  342. package/bin/skills/torchtitan/references/float8.md +133 -0
  343. package/bin/skills/torchtitan/references/fsdp.md +126 -0
  344. package/bin/skills/transformer-lens/SKILL.md +346 -0
  345. package/bin/skills/transformer-lens/references/README.md +54 -0
  346. package/bin/skills/transformer-lens/references/api.md +362 -0
  347. package/bin/skills/transformer-lens/references/tutorials.md +339 -0
  348. package/bin/skills/trl-fine-tuning/SKILL.md +455 -0
  349. package/bin/skills/trl-fine-tuning/references/dpo-variants.md +227 -0
  350. package/bin/skills/trl-fine-tuning/references/online-rl.md +82 -0
  351. package/bin/skills/trl-fine-tuning/references/reward-modeling.md +122 -0
  352. package/bin/skills/trl-fine-tuning/references/sft-training.md +168 -0
  353. package/bin/skills/unsloth/SKILL.md +80 -0
  354. package/bin/skills/unsloth/references/index.md +7 -0
  355. package/bin/skills/unsloth/references/llms-full.md +16799 -0
  356. package/bin/skills/unsloth/references/llms-txt.md +12044 -0
  357. package/bin/skills/unsloth/references/llms.md +82 -0
  358. package/bin/skills/verl/SKILL.md +391 -0
  359. package/bin/skills/verl/references/api-reference.md +301 -0
  360. package/bin/skills/verl/references/troubleshooting.md +391 -0
  361. package/bin/skills/vllm/SKILL.md +364 -0
  362. package/bin/skills/vllm/references/optimization.md +226 -0
  363. package/bin/skills/vllm/references/quantization.md +284 -0
  364. package/bin/skills/vllm/references/server-deployment.md +255 -0
  365. package/bin/skills/vllm/references/troubleshooting.md +447 -0
  366. package/bin/skills/weights-and-biases/SKILL.md +590 -0
  367. package/bin/skills/weights-and-biases/references/artifacts.md +584 -0
  368. package/bin/skills/weights-and-biases/references/integrations.md +700 -0
  369. package/bin/skills/weights-and-biases/references/sweeps.md +847 -0
  370. package/bin/skills/whisper/SKILL.md +317 -0
  371. package/bin/skills/whisper/references/languages.md +189 -0
  372. package/bin/synsc +0 -0
  373. package/package.json +10 -0
@@ -0,0 +1,767 @@
1
+ # Production-Ready Examples
2
+
3
+ Real-world examples of using Guidance for structured generation, agents, and workflows.
4
+
5
+ ## Table of Contents
6
+ - JSON Generation
7
+ - Data Extraction
8
+ - Classification Systems
9
+ - Agent Systems
10
+ - Multi-Step Workflows
11
+ - Code Generation
12
+ - Production Tips
13
+
14
+ ## JSON Generation
15
+
16
+ ### Basic JSON
17
+
18
+ ```python
19
+ from guidance import models, gen, guidance
20
+
21
+ @guidance
22
+ def generate_user(lm):
23
+ """Generate valid user JSON."""
24
+ lm += "{\n"
25
+ lm += ' "name": ' + gen("name", regex=r'"[A-Za-z ]+"') + ",\n"
26
+ lm += ' "age": ' + gen("age", regex=r"[0-9]+") + ",\n"
27
+ lm += ' "email": ' + gen(
28
+ "email",
29
+ regex=r'"[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}"'
30
+ ) + "\n"
31
+ lm += "}"
32
+ return lm
33
+
34
+ # Use it
35
+ lm = models.Anthropic("claude-sonnet-4-5-20250929")
36
+ lm += "Generate a user profile:\n"
37
+ lm = generate_user(lm)
38
+
39
+ print(lm)
40
+ # Output: Valid JSON guaranteed
41
+ ```
42
+
43
+ ### Nested JSON
44
+
45
+ ```python
46
+ @guidance
47
+ def generate_order(lm):
48
+ """Generate nested order JSON."""
49
+ lm += "{\n"
50
+
51
+ # Customer info
52
+ lm += ' "customer": {\n'
53
+ lm += ' "name": ' + gen("customer_name", regex=r'"[A-Za-z ]+"') + ",\n"
54
+ lm += ' "email": ' + gen(
55
+ "customer_email",
56
+ regex=r'"[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}"'
57
+ ) + "\n"
58
+ lm += " },\n"
59
+
60
+ # Order details
61
+ lm += ' "order": {\n'
62
+ lm += ' "id": ' + gen("order_id", regex=r'"ORD-[0-9]{6}"') + ",\n"
63
+ lm += ' "date": ' + gen("order_date", regex=r'"\d{4}-\d{2}-\d{2}"') + ",\n"
64
+ lm += ' "total": ' + gen("order_total", regex=r"[0-9]+\.[0-9]{2}") + "\n"
65
+ lm += " },\n"
66
+
67
+ # Status
68
+ lm += ' "status": ' + gen(
69
+ "status",
70
+ regex=r'"(pending|processing|shipped|delivered)"'
71
+ ) + "\n"
72
+
73
+ lm += "}"
74
+ return lm
75
+
76
+ lm = models.Anthropic("claude-sonnet-4-5-20250929")
77
+ lm = generate_order(lm)
78
+ ```
79
+
80
+ ### JSON Array
81
+
82
+ ```python
83
+ @guidance
84
+ def generate_user_list(lm, count=3):
85
+ """Generate JSON array of users."""
86
+ lm += "[\n"
87
+
88
+ for i in range(count):
89
+ lm += " {\n"
90
+ lm += ' "id": ' + gen(f"id_{i}", regex=r"[0-9]+") + ",\n"
91
+ lm += ' "name": ' + gen(f"name_{i}", regex=r'"[A-Za-z ]+"') + ",\n"
92
+ lm += ' "active": ' + gen(f"active_{i}", regex=r"(true|false)") + "\n"
93
+ lm += " }"
94
+ if i < count - 1:
95
+ lm += ","
96
+ lm += "\n"
97
+
98
+ lm += "]"
99
+ return lm
100
+
101
+ lm = models.Anthropic("claude-sonnet-4-5-20250929")
102
+ lm = generate_user_list(lm, count=5)
103
+ ```
104
+
105
+ ### Dynamic JSON Schema
106
+
107
+ ```python
108
+ import json
109
+ from guidance import models, gen, guidance
110
+
111
+ @guidance
112
+ def json_from_schema(lm, schema):
113
+ """Generate JSON matching a schema."""
114
+ lm += "{\n"
115
+
116
+ fields = list(schema["properties"].items())
117
+ for i, (field_name, field_schema) in enumerate(fields):
118
+ lm += f' "{field_name}": '
119
+
120
+ # Handle different types
121
+ if field_schema["type"] == "string":
122
+ if "pattern" in field_schema:
123
+ lm += gen(field_name, regex=f'"{field_schema["pattern"]}"')
124
+ else:
125
+ lm += gen(field_name, regex=r'"[^"]+"')
126
+ elif field_schema["type"] == "number":
127
+ lm += gen(field_name, regex=r"[0-9]+(\.[0-9]+)?")
128
+ elif field_schema["type"] == "integer":
129
+ lm += gen(field_name, regex=r"[0-9]+")
130
+ elif field_schema["type"] == "boolean":
131
+ lm += gen(field_name, regex=r"(true|false)")
132
+
133
+ if i < len(fields) - 1:
134
+ lm += ","
135
+ lm += "\n"
136
+
137
+ lm += "}"
138
+ return lm
139
+
140
+ # Define schema
141
+ schema = {
142
+ "type": "object",
143
+ "properties": {
144
+ "name": {"type": "string"},
145
+ "age": {"type": "integer"},
146
+ "score": {"type": "number"},
147
+ "active": {"type": "boolean"}
148
+ }
149
+ }
150
+
151
+ lm = models.Anthropic("claude-sonnet-4-5-20250929")
152
+ lm = json_from_schema(lm, schema)
153
+ ```
154
+
155
+ ## Data Extraction
156
+
157
+ ### Extract from Text
158
+
159
+ ```python
160
+ from guidance import models, gen, guidance, system, user, assistant
161
+
162
+ @guidance
163
+ def extract_person_info(lm, text):
164
+ """Extract structured info from text."""
165
+ lm += f"Text: {text}\n\n"
166
+
167
+ with assistant():
168
+ lm += "Name: " + gen("name", regex=r"[A-Za-z ]+", stop="\n") + "\n"
169
+ lm += "Age: " + gen("age", regex=r"[0-9]+", max_tokens=3) + "\n"
170
+ lm += "Occupation: " + gen("occupation", regex=r"[A-Za-z ]+", stop="\n") + "\n"
171
+ lm += "Email: " + gen(
172
+ "email",
173
+ regex=r"[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}",
174
+ stop="\n"
175
+ ) + "\n"
176
+
177
+ return lm
178
+
179
+ text = "John Smith is a 35-year-old software engineer. Contact: john@example.com"
180
+
181
+ lm = models.Anthropic("claude-sonnet-4-5-20250929")
182
+
183
+ with system():
184
+ lm += "You extract structured information from text."
185
+
186
+ with user():
187
+ lm = extract_person_info(lm, text)
188
+
189
+ print(f"Name: {lm['name']}")
190
+ print(f"Age: {lm['age']}")
191
+ print(f"Occupation: {lm['occupation']}")
192
+ print(f"Email: {lm['email']}")
193
+ ```
194
+
195
+ ### Multi-Entity Extraction
196
+
197
+ ```python
198
+ @guidance
199
+ def extract_entities(lm, text):
200
+ """Extract multiple entity types."""
201
+ lm += f"Analyze: {text}\n\n"
202
+
203
+ # Person entities
204
+ lm += "People:\n"
205
+ for i in range(3): # Up to 3 people
206
+ lm += f"- " + gen(f"person_{i}", regex=r"[A-Za-z ]+", stop="\n") + "\n"
207
+
208
+ # Organization entities
209
+ lm += "\nOrganizations:\n"
210
+ for i in range(2): # Up to 2 orgs
211
+ lm += f"- " + gen(f"org_{i}", regex=r"[A-Za-z0-9 ]+", stop="\n") + "\n"
212
+
213
+ # Dates
214
+ lm += "\nDates:\n"
215
+ for i in range(2): # Up to 2 dates
216
+ lm += f"- " + gen(f"date_{i}", regex=r"\d{4}-\d{2}-\d{2}", stop="\n") + "\n"
217
+
218
+ # Locations
219
+ lm += "\nLocations:\n"
220
+ for i in range(2): # Up to 2 locations
221
+ lm += f"- " + gen(f"location_{i}", regex=r"[A-Za-z ]+", stop="\n") + "\n"
222
+
223
+ return lm
224
+
225
+ text = """
226
+ Tim Cook and Satya Nadella met at Microsoft headquarters in Redmond on 2024-09-15
227
+ to discuss the collaboration between Apple and Microsoft. The meeting continued
228
+ in Cupertino on 2024-09-20.
229
+ """
230
+
231
+ lm = models.Anthropic("claude-sonnet-4-5-20250929")
232
+ lm = extract_entities(lm, text)
233
+ ```
234
+
235
+ ### Batch Extraction
236
+
237
+ ```python
238
+ @guidance
239
+ def batch_extract(lm, texts):
240
+ """Extract from multiple texts."""
241
+ lm += "Batch Extraction Results:\n\n"
242
+
243
+ for i, text in enumerate(texts):
244
+ lm += f"=== Item {i+1} ===\n"
245
+ lm += f"Text: {text}\n"
246
+ lm += "Name: " + gen(f"name_{i}", regex=r"[A-Za-z ]+", stop="\n") + "\n"
247
+ lm += "Sentiment: " + gen(
248
+ f"sentiment_{i}",
249
+ regex=r"(positive|negative|neutral)",
250
+ stop="\n"
251
+ ) + "\n\n"
252
+
253
+ return lm
254
+
255
+ texts = [
256
+ "Alice is happy with the product",
257
+ "Bob is disappointed with the service",
258
+ "Carol has no strong feelings either way"
259
+ ]
260
+
261
+ lm = models.Anthropic("claude-sonnet-4-5-20250929")
262
+ lm = batch_extract(lm, texts)
263
+ ```
264
+
265
+ ## Classification Systems
266
+
267
+ ### Sentiment Analysis
268
+
269
+ ```python
270
+ from guidance import models, select, gen
271
+
272
+ lm = models.Anthropic("claude-sonnet-4-5-20250929")
273
+
274
+ text = "This product is absolutely amazing! Best purchase ever."
275
+
276
+ lm += f"Text: {text}\n\n"
277
+ lm += "Sentiment: " + select(
278
+ ["positive", "negative", "neutral"],
279
+ name="sentiment"
280
+ )
281
+ lm += "\nConfidence: " + gen("confidence", regex=r"[0-9]{1,3}") + "%\n"
282
+ lm += "Reasoning: " + gen("reasoning", stop="\n", max_tokens=50)
283
+
284
+ print(f"Sentiment: {lm['sentiment']}")
285
+ print(f"Confidence: {lm['confidence']}%")
286
+ print(f"Reasoning: {lm['reasoning']}")
287
+ ```
288
+
289
+ ### Multi-Label Classification
290
+
291
+ ```python
292
+ @guidance
293
+ def classify_article(lm, text):
294
+ """Classify article with multiple labels."""
295
+ lm += f"Article: {text}\n\n"
296
+
297
+ # Primary category
298
+ lm += "Primary Category: " + select(
299
+ ["Technology", "Business", "Science", "Politics", "Entertainment"],
300
+ name="primary_category"
301
+ ) + "\n"
302
+
303
+ # Secondary categories (up to 3)
304
+ lm += "\nSecondary Categories:\n"
305
+ categories = ["Technology", "Business", "Science", "Politics", "Entertainment"]
306
+ for i in range(3):
307
+ lm += f"{i+1}. " + select(categories, name=f"secondary_{i}") + "\n"
308
+
309
+ # Tags
310
+ lm += "\nTags: " + gen("tags", stop="\n", max_tokens=50) + "\n"
311
+
312
+ # Target audience
313
+ lm += "Target Audience: " + select(
314
+ ["General", "Expert", "Beginner"],
315
+ name="audience"
316
+ )
317
+
318
+ return lm
319
+
320
+ article = """
321
+ Apple announced new AI features in iOS 18, leveraging machine learning to improve
322
+ battery life and performance. The company's stock rose 5% following the announcement.
323
+ """
324
+
325
+ lm = models.Anthropic("claude-sonnet-4-5-20250929")
326
+ lm = classify_article(lm, article)
327
+ ```
328
+
329
+ ### Intent Classification
330
+
331
+ ```python
332
+ @guidance
333
+ def classify_intent(lm, message):
334
+ """Classify user intent."""
335
+ lm += f"User Message: {message}\n\n"
336
+
337
+ # Intent
338
+ lm += "Intent: " + select(
339
+ ["question", "complaint", "request", "feedback", "other"],
340
+ name="intent"
341
+ ) + "\n"
342
+
343
+ # Urgency
344
+ lm += "Urgency: " + select(
345
+ ["low", "medium", "high", "critical"],
346
+ name="urgency"
347
+ ) + "\n"
348
+
349
+ # Department
350
+ lm += "Route To: " + select(
351
+ ["support", "sales", "billing", "technical"],
352
+ name="department"
353
+ ) + "\n"
354
+
355
+ # Sentiment
356
+ lm += "Sentiment: " + select(
357
+ ["positive", "neutral", "negative"],
358
+ name="sentiment"
359
+ )
360
+
361
+ return lm
362
+
363
+ message = "My account was charged twice for the same order. Need help ASAP!"
364
+
365
+ lm = models.Anthropic("claude-sonnet-4-5-20250929")
366
+ lm = classify_intent(lm, message)
367
+
368
+ print(f"Intent: {lm['intent']}")
369
+ print(f"Urgency: {lm['urgency']}")
370
+ print(f"Department: {lm['department']}")
371
+ ```
372
+
373
+ ## Agent Systems
374
+
375
+ ### ReAct Agent
376
+
377
+ ```python
378
+ from guidance import models, gen, select, guidance
379
+
380
+ @guidance(stateless=False)
381
+ def react_agent(lm, question, tools, max_rounds=5):
382
+ """ReAct agent with tool use."""
383
+ lm += f"Question: {question}\n\n"
384
+
385
+ for round in range(max_rounds):
386
+ # Thought
387
+ lm += f"Thought {round+1}: " + gen("thought", stop="\n", max_tokens=100) + "\n"
388
+
389
+ # Action selection
390
+ lm += "Action: " + select(
391
+ list(tools.keys()) + ["answer"],
392
+ name="action"
393
+ )
394
+
395
+ if lm["action"] == "answer":
396
+ lm += "\n\nFinal Answer: " + gen("answer", max_tokens=200)
397
+ break
398
+
399
+ # Action input
400
+ lm += "\nAction Input: " + gen("action_input", stop="\n", max_tokens=100) + "\n"
401
+
402
+ # Execute tool
403
+ if lm["action"] in tools:
404
+ try:
405
+ result = tools[lm["action"]](lm["action_input"])
406
+ lm += f"Observation: {result}\n\n"
407
+ except Exception as e:
408
+ lm += f"Observation: Error - {str(e)}\n\n"
409
+
410
+ return lm
411
+
412
+ # Define tools
413
+ tools = {
414
+ "calculator": lambda expr: eval(expr),
415
+ "search": lambda query: f"Search results for '{query}': [Mock results]",
416
+ "weather": lambda city: f"Weather in {city}: Sunny, 72°F"
417
+ }
418
+
419
+ # Use agent
420
+ lm = models.Anthropic("claude-sonnet-4-5-20250929")
421
+ lm = react_agent(lm, "What is (25 * 4) + 10?", tools)
422
+
423
+ print(lm["answer"])
424
+ ```
425
+
426
+ ### Multi-Agent System
427
+
428
+ ```python
429
+ @guidance
430
+ def coordinator_agent(lm, task):
431
+ """Coordinator that delegates to specialists."""
432
+ lm += f"Task: {task}\n\n"
433
+
434
+ # Determine which specialist to use
435
+ lm += "Specialist: " + select(
436
+ ["researcher", "writer", "coder", "analyst"],
437
+ name="specialist"
438
+ ) + "\n"
439
+
440
+ lm += "Reasoning: " + gen("reasoning", stop="\n", max_tokens=100) + "\n"
441
+
442
+ return lm
443
+
444
+ @guidance
445
+ def researcher_agent(lm, query):
446
+ """Research specialist."""
447
+ lm += f"Research Query: {query}\n\n"
448
+ lm += "Findings:\n"
449
+ for i in range(3):
450
+ lm += f"{i+1}. " + gen(f"finding_{i}", stop="\n", max_tokens=100) + "\n"
451
+ return lm
452
+
453
+ @guidance
454
+ def writer_agent(lm, topic):
455
+ """Writing specialist."""
456
+ lm += f"Topic: {topic}\n\n"
457
+ lm += "Title: " + gen("title", stop="\n", max_tokens=50) + "\n"
458
+ lm += "Content:\n" + gen("content", max_tokens=500)
459
+ return lm
460
+
461
+ # Coordination workflow
462
+ task = "Write an article about AI safety"
463
+
464
+ lm = models.Anthropic("claude-sonnet-4-5-20250929")
465
+ lm = coordinator_agent(lm, task)
466
+
467
+ specialist = lm["specialist"]
468
+ if specialist == "researcher":
469
+ lm = researcher_agent(lm, task)
470
+ elif specialist == "writer":
471
+ lm = writer_agent(lm, task)
472
+ ```
473
+
474
+ ### Tool Use with Validation
475
+
476
+ ```python
477
+ @guidance(stateless=False)
478
+ def validated_tool_agent(lm, question):
479
+ """Agent with validated tool calls."""
480
+ tools = {
481
+ "add": lambda a, b: float(a) + float(b),
482
+ "multiply": lambda a, b: float(a) * float(b),
483
+ "divide": lambda a, b: float(a) / float(b) if float(b) != 0 else "Error: Division by zero"
484
+ }
485
+
486
+ lm += f"Question: {question}\n\n"
487
+
488
+ for i in range(5):
489
+ # Select tool
490
+ lm += "Tool: " + select(list(tools.keys()) + ["done"], name="tool")
491
+
492
+ if lm["tool"] == "done":
493
+ lm += "\nAnswer: " + gen("answer", max_tokens=100)
494
+ break
495
+
496
+ # Get validated numeric arguments
497
+ lm += "\nArg1: " + gen("arg1", regex=r"-?[0-9]+(\.[0-9]+)?") + "\n"
498
+ lm += "Arg2: " + gen("arg2", regex=r"-?[0-9]+(\.[0-9]+)?") + "\n"
499
+
500
+ # Execute
501
+ result = tools[lm["tool"]](lm["arg1"], lm["arg2"])
502
+ lm += f"Result: {result}\n\n"
503
+
504
+ return lm
505
+
506
+ lm = models.Anthropic("claude-sonnet-4-5-20250929")
507
+ lm = validated_tool_agent(lm, "What is (10 + 5) * 3?")
508
+ ```
509
+
510
+ ## Multi-Step Workflows
511
+
512
+ ### Chain of Thought
513
+
514
+ ```python
515
+ @guidance
516
+ def chain_of_thought(lm, question):
517
+ """Multi-step reasoning with CoT."""
518
+ lm += f"Question: {question}\n\n"
519
+
520
+ # Generate reasoning steps
521
+ lm += "Let me think step by step:\n\n"
522
+ for i in range(4):
523
+ lm += f"Step {i+1}: " + gen(f"step_{i+1}", stop="\n", max_tokens=100) + "\n"
524
+
525
+ # Final answer
526
+ lm += "\nTherefore, the answer is: " + gen("answer", stop="\n", max_tokens=50)
527
+
528
+ return lm
529
+
530
+ lm = models.Anthropic("claude-sonnet-4-5-20250929")
531
+ lm = chain_of_thought(lm, "If a train travels 60 mph for 2.5 hours, how far does it go?")
532
+
533
+ print(lm["answer"])
534
+ ```
535
+
536
+ ### Self-Consistency
537
+
538
+ ```python
539
+ @guidance
540
+ def self_consistency(lm, question, num_samples=3):
541
+ """Generate multiple reasoning paths and aggregate."""
542
+ lm += f"Question: {question}\n\n"
543
+
544
+ answers = []
545
+ for i in range(num_samples):
546
+ lm += f"=== Attempt {i+1} ===\n"
547
+ lm += "Reasoning: " + gen(f"reasoning_{i}", stop="\n", max_tokens=100) + "\n"
548
+ lm += "Answer: " + gen(f"answer_{i}", stop="\n", max_tokens=50) + "\n\n"
549
+ answers.append(lm[f"answer_{i}"])
550
+
551
+ # Aggregate (simple majority vote)
552
+ from collections import Counter
553
+ most_common = Counter(answers).most_common(1)[0][0]
554
+
555
+ lm += f"Final Answer (by majority): {most_common}\n"
556
+ return lm
557
+
558
+ lm = models.Anthropic("claude-sonnet-4-5-20250929")
559
+ lm = self_consistency(lm, "What is 15% of 200?")
560
+ ```
561
+
562
+ ### Planning and Execution
563
+
564
+ ```python
565
+ @guidance
566
+ def plan_and_execute(lm, goal):
567
+ """Plan tasks then execute them."""
568
+ lm += f"Goal: {goal}\n\n"
569
+
570
+ # Planning phase
571
+ lm += "Plan:\n"
572
+ num_steps = 4
573
+ for i in range(num_steps):
574
+ lm += f"{i+1}. " + gen(f"plan_step_{i}", stop="\n", max_tokens=100) + "\n"
575
+
576
+ # Execution phase
577
+ lm += "\nExecution:\n\n"
578
+ for i in range(num_steps):
579
+ lm += f"Step {i+1}: {lm[f'plan_step_{i}']}\n"
580
+ lm += "Status: " + select(["completed", "in-progress", "blocked"], name=f"status_{i}") + "\n"
581
+ lm += "Result: " + gen(f"result_{i}", stop="\n", max_tokens=150) + "\n\n"
582
+
583
+ # Summary
584
+ lm += "Summary: " + gen("summary", max_tokens=200)
585
+
586
+ return lm
587
+
588
+ lm = models.Anthropic("claude-sonnet-4-5-20250929")
589
+ lm = plan_and_execute(lm, "Build a REST API for a blog platform")
590
+ ```
591
+
592
+ ## Code Generation
593
+
594
+ ### Python Function
595
+
596
+ ```python
597
+ @guidance
598
+ def generate_python_function(lm, description):
599
+ """Generate Python function from description."""
600
+ lm += f"Description: {description}\n\n"
601
+
602
+ # Function signature
603
+ lm += "def " + gen("func_name", regex=r"[a-z_][a-z0-9_]*") + "("
604
+ lm += gen("params", regex=r"[a-z_][a-z0-9_]*(, [a-z_][a-z0-9_]*)*") + "):\n"
605
+
606
+ # Docstring
607
+ lm += ' """' + gen("docstring", stop='"""', max_tokens=100) + '"""\n'
608
+
609
+ # Function body
610
+ lm += " " + gen("body", stop="\n", max_tokens=200) + "\n"
611
+
612
+ return lm
613
+
614
+ lm = models.Anthropic("claude-sonnet-4-5-20250929")
615
+ lm = generate_python_function(lm, "Check if a number is prime")
616
+
617
+ print(lm)
618
+ ```
619
+
620
+ ### SQL Query
621
+
622
+ ```python
623
+ @guidance
624
+ def generate_sql(lm, description):
625
+ """Generate SQL query from description."""
626
+ lm += f"Description: {description}\n\n"
627
+ lm += "SQL Query:\n"
628
+
629
+ # SELECT clause
630
+ lm += "SELECT " + gen("select_clause", stop=" FROM", max_tokens=100)
631
+
632
+ # FROM clause
633
+ lm += " FROM " + gen("from_clause", stop=" WHERE", max_tokens=50)
634
+
635
+ # WHERE clause (optional)
636
+ lm += " WHERE " + gen("where_clause", stop=";", max_tokens=100) + ";"
637
+
638
+ return lm
639
+
640
+ lm = models.Anthropic("claude-sonnet-4-5-20250929")
641
+ lm = generate_sql(lm, "Get all users who signed up in the last 30 days")
642
+ ```
643
+
644
+ ### API Endpoint
645
+
646
+ ```python
647
+ @guidance
648
+ def generate_api_endpoint(lm, description):
649
+ """Generate REST API endpoint."""
650
+ lm += f"Description: {description}\n\n"
651
+
652
+ # HTTP method
653
+ lm += "Method: " + select(["GET", "POST", "PUT", "DELETE"], name="method") + "\n"
654
+
655
+ # Path
656
+ lm += "Path: /" + gen("path", regex=r"[a-z0-9/-]+", stop="\n") + "\n"
657
+
658
+ # Request body (if POST/PUT)
659
+ if lm["method"] in ["POST", "PUT"]:
660
+ lm += "\nRequest Body:\n"
661
+ lm += "{\n"
662
+ lm += ' "field1": ' + gen("field1", regex=r'"[a-z_]+"') + ",\n"
663
+ lm += ' "field2": ' + gen("field2", regex=r'"[a-z_]+"') + "\n"
664
+ lm += "}\n"
665
+
666
+ # Response
667
+ lm += "\nResponse (200 OK):\n"
668
+ lm += "{\n"
669
+ lm += ' "status": "success",\n'
670
+ lm += ' "data": ' + gen("response_data", max_tokens=100) + "\n"
671
+ lm += "}\n"
672
+
673
+ return lm
674
+
675
+ lm = models.Anthropic("claude-sonnet-4-5-20250929")
676
+ lm = generate_api_endpoint(lm, "Create a new blog post")
677
+ ```
678
+
679
+ ## Production Tips
680
+
681
+ ### Error Handling
682
+
683
+ ```python
684
+ @guidance
685
+ def safe_extraction(lm, text):
686
+ """Extract with fallback handling."""
687
+ try:
688
+ lm += f"Text: {text}\n"
689
+ lm += "Name: " + gen("name", regex=r"[A-Za-z ]+", stop="\n", max_tokens=30)
690
+ return lm
691
+ except Exception as e:
692
+ # Fallback to less strict extraction
693
+ lm += f"Text: {text}\n"
694
+ lm += "Name: " + gen("name", stop="\n", max_tokens=30)
695
+ return lm
696
+ ```
697
+
698
+ ### Caching
699
+
700
+ ```python
701
+ from functools import lru_cache
702
+
703
+ @lru_cache(maxsize=100)
704
+ def cached_generation(text):
705
+ """Cache LLM generations."""
706
+ lm = models.Anthropic("claude-sonnet-4-5-20250929")
707
+ lm += f"Analyze: {text}\n"
708
+ lm += "Sentiment: " + select(["positive", "negative", "neutral"], name="sentiment")
709
+ return lm["sentiment"]
710
+
711
+ # First call: hits LLM
712
+ result1 = cached_generation("This is great!")
713
+
714
+ # Second call: returns cached result
715
+ result2 = cached_generation("This is great!") # Instant!
716
+ ```
717
+
718
+ ### Monitoring
719
+
720
+ ```python
721
+ import time
722
+
723
+ @guidance
724
+ def monitored_generation(lm, text):
725
+ """Track generation metrics."""
726
+ start_time = time.time()
727
+
728
+ lm += f"Text: {text}\n"
729
+ lm += "Analysis: " + gen("analysis", max_tokens=100)
730
+
731
+ elapsed = time.time() - start_time
732
+
733
+ # Log metrics
734
+ print(f"Generation time: {elapsed:.2f}s")
735
+ print(f"Output length: {len(lm['analysis'])} chars")
736
+
737
+ return lm
738
+ ```
739
+
740
+ ### Batch Processing
741
+
742
+ ```python
743
+ def batch_process(texts, batch_size=10):
744
+ """Process texts in batches."""
745
+ lm = models.Anthropic("claude-sonnet-4-5-20250929")
746
+ results = []
747
+
748
+ for i in range(0, len(texts), batch_size):
749
+ batch = texts[i:i+batch_size]
750
+
751
+ for text in batch:
752
+ lm += f"Text: {text}\n"
753
+ lm += "Sentiment: " + select(
754
+ ["positive", "negative", "neutral"],
755
+ name=f"sentiment_{i}"
756
+ ) + "\n\n"
757
+
758
+ results.extend([lm[f"sentiment_{i}"] for i in range(len(batch))])
759
+
760
+ return results
761
+ ```
762
+
763
+ ## Resources
764
+
765
+ - **Guidance Notebooks**: https://github.com/guidance-ai/guidance/tree/main/notebooks
766
+ - **Guidance Docs**: https://guidance.readthedocs.io
767
+ - **Community Examples**: https://github.com/guidance-ai/guidance/discussions