@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.
- package/bin/skills/accelerate/SKILL.md +332 -0
- package/bin/skills/accelerate/references/custom-plugins.md +453 -0
- package/bin/skills/accelerate/references/megatron-integration.md +489 -0
- package/bin/skills/accelerate/references/performance.md +525 -0
- package/bin/skills/audiocraft/SKILL.md +564 -0
- package/bin/skills/audiocraft/references/advanced-usage.md +666 -0
- package/bin/skills/audiocraft/references/troubleshooting.md +504 -0
- package/bin/skills/autogpt/SKILL.md +403 -0
- package/bin/skills/autogpt/references/advanced-usage.md +535 -0
- package/bin/skills/autogpt/references/troubleshooting.md +420 -0
- package/bin/skills/awq/SKILL.md +310 -0
- package/bin/skills/awq/references/advanced-usage.md +324 -0
- package/bin/skills/awq/references/troubleshooting.md +344 -0
- package/bin/skills/axolotl/SKILL.md +158 -0
- package/bin/skills/axolotl/references/api.md +5548 -0
- package/bin/skills/axolotl/references/dataset-formats.md +1029 -0
- package/bin/skills/axolotl/references/index.md +15 -0
- package/bin/skills/axolotl/references/other.md +3563 -0
- package/bin/skills/bigcode-evaluation-harness/SKILL.md +405 -0
- package/bin/skills/bigcode-evaluation-harness/references/benchmarks.md +393 -0
- package/bin/skills/bigcode-evaluation-harness/references/custom-tasks.md +424 -0
- package/bin/skills/bigcode-evaluation-harness/references/issues.md +394 -0
- package/bin/skills/bitsandbytes/SKILL.md +411 -0
- package/bin/skills/bitsandbytes/references/memory-optimization.md +521 -0
- package/bin/skills/bitsandbytes/references/qlora-training.md +521 -0
- package/bin/skills/bitsandbytes/references/quantization-formats.md +447 -0
- package/bin/skills/blip-2/SKILL.md +564 -0
- package/bin/skills/blip-2/references/advanced-usage.md +680 -0
- package/bin/skills/blip-2/references/troubleshooting.md +526 -0
- package/bin/skills/chroma/SKILL.md +406 -0
- package/bin/skills/chroma/references/integration.md +38 -0
- package/bin/skills/clip/SKILL.md +253 -0
- package/bin/skills/clip/references/applications.md +207 -0
- package/bin/skills/constitutional-ai/SKILL.md +290 -0
- package/bin/skills/crewai/SKILL.md +498 -0
- package/bin/skills/crewai/references/flows.md +438 -0
- package/bin/skills/crewai/references/tools.md +429 -0
- package/bin/skills/crewai/references/troubleshooting.md +480 -0
- package/bin/skills/deepspeed/SKILL.md +141 -0
- package/bin/skills/deepspeed/references/08.md +17 -0
- package/bin/skills/deepspeed/references/09.md +173 -0
- package/bin/skills/deepspeed/references/2020.md +378 -0
- package/bin/skills/deepspeed/references/2023.md +279 -0
- package/bin/skills/deepspeed/references/assets.md +179 -0
- package/bin/skills/deepspeed/references/index.md +35 -0
- package/bin/skills/deepspeed/references/mii.md +118 -0
- package/bin/skills/deepspeed/references/other.md +1191 -0
- package/bin/skills/deepspeed/references/tutorials.md +6554 -0
- package/bin/skills/dspy/SKILL.md +590 -0
- package/bin/skills/dspy/references/examples.md +663 -0
- package/bin/skills/dspy/references/modules.md +475 -0
- package/bin/skills/dspy/references/optimizers.md +566 -0
- package/bin/skills/faiss/SKILL.md +221 -0
- package/bin/skills/faiss/references/index_types.md +280 -0
- package/bin/skills/flash-attention/SKILL.md +367 -0
- package/bin/skills/flash-attention/references/benchmarks.md +215 -0
- package/bin/skills/flash-attention/references/transformers-integration.md +293 -0
- package/bin/skills/gguf/SKILL.md +427 -0
- package/bin/skills/gguf/references/advanced-usage.md +504 -0
- package/bin/skills/gguf/references/troubleshooting.md +442 -0
- package/bin/skills/gptq/SKILL.md +450 -0
- package/bin/skills/gptq/references/calibration.md +337 -0
- package/bin/skills/gptq/references/integration.md +129 -0
- package/bin/skills/gptq/references/troubleshooting.md +95 -0
- package/bin/skills/grpo-rl-training/README.md +97 -0
- package/bin/skills/grpo-rl-training/SKILL.md +572 -0
- package/bin/skills/grpo-rl-training/examples/reward_functions_library.py +393 -0
- package/bin/skills/grpo-rl-training/templates/basic_grpo_training.py +228 -0
- package/bin/skills/guidance/SKILL.md +572 -0
- package/bin/skills/guidance/references/backends.md +554 -0
- package/bin/skills/guidance/references/constraints.md +674 -0
- package/bin/skills/guidance/references/examples.md +767 -0
- package/bin/skills/hqq/SKILL.md +445 -0
- package/bin/skills/hqq/references/advanced-usage.md +528 -0
- package/bin/skills/hqq/references/troubleshooting.md +503 -0
- package/bin/skills/hugging-face-cli/SKILL.md +191 -0
- package/bin/skills/hugging-face-cli/references/commands.md +954 -0
- package/bin/skills/hugging-face-cli/references/examples.md +374 -0
- package/bin/skills/hugging-face-datasets/SKILL.md +547 -0
- package/bin/skills/hugging-face-datasets/examples/diverse_training_examples.json +239 -0
- package/bin/skills/hugging-face-datasets/examples/system_prompt_template.txt +196 -0
- package/bin/skills/hugging-face-datasets/examples/training_examples.json +176 -0
- package/bin/skills/hugging-face-datasets/scripts/dataset_manager.py +522 -0
- package/bin/skills/hugging-face-datasets/scripts/sql_manager.py +844 -0
- package/bin/skills/hugging-face-datasets/templates/chat.json +55 -0
- package/bin/skills/hugging-face-datasets/templates/classification.json +62 -0
- package/bin/skills/hugging-face-datasets/templates/completion.json +51 -0
- package/bin/skills/hugging-face-datasets/templates/custom.json +75 -0
- package/bin/skills/hugging-face-datasets/templates/qa.json +54 -0
- package/bin/skills/hugging-face-datasets/templates/tabular.json +81 -0
- package/bin/skills/hugging-face-evaluation/SKILL.md +656 -0
- package/bin/skills/hugging-face-evaluation/examples/USAGE_EXAMPLES.md +382 -0
- package/bin/skills/hugging-face-evaluation/examples/artificial_analysis_to_hub.py +141 -0
- package/bin/skills/hugging-face-evaluation/examples/example_readme_tables.md +135 -0
- package/bin/skills/hugging-face-evaluation/examples/metric_mapping.json +50 -0
- package/bin/skills/hugging-face-evaluation/requirements.txt +20 -0
- package/bin/skills/hugging-face-evaluation/scripts/evaluation_manager.py +1374 -0
- package/bin/skills/hugging-face-evaluation/scripts/inspect_eval_uv.py +104 -0
- package/bin/skills/hugging-face-evaluation/scripts/inspect_vllm_uv.py +317 -0
- package/bin/skills/hugging-face-evaluation/scripts/lighteval_vllm_uv.py +303 -0
- package/bin/skills/hugging-face-evaluation/scripts/run_eval_job.py +98 -0
- package/bin/skills/hugging-face-evaluation/scripts/run_vllm_eval_job.py +331 -0
- package/bin/skills/hugging-face-evaluation/scripts/test_extraction.py +206 -0
- package/bin/skills/hugging-face-jobs/SKILL.md +1041 -0
- package/bin/skills/hugging-face-jobs/index.html +216 -0
- package/bin/skills/hugging-face-jobs/references/hardware_guide.md +336 -0
- package/bin/skills/hugging-face-jobs/references/hub_saving.md +352 -0
- package/bin/skills/hugging-face-jobs/references/token_usage.md +546 -0
- package/bin/skills/hugging-face-jobs/references/troubleshooting.md +475 -0
- package/bin/skills/hugging-face-jobs/scripts/cot-self-instruct.py +718 -0
- package/bin/skills/hugging-face-jobs/scripts/finepdfs-stats.py +546 -0
- package/bin/skills/hugging-face-jobs/scripts/generate-responses.py +587 -0
- package/bin/skills/hugging-face-model-trainer/SKILL.md +711 -0
- package/bin/skills/hugging-face-model-trainer/references/gguf_conversion.md +296 -0
- package/bin/skills/hugging-face-model-trainer/references/hardware_guide.md +283 -0
- package/bin/skills/hugging-face-model-trainer/references/hub_saving.md +364 -0
- package/bin/skills/hugging-face-model-trainer/references/reliability_principles.md +371 -0
- package/bin/skills/hugging-face-model-trainer/references/trackio_guide.md +189 -0
- package/bin/skills/hugging-face-model-trainer/references/training_methods.md +150 -0
- package/bin/skills/hugging-face-model-trainer/references/training_patterns.md +203 -0
- package/bin/skills/hugging-face-model-trainer/references/troubleshooting.md +282 -0
- package/bin/skills/hugging-face-model-trainer/scripts/convert_to_gguf.py +424 -0
- package/bin/skills/hugging-face-model-trainer/scripts/dataset_inspector.py +417 -0
- package/bin/skills/hugging-face-model-trainer/scripts/estimate_cost.py +150 -0
- package/bin/skills/hugging-face-model-trainer/scripts/train_dpo_example.py +106 -0
- package/bin/skills/hugging-face-model-trainer/scripts/train_grpo_example.py +89 -0
- package/bin/skills/hugging-face-model-trainer/scripts/train_sft_example.py +122 -0
- package/bin/skills/hugging-face-paper-publisher/SKILL.md +627 -0
- package/bin/skills/hugging-face-paper-publisher/examples/example_usage.md +327 -0
- package/bin/skills/hugging-face-paper-publisher/references/quick_reference.md +216 -0
- package/bin/skills/hugging-face-paper-publisher/scripts/paper_manager.py +508 -0
- package/bin/skills/hugging-face-paper-publisher/templates/arxiv.md +299 -0
- package/bin/skills/hugging-face-paper-publisher/templates/ml-report.md +358 -0
- package/bin/skills/hugging-face-paper-publisher/templates/modern.md +319 -0
- package/bin/skills/hugging-face-paper-publisher/templates/standard.md +201 -0
- package/bin/skills/hugging-face-tool-builder/SKILL.md +115 -0
- package/bin/skills/hugging-face-tool-builder/references/baseline_hf_api.py +57 -0
- package/bin/skills/hugging-face-tool-builder/references/baseline_hf_api.sh +40 -0
- package/bin/skills/hugging-face-tool-builder/references/baseline_hf_api.tsx +57 -0
- package/bin/skills/hugging-face-tool-builder/references/find_models_by_paper.sh +230 -0
- package/bin/skills/hugging-face-tool-builder/references/hf_enrich_models.sh +96 -0
- package/bin/skills/hugging-face-tool-builder/references/hf_model_card_frontmatter.sh +188 -0
- package/bin/skills/hugging-face-tool-builder/references/hf_model_papers_auth.sh +171 -0
- package/bin/skills/hugging-face-trackio/SKILL.md +65 -0
- package/bin/skills/hugging-face-trackio/references/logging_metrics.md +206 -0
- package/bin/skills/hugging-face-trackio/references/retrieving_metrics.md +223 -0
- package/bin/skills/huggingface-tokenizers/SKILL.md +516 -0
- package/bin/skills/huggingface-tokenizers/references/algorithms.md +653 -0
- package/bin/skills/huggingface-tokenizers/references/integration.md +637 -0
- package/bin/skills/huggingface-tokenizers/references/pipeline.md +723 -0
- package/bin/skills/huggingface-tokenizers/references/training.md +565 -0
- package/bin/skills/instructor/SKILL.md +740 -0
- package/bin/skills/instructor/references/examples.md +107 -0
- package/bin/skills/instructor/references/providers.md +70 -0
- package/bin/skills/instructor/references/validation.md +606 -0
- package/bin/skills/knowledge-distillation/SKILL.md +458 -0
- package/bin/skills/knowledge-distillation/references/minillm.md +334 -0
- package/bin/skills/lambda-labs/SKILL.md +545 -0
- package/bin/skills/lambda-labs/references/advanced-usage.md +611 -0
- package/bin/skills/lambda-labs/references/troubleshooting.md +530 -0
- package/bin/skills/langchain/SKILL.md +480 -0
- package/bin/skills/langchain/references/agents.md +499 -0
- package/bin/skills/langchain/references/integration.md +562 -0
- package/bin/skills/langchain/references/rag.md +600 -0
- package/bin/skills/langsmith/SKILL.md +422 -0
- package/bin/skills/langsmith/references/advanced-usage.md +548 -0
- package/bin/skills/langsmith/references/troubleshooting.md +537 -0
- package/bin/skills/litgpt/SKILL.md +469 -0
- package/bin/skills/litgpt/references/custom-models.md +568 -0
- package/bin/skills/litgpt/references/distributed-training.md +451 -0
- package/bin/skills/litgpt/references/supported-models.md +336 -0
- package/bin/skills/litgpt/references/training-recipes.md +619 -0
- package/bin/skills/llama-cpp/SKILL.md +258 -0
- package/bin/skills/llama-cpp/references/optimization.md +89 -0
- package/bin/skills/llama-cpp/references/quantization.md +213 -0
- package/bin/skills/llama-cpp/references/server.md +125 -0
- package/bin/skills/llama-factory/SKILL.md +80 -0
- package/bin/skills/llama-factory/references/_images.md +23 -0
- package/bin/skills/llama-factory/references/advanced.md +1055 -0
- package/bin/skills/llama-factory/references/getting_started.md +349 -0
- package/bin/skills/llama-factory/references/index.md +19 -0
- package/bin/skills/llama-factory/references/other.md +31 -0
- package/bin/skills/llamaguard/SKILL.md +337 -0
- package/bin/skills/llamaindex/SKILL.md +569 -0
- package/bin/skills/llamaindex/references/agents.md +83 -0
- package/bin/skills/llamaindex/references/data_connectors.md +108 -0
- package/bin/skills/llamaindex/references/query_engines.md +406 -0
- package/bin/skills/llava/SKILL.md +304 -0
- package/bin/skills/llava/references/training.md +197 -0
- package/bin/skills/lm-evaluation-harness/SKILL.md +490 -0
- package/bin/skills/lm-evaluation-harness/references/api-evaluation.md +490 -0
- package/bin/skills/lm-evaluation-harness/references/benchmark-guide.md +488 -0
- package/bin/skills/lm-evaluation-harness/references/custom-tasks.md +602 -0
- package/bin/skills/lm-evaluation-harness/references/distributed-eval.md +519 -0
- package/bin/skills/long-context/SKILL.md +536 -0
- package/bin/skills/long-context/references/extension_methods.md +468 -0
- package/bin/skills/long-context/references/fine_tuning.md +611 -0
- package/bin/skills/long-context/references/rope.md +402 -0
- package/bin/skills/mamba/SKILL.md +260 -0
- package/bin/skills/mamba/references/architecture-details.md +206 -0
- package/bin/skills/mamba/references/benchmarks.md +255 -0
- package/bin/skills/mamba/references/training-guide.md +388 -0
- package/bin/skills/megatron-core/SKILL.md +366 -0
- package/bin/skills/megatron-core/references/benchmarks.md +249 -0
- package/bin/skills/megatron-core/references/parallelism-guide.md +404 -0
- package/bin/skills/megatron-core/references/production-examples.md +473 -0
- package/bin/skills/megatron-core/references/training-recipes.md +547 -0
- package/bin/skills/miles/SKILL.md +315 -0
- package/bin/skills/miles/references/api-reference.md +141 -0
- package/bin/skills/miles/references/troubleshooting.md +352 -0
- package/bin/skills/mlflow/SKILL.md +704 -0
- package/bin/skills/mlflow/references/deployment.md +744 -0
- package/bin/skills/mlflow/references/model-registry.md +770 -0
- package/bin/skills/mlflow/references/tracking.md +680 -0
- package/bin/skills/modal/SKILL.md +341 -0
- package/bin/skills/modal/references/advanced-usage.md +503 -0
- package/bin/skills/modal/references/troubleshooting.md +494 -0
- package/bin/skills/model-merging/SKILL.md +539 -0
- package/bin/skills/model-merging/references/evaluation.md +462 -0
- package/bin/skills/model-merging/references/examples.md +428 -0
- package/bin/skills/model-merging/references/methods.md +352 -0
- package/bin/skills/model-pruning/SKILL.md +495 -0
- package/bin/skills/model-pruning/references/wanda.md +347 -0
- package/bin/skills/moe-training/SKILL.md +526 -0
- package/bin/skills/moe-training/references/architectures.md +432 -0
- package/bin/skills/moe-training/references/inference.md +348 -0
- package/bin/skills/moe-training/references/training.md +425 -0
- package/bin/skills/nanogpt/SKILL.md +290 -0
- package/bin/skills/nanogpt/references/architecture.md +382 -0
- package/bin/skills/nanogpt/references/data.md +476 -0
- package/bin/skills/nanogpt/references/training.md +564 -0
- package/bin/skills/nemo-curator/SKILL.md +383 -0
- package/bin/skills/nemo-curator/references/deduplication.md +87 -0
- package/bin/skills/nemo-curator/references/filtering.md +102 -0
- package/bin/skills/nemo-evaluator/SKILL.md +494 -0
- package/bin/skills/nemo-evaluator/references/adapter-system.md +340 -0
- package/bin/skills/nemo-evaluator/references/configuration.md +447 -0
- package/bin/skills/nemo-evaluator/references/custom-benchmarks.md +315 -0
- package/bin/skills/nemo-evaluator/references/execution-backends.md +361 -0
- package/bin/skills/nemo-guardrails/SKILL.md +297 -0
- package/bin/skills/nnsight/SKILL.md +436 -0
- package/bin/skills/nnsight/references/README.md +78 -0
- package/bin/skills/nnsight/references/api.md +344 -0
- package/bin/skills/nnsight/references/tutorials.md +300 -0
- package/bin/skills/openrlhf/SKILL.md +249 -0
- package/bin/skills/openrlhf/references/algorithm-comparison.md +404 -0
- package/bin/skills/openrlhf/references/custom-rewards.md +530 -0
- package/bin/skills/openrlhf/references/hybrid-engine.md +287 -0
- package/bin/skills/openrlhf/references/multi-node-training.md +454 -0
- package/bin/skills/outlines/SKILL.md +652 -0
- package/bin/skills/outlines/references/backends.md +615 -0
- package/bin/skills/outlines/references/examples.md +773 -0
- package/bin/skills/outlines/references/json_generation.md +652 -0
- package/bin/skills/peft/SKILL.md +431 -0
- package/bin/skills/peft/references/advanced-usage.md +514 -0
- package/bin/skills/peft/references/troubleshooting.md +480 -0
- package/bin/skills/phoenix/SKILL.md +475 -0
- package/bin/skills/phoenix/references/advanced-usage.md +619 -0
- package/bin/skills/phoenix/references/troubleshooting.md +538 -0
- package/bin/skills/pinecone/SKILL.md +358 -0
- package/bin/skills/pinecone/references/deployment.md +181 -0
- package/bin/skills/pytorch-fsdp/SKILL.md +126 -0
- package/bin/skills/pytorch-fsdp/references/index.md +7 -0
- package/bin/skills/pytorch-fsdp/references/other.md +4249 -0
- package/bin/skills/pytorch-lightning/SKILL.md +346 -0
- package/bin/skills/pytorch-lightning/references/callbacks.md +436 -0
- package/bin/skills/pytorch-lightning/references/distributed.md +490 -0
- package/bin/skills/pytorch-lightning/references/hyperparameter-tuning.md +556 -0
- package/bin/skills/pyvene/SKILL.md +473 -0
- package/bin/skills/pyvene/references/README.md +73 -0
- package/bin/skills/pyvene/references/api.md +383 -0
- package/bin/skills/pyvene/references/tutorials.md +376 -0
- package/bin/skills/qdrant/SKILL.md +493 -0
- package/bin/skills/qdrant/references/advanced-usage.md +648 -0
- package/bin/skills/qdrant/references/troubleshooting.md +631 -0
- package/bin/skills/ray-data/SKILL.md +326 -0
- package/bin/skills/ray-data/references/integration.md +82 -0
- package/bin/skills/ray-data/references/transformations.md +83 -0
- package/bin/skills/ray-train/SKILL.md +406 -0
- package/bin/skills/ray-train/references/multi-node.md +628 -0
- package/bin/skills/rwkv/SKILL.md +260 -0
- package/bin/skills/rwkv/references/architecture-details.md +344 -0
- package/bin/skills/rwkv/references/rwkv7.md +386 -0
- package/bin/skills/rwkv/references/state-management.md +369 -0
- package/bin/skills/saelens/SKILL.md +386 -0
- package/bin/skills/saelens/references/README.md +70 -0
- package/bin/skills/saelens/references/api.md +333 -0
- package/bin/skills/saelens/references/tutorials.md +318 -0
- package/bin/skills/segment-anything/SKILL.md +500 -0
- package/bin/skills/segment-anything/references/advanced-usage.md +589 -0
- package/bin/skills/segment-anything/references/troubleshooting.md +484 -0
- package/bin/skills/sentence-transformers/SKILL.md +255 -0
- package/bin/skills/sentence-transformers/references/models.md +123 -0
- package/bin/skills/sentencepiece/SKILL.md +235 -0
- package/bin/skills/sentencepiece/references/algorithms.md +200 -0
- package/bin/skills/sentencepiece/references/training.md +304 -0
- package/bin/skills/sglang/SKILL.md +442 -0
- package/bin/skills/sglang/references/deployment.md +490 -0
- package/bin/skills/sglang/references/radix-attention.md +413 -0
- package/bin/skills/sglang/references/structured-generation.md +541 -0
- package/bin/skills/simpo/SKILL.md +219 -0
- package/bin/skills/simpo/references/datasets.md +478 -0
- package/bin/skills/simpo/references/hyperparameters.md +452 -0
- package/bin/skills/simpo/references/loss-functions.md +350 -0
- package/bin/skills/skypilot/SKILL.md +509 -0
- package/bin/skills/skypilot/references/advanced-usage.md +491 -0
- package/bin/skills/skypilot/references/troubleshooting.md +570 -0
- package/bin/skills/slime/SKILL.md +464 -0
- package/bin/skills/slime/references/api-reference.md +392 -0
- package/bin/skills/slime/references/troubleshooting.md +386 -0
- package/bin/skills/speculative-decoding/SKILL.md +467 -0
- package/bin/skills/speculative-decoding/references/lookahead.md +309 -0
- package/bin/skills/speculative-decoding/references/medusa.md +350 -0
- package/bin/skills/stable-diffusion/SKILL.md +519 -0
- package/bin/skills/stable-diffusion/references/advanced-usage.md +716 -0
- package/bin/skills/stable-diffusion/references/troubleshooting.md +555 -0
- package/bin/skills/tensorboard/SKILL.md +629 -0
- package/bin/skills/tensorboard/references/integrations.md +638 -0
- package/bin/skills/tensorboard/references/profiling.md +545 -0
- package/bin/skills/tensorboard/references/visualization.md +620 -0
- package/bin/skills/tensorrt-llm/SKILL.md +187 -0
- package/bin/skills/tensorrt-llm/references/multi-gpu.md +298 -0
- package/bin/skills/tensorrt-llm/references/optimization.md +242 -0
- package/bin/skills/tensorrt-llm/references/serving.md +470 -0
- package/bin/skills/tinker/SKILL.md +362 -0
- package/bin/skills/tinker/references/api-reference.md +168 -0
- package/bin/skills/tinker/references/getting-started.md +157 -0
- package/bin/skills/tinker/references/loss-functions.md +163 -0
- package/bin/skills/tinker/references/models-and-lora.md +139 -0
- package/bin/skills/tinker/references/recipes.md +280 -0
- package/bin/skills/tinker/references/reinforcement-learning.md +212 -0
- package/bin/skills/tinker/references/rendering.md +243 -0
- package/bin/skills/tinker/references/supervised-learning.md +232 -0
- package/bin/skills/tinker-training-cost/SKILL.md +187 -0
- package/bin/skills/tinker-training-cost/scripts/calculate_cost.py +123 -0
- package/bin/skills/torchforge/SKILL.md +433 -0
- package/bin/skills/torchforge/references/api-reference.md +327 -0
- package/bin/skills/torchforge/references/troubleshooting.md +409 -0
- package/bin/skills/torchtitan/SKILL.md +358 -0
- package/bin/skills/torchtitan/references/checkpoint.md +181 -0
- package/bin/skills/torchtitan/references/custom-models.md +258 -0
- package/bin/skills/torchtitan/references/float8.md +133 -0
- package/bin/skills/torchtitan/references/fsdp.md +126 -0
- package/bin/skills/transformer-lens/SKILL.md +346 -0
- package/bin/skills/transformer-lens/references/README.md +54 -0
- package/bin/skills/transformer-lens/references/api.md +362 -0
- package/bin/skills/transformer-lens/references/tutorials.md +339 -0
- package/bin/skills/trl-fine-tuning/SKILL.md +455 -0
- package/bin/skills/trl-fine-tuning/references/dpo-variants.md +227 -0
- package/bin/skills/trl-fine-tuning/references/online-rl.md +82 -0
- package/bin/skills/trl-fine-tuning/references/reward-modeling.md +122 -0
- package/bin/skills/trl-fine-tuning/references/sft-training.md +168 -0
- package/bin/skills/unsloth/SKILL.md +80 -0
- package/bin/skills/unsloth/references/index.md +7 -0
- package/bin/skills/unsloth/references/llms-full.md +16799 -0
- package/bin/skills/unsloth/references/llms-txt.md +12044 -0
- package/bin/skills/unsloth/references/llms.md +82 -0
- package/bin/skills/verl/SKILL.md +391 -0
- package/bin/skills/verl/references/api-reference.md +301 -0
- package/bin/skills/verl/references/troubleshooting.md +391 -0
- package/bin/skills/vllm/SKILL.md +364 -0
- package/bin/skills/vllm/references/optimization.md +226 -0
- package/bin/skills/vllm/references/quantization.md +284 -0
- package/bin/skills/vllm/references/server-deployment.md +255 -0
- package/bin/skills/vllm/references/troubleshooting.md +447 -0
- package/bin/skills/weights-and-biases/SKILL.md +590 -0
- package/bin/skills/weights-and-biases/references/artifacts.md +584 -0
- package/bin/skills/weights-and-biases/references/integrations.md +700 -0
- package/bin/skills/weights-and-biases/references/sweeps.md +847 -0
- package/bin/skills/whisper/SKILL.md +317 -0
- package/bin/skills/whisper/references/languages.md +189 -0
- package/bin/synsc +0 -0
- package/package.json +10 -0
|
@@ -0,0 +1,590 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: dspy
|
|
3
|
+
description: Build complex AI systems with declarative programming, optimize prompts automatically, create modular RAG systems and agents with DSPy - Stanford NLP's framework for systematic LM programming
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
author: Synthetic Sciences
|
|
6
|
+
license: MIT
|
|
7
|
+
tags: [Prompt Engineering, DSPy, Declarative Programming, RAG, Agents, Prompt Optimization, LM Programming, Stanford NLP, Automatic Optimization, Modular AI]
|
|
8
|
+
dependencies: [dspy, openai, anthropic]
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# DSPy: Declarative Language Model Programming
|
|
12
|
+
|
|
13
|
+
## When to Use This Skill
|
|
14
|
+
|
|
15
|
+
Use DSPy when you need to:
|
|
16
|
+
- **Build complex AI systems** with multiple components and workflows
|
|
17
|
+
- **Program LMs declaratively** instead of manual prompt engineering
|
|
18
|
+
- **Optimize prompts automatically** using data-driven methods
|
|
19
|
+
- **Create modular AI pipelines** that are maintainable and portable
|
|
20
|
+
- **Improve model outputs systematically** with optimizers
|
|
21
|
+
- **Build RAG systems, agents, or classifiers** with better reliability
|
|
22
|
+
|
|
23
|
+
**GitHub Stars**: 22,000+ | **Created By**: Stanford NLP
|
|
24
|
+
|
|
25
|
+
## Installation
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
# Stable release
|
|
29
|
+
pip install dspy
|
|
30
|
+
|
|
31
|
+
# Latest development version
|
|
32
|
+
pip install git+https://github.com/stanfordnlp/dspy.git
|
|
33
|
+
|
|
34
|
+
# With specific LM providers
|
|
35
|
+
pip install dspy[openai] # OpenAI
|
|
36
|
+
pip install dspy[anthropic] # Anthropic Claude
|
|
37
|
+
pip install dspy[all] # All providers
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Quick Start
|
|
41
|
+
|
|
42
|
+
### Basic Example: Question Answering
|
|
43
|
+
|
|
44
|
+
```python
|
|
45
|
+
import dspy
|
|
46
|
+
|
|
47
|
+
# Configure your language model
|
|
48
|
+
lm = dspy.Claude(model="claude-sonnet-4-5-20250929")
|
|
49
|
+
dspy.settings.configure(lm=lm)
|
|
50
|
+
|
|
51
|
+
# Define a signature (input → output)
|
|
52
|
+
class QA(dspy.Signature):
|
|
53
|
+
"""Answer questions with short factual answers."""
|
|
54
|
+
question = dspy.InputField()
|
|
55
|
+
answer = dspy.OutputField(desc="often between 1 and 5 words")
|
|
56
|
+
|
|
57
|
+
# Create a module
|
|
58
|
+
qa = dspy.Predict(QA)
|
|
59
|
+
|
|
60
|
+
# Use it
|
|
61
|
+
response = qa(question="What is the capital of France?")
|
|
62
|
+
print(response.answer) # "Paris"
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Chain of Thought Reasoning
|
|
66
|
+
|
|
67
|
+
```python
|
|
68
|
+
import dspy
|
|
69
|
+
|
|
70
|
+
lm = dspy.Claude(model="claude-sonnet-4-5-20250929")
|
|
71
|
+
dspy.settings.configure(lm=lm)
|
|
72
|
+
|
|
73
|
+
# Use ChainOfThought for better reasoning
|
|
74
|
+
class MathProblem(dspy.Signature):
|
|
75
|
+
"""Solve math word problems."""
|
|
76
|
+
problem = dspy.InputField()
|
|
77
|
+
answer = dspy.OutputField(desc="numerical answer")
|
|
78
|
+
|
|
79
|
+
# ChainOfThought generates reasoning steps automatically
|
|
80
|
+
cot = dspy.ChainOfThought(MathProblem)
|
|
81
|
+
|
|
82
|
+
response = cot(problem="If John has 5 apples and gives 2 to Mary, how many does he have?")
|
|
83
|
+
print(response.rationale) # Shows reasoning steps
|
|
84
|
+
print(response.answer) # "3"
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Core Concepts
|
|
88
|
+
|
|
89
|
+
### 1. Signatures
|
|
90
|
+
|
|
91
|
+
Signatures define the structure of your AI task (inputs → outputs):
|
|
92
|
+
|
|
93
|
+
```python
|
|
94
|
+
# Inline signature (simple)
|
|
95
|
+
qa = dspy.Predict("question -> answer")
|
|
96
|
+
|
|
97
|
+
# Class signature (detailed)
|
|
98
|
+
class Summarize(dspy.Signature):
|
|
99
|
+
"""Summarize text into key points."""
|
|
100
|
+
text = dspy.InputField()
|
|
101
|
+
summary = dspy.OutputField(desc="bullet points, 3-5 items")
|
|
102
|
+
|
|
103
|
+
summarizer = dspy.ChainOfThought(Summarize)
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
**When to use each:**
|
|
107
|
+
- **Inline**: Quick prototyping, simple tasks
|
|
108
|
+
- **Class**: Complex tasks, type hints, better documentation
|
|
109
|
+
|
|
110
|
+
### 2. Modules
|
|
111
|
+
|
|
112
|
+
Modules are reusable components that transform inputs to outputs:
|
|
113
|
+
|
|
114
|
+
#### dspy.Predict
|
|
115
|
+
Basic prediction module:
|
|
116
|
+
|
|
117
|
+
```python
|
|
118
|
+
predictor = dspy.Predict("context, question -> answer")
|
|
119
|
+
result = predictor(context="Paris is the capital of France",
|
|
120
|
+
question="What is the capital?")
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
#### dspy.ChainOfThought
|
|
124
|
+
Generates reasoning steps before answering:
|
|
125
|
+
|
|
126
|
+
```python
|
|
127
|
+
cot = dspy.ChainOfThought("question -> answer")
|
|
128
|
+
result = cot(question="Why is the sky blue?")
|
|
129
|
+
print(result.rationale) # Reasoning steps
|
|
130
|
+
print(result.answer) # Final answer
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
#### dspy.ReAct
|
|
134
|
+
Agent-like reasoning with tools:
|
|
135
|
+
|
|
136
|
+
```python
|
|
137
|
+
from dspy.predict import ReAct
|
|
138
|
+
|
|
139
|
+
class SearchQA(dspy.Signature):
|
|
140
|
+
"""Answer questions using search."""
|
|
141
|
+
question = dspy.InputField()
|
|
142
|
+
answer = dspy.OutputField()
|
|
143
|
+
|
|
144
|
+
def search_tool(query: str) -> str:
|
|
145
|
+
"""Search Wikipedia."""
|
|
146
|
+
# Your search implementation
|
|
147
|
+
return results
|
|
148
|
+
|
|
149
|
+
react = ReAct(SearchQA, tools=[search_tool])
|
|
150
|
+
result = react(question="When was Python created?")
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
#### dspy.ProgramOfThought
|
|
154
|
+
Generates and executes code for reasoning:
|
|
155
|
+
|
|
156
|
+
```python
|
|
157
|
+
pot = dspy.ProgramOfThought("question -> answer")
|
|
158
|
+
result = pot(question="What is 15% of 240?")
|
|
159
|
+
# Generates: answer = 240 * 0.15
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### 3. Optimizers
|
|
163
|
+
|
|
164
|
+
Optimizers improve your modules automatically using training data:
|
|
165
|
+
|
|
166
|
+
#### BootstrapFewShot
|
|
167
|
+
Learns from examples:
|
|
168
|
+
|
|
169
|
+
```python
|
|
170
|
+
from dspy.teleprompt import BootstrapFewShot
|
|
171
|
+
|
|
172
|
+
# Training data
|
|
173
|
+
trainset = [
|
|
174
|
+
dspy.Example(question="What is 2+2?", answer="4").with_inputs("question"),
|
|
175
|
+
dspy.Example(question="What is 3+5?", answer="8").with_inputs("question"),
|
|
176
|
+
]
|
|
177
|
+
|
|
178
|
+
# Define metric
|
|
179
|
+
def validate_answer(example, pred, trace=None):
|
|
180
|
+
return example.answer == pred.answer
|
|
181
|
+
|
|
182
|
+
# Optimize
|
|
183
|
+
optimizer = BootstrapFewShot(metric=validate_answer, max_bootstrapped_demos=3)
|
|
184
|
+
optimized_qa = optimizer.compile(qa, trainset=trainset)
|
|
185
|
+
|
|
186
|
+
# Now optimized_qa performs better!
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
#### MIPRO (Most Important Prompt Optimization)
|
|
190
|
+
Iteratively improves prompts:
|
|
191
|
+
|
|
192
|
+
```python
|
|
193
|
+
from dspy.teleprompt import MIPRO
|
|
194
|
+
|
|
195
|
+
optimizer = MIPRO(
|
|
196
|
+
metric=validate_answer,
|
|
197
|
+
num_candidates=10,
|
|
198
|
+
init_temperature=1.0
|
|
199
|
+
)
|
|
200
|
+
|
|
201
|
+
optimized_cot = optimizer.compile(
|
|
202
|
+
cot,
|
|
203
|
+
trainset=trainset,
|
|
204
|
+
num_trials=100
|
|
205
|
+
)
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
#### BootstrapFinetune
|
|
209
|
+
Creates datasets for model fine-tuning:
|
|
210
|
+
|
|
211
|
+
```python
|
|
212
|
+
from dspy.teleprompt import BootstrapFinetune
|
|
213
|
+
|
|
214
|
+
optimizer = BootstrapFinetune(metric=validate_answer)
|
|
215
|
+
optimized_module = optimizer.compile(qa, trainset=trainset)
|
|
216
|
+
|
|
217
|
+
# Exports training data for fine-tuning
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
### 4. Building Complex Systems
|
|
221
|
+
|
|
222
|
+
#### Multi-Stage Pipeline
|
|
223
|
+
|
|
224
|
+
```python
|
|
225
|
+
import dspy
|
|
226
|
+
|
|
227
|
+
class MultiHopQA(dspy.Module):
|
|
228
|
+
def __init__(self):
|
|
229
|
+
super().__init__()
|
|
230
|
+
self.retrieve = dspy.Retrieve(k=3)
|
|
231
|
+
self.generate_query = dspy.ChainOfThought("question -> search_query")
|
|
232
|
+
self.generate_answer = dspy.ChainOfThought("context, question -> answer")
|
|
233
|
+
|
|
234
|
+
def forward(self, question):
|
|
235
|
+
# Stage 1: Generate search query
|
|
236
|
+
search_query = self.generate_query(question=question).search_query
|
|
237
|
+
|
|
238
|
+
# Stage 2: Retrieve context
|
|
239
|
+
passages = self.retrieve(search_query).passages
|
|
240
|
+
context = "\n".join(passages)
|
|
241
|
+
|
|
242
|
+
# Stage 3: Generate answer
|
|
243
|
+
answer = self.generate_answer(context=context, question=question).answer
|
|
244
|
+
return dspy.Prediction(answer=answer, context=context)
|
|
245
|
+
|
|
246
|
+
# Use the pipeline
|
|
247
|
+
qa_system = MultiHopQA()
|
|
248
|
+
result = qa_system(question="Who wrote the book that inspired the movie Blade Runner?")
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
#### RAG System with Optimization
|
|
252
|
+
|
|
253
|
+
```python
|
|
254
|
+
import dspy
|
|
255
|
+
from dspy.retrieve.chromadb_rm import ChromadbRM
|
|
256
|
+
|
|
257
|
+
# Configure retriever
|
|
258
|
+
retriever = ChromadbRM(
|
|
259
|
+
collection_name="documents",
|
|
260
|
+
persist_directory="./chroma_db"
|
|
261
|
+
)
|
|
262
|
+
|
|
263
|
+
class RAG(dspy.Module):
|
|
264
|
+
def __init__(self, num_passages=3):
|
|
265
|
+
super().__init__()
|
|
266
|
+
self.retrieve = dspy.Retrieve(k=num_passages)
|
|
267
|
+
self.generate = dspy.ChainOfThought("context, question -> answer")
|
|
268
|
+
|
|
269
|
+
def forward(self, question):
|
|
270
|
+
context = self.retrieve(question).passages
|
|
271
|
+
return self.generate(context=context, question=question)
|
|
272
|
+
|
|
273
|
+
# Create and optimize
|
|
274
|
+
rag = RAG()
|
|
275
|
+
|
|
276
|
+
# Optimize with training data
|
|
277
|
+
from dspy.teleprompt import BootstrapFewShot
|
|
278
|
+
|
|
279
|
+
optimizer = BootstrapFewShot(metric=validate_answer)
|
|
280
|
+
optimized_rag = optimizer.compile(rag, trainset=trainset)
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
## LM Provider Configuration
|
|
284
|
+
|
|
285
|
+
### Anthropic Claude
|
|
286
|
+
|
|
287
|
+
```python
|
|
288
|
+
import dspy
|
|
289
|
+
|
|
290
|
+
lm = dspy.Claude(
|
|
291
|
+
model="claude-sonnet-4-5-20250929",
|
|
292
|
+
api_key="your-api-key", # Or set ANTHROPIC_API_KEY env var
|
|
293
|
+
max_tokens=1000,
|
|
294
|
+
temperature=0.7
|
|
295
|
+
)
|
|
296
|
+
dspy.settings.configure(lm=lm)
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
### OpenAI
|
|
300
|
+
|
|
301
|
+
```python
|
|
302
|
+
lm = dspy.OpenAI(
|
|
303
|
+
model="gpt-4",
|
|
304
|
+
api_key="your-api-key",
|
|
305
|
+
max_tokens=1000
|
|
306
|
+
)
|
|
307
|
+
dspy.settings.configure(lm=lm)
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
### Local Models (Ollama)
|
|
311
|
+
|
|
312
|
+
```python
|
|
313
|
+
lm = dspy.OllamaLocal(
|
|
314
|
+
model="llama3.1",
|
|
315
|
+
base_url="http://localhost:11434"
|
|
316
|
+
)
|
|
317
|
+
dspy.settings.configure(lm=lm)
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
### Multiple Models
|
|
321
|
+
|
|
322
|
+
```python
|
|
323
|
+
# Different models for different tasks
|
|
324
|
+
cheap_lm = dspy.OpenAI(model="gpt-3.5-turbo")
|
|
325
|
+
strong_lm = dspy.Claude(model="claude-sonnet-4-5-20250929")
|
|
326
|
+
|
|
327
|
+
# Use cheap model for retrieval, strong model for reasoning
|
|
328
|
+
with dspy.settings.context(lm=cheap_lm):
|
|
329
|
+
context = retriever(question)
|
|
330
|
+
|
|
331
|
+
with dspy.settings.context(lm=strong_lm):
|
|
332
|
+
answer = generator(context=context, question=question)
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
## Common Patterns
|
|
336
|
+
|
|
337
|
+
### Pattern 1: Structured Output
|
|
338
|
+
|
|
339
|
+
```python
|
|
340
|
+
from pydantic import BaseModel, Field
|
|
341
|
+
|
|
342
|
+
class PersonInfo(BaseModel):
|
|
343
|
+
name: str = Field(description="Full name")
|
|
344
|
+
age: int = Field(description="Age in years")
|
|
345
|
+
occupation: str = Field(description="Current job")
|
|
346
|
+
|
|
347
|
+
class ExtractPerson(dspy.Signature):
|
|
348
|
+
"""Extract person information from text."""
|
|
349
|
+
text = dspy.InputField()
|
|
350
|
+
person: PersonInfo = dspy.OutputField()
|
|
351
|
+
|
|
352
|
+
extractor = dspy.TypedPredictor(ExtractPerson)
|
|
353
|
+
result = extractor(text="John Doe is a 35-year-old software engineer.")
|
|
354
|
+
print(result.person.name) # "John Doe"
|
|
355
|
+
print(result.person.age) # 35
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
### Pattern 2: Assertion-Driven Optimization
|
|
359
|
+
|
|
360
|
+
```python
|
|
361
|
+
import dspy
|
|
362
|
+
from dspy.primitives.assertions import assert_transform_module, backtrack_handler
|
|
363
|
+
|
|
364
|
+
class MathQA(dspy.Module):
|
|
365
|
+
def __init__(self):
|
|
366
|
+
super().__init__()
|
|
367
|
+
self.solve = dspy.ChainOfThought("problem -> solution: float")
|
|
368
|
+
|
|
369
|
+
def forward(self, problem):
|
|
370
|
+
solution = self.solve(problem=problem).solution
|
|
371
|
+
|
|
372
|
+
# Assert solution is numeric
|
|
373
|
+
dspy.Assert(
|
|
374
|
+
isinstance(float(solution), float),
|
|
375
|
+
"Solution must be a number",
|
|
376
|
+
backtrack=backtrack_handler
|
|
377
|
+
)
|
|
378
|
+
|
|
379
|
+
return dspy.Prediction(solution=solution)
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
### Pattern 3: Self-Consistency
|
|
383
|
+
|
|
384
|
+
```python
|
|
385
|
+
import dspy
|
|
386
|
+
from collections import Counter
|
|
387
|
+
|
|
388
|
+
class ConsistentQA(dspy.Module):
|
|
389
|
+
def __init__(self, num_samples=5):
|
|
390
|
+
super().__init__()
|
|
391
|
+
self.qa = dspy.ChainOfThought("question -> answer")
|
|
392
|
+
self.num_samples = num_samples
|
|
393
|
+
|
|
394
|
+
def forward(self, question):
|
|
395
|
+
# Generate multiple answers
|
|
396
|
+
answers = []
|
|
397
|
+
for _ in range(self.num_samples):
|
|
398
|
+
result = self.qa(question=question)
|
|
399
|
+
answers.append(result.answer)
|
|
400
|
+
|
|
401
|
+
# Return most common answer
|
|
402
|
+
most_common = Counter(answers).most_common(1)[0][0]
|
|
403
|
+
return dspy.Prediction(answer=most_common)
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
### Pattern 4: Retrieval with Reranking
|
|
407
|
+
|
|
408
|
+
```python
|
|
409
|
+
class RerankedRAG(dspy.Module):
|
|
410
|
+
def __init__(self):
|
|
411
|
+
super().__init__()
|
|
412
|
+
self.retrieve = dspy.Retrieve(k=10)
|
|
413
|
+
self.rerank = dspy.Predict("question, passage -> relevance_score: float")
|
|
414
|
+
self.answer = dspy.ChainOfThought("context, question -> answer")
|
|
415
|
+
|
|
416
|
+
def forward(self, question):
|
|
417
|
+
# Retrieve candidates
|
|
418
|
+
passages = self.retrieve(question).passages
|
|
419
|
+
|
|
420
|
+
# Rerank passages
|
|
421
|
+
scored = []
|
|
422
|
+
for passage in passages:
|
|
423
|
+
score = float(self.rerank(question=question, passage=passage).relevance_score)
|
|
424
|
+
scored.append((score, passage))
|
|
425
|
+
|
|
426
|
+
# Take top 3
|
|
427
|
+
top_passages = [p for _, p in sorted(scored, reverse=True)[:3]]
|
|
428
|
+
context = "\n\n".join(top_passages)
|
|
429
|
+
|
|
430
|
+
# Generate answer
|
|
431
|
+
return self.answer(context=context, question=question)
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
## Evaluation and Metrics
|
|
435
|
+
|
|
436
|
+
### Custom Metrics
|
|
437
|
+
|
|
438
|
+
```python
|
|
439
|
+
def exact_match(example, pred, trace=None):
|
|
440
|
+
"""Exact match metric."""
|
|
441
|
+
return example.answer.lower() == pred.answer.lower()
|
|
442
|
+
|
|
443
|
+
def f1_score(example, pred, trace=None):
|
|
444
|
+
"""F1 score for text overlap."""
|
|
445
|
+
pred_tokens = set(pred.answer.lower().split())
|
|
446
|
+
gold_tokens = set(example.answer.lower().split())
|
|
447
|
+
|
|
448
|
+
if not pred_tokens:
|
|
449
|
+
return 0.0
|
|
450
|
+
|
|
451
|
+
precision = len(pred_tokens & gold_tokens) / len(pred_tokens)
|
|
452
|
+
recall = len(pred_tokens & gold_tokens) / len(gold_tokens)
|
|
453
|
+
|
|
454
|
+
if precision + recall == 0:
|
|
455
|
+
return 0.0
|
|
456
|
+
|
|
457
|
+
return 2 * (precision * recall) / (precision + recall)
|
|
458
|
+
```
|
|
459
|
+
|
|
460
|
+
### Evaluation
|
|
461
|
+
|
|
462
|
+
```python
|
|
463
|
+
from dspy.evaluate import Evaluate
|
|
464
|
+
|
|
465
|
+
# Create evaluator
|
|
466
|
+
evaluator = Evaluate(
|
|
467
|
+
devset=testset,
|
|
468
|
+
metric=exact_match,
|
|
469
|
+
num_threads=4,
|
|
470
|
+
display_progress=True
|
|
471
|
+
)
|
|
472
|
+
|
|
473
|
+
# Evaluate model
|
|
474
|
+
score = evaluator(qa_system)
|
|
475
|
+
print(f"Accuracy: {score}")
|
|
476
|
+
|
|
477
|
+
# Compare optimized vs unoptimized
|
|
478
|
+
score_before = evaluator(qa)
|
|
479
|
+
score_after = evaluator(optimized_qa)
|
|
480
|
+
print(f"Improvement: {score_after - score_before:.2%}")
|
|
481
|
+
```
|
|
482
|
+
|
|
483
|
+
## Best Practices
|
|
484
|
+
|
|
485
|
+
### 1. Start Simple, Iterate
|
|
486
|
+
|
|
487
|
+
```python
|
|
488
|
+
# Start with Predict
|
|
489
|
+
qa = dspy.Predict("question -> answer")
|
|
490
|
+
|
|
491
|
+
# Add reasoning if needed
|
|
492
|
+
qa = dspy.ChainOfThought("question -> answer")
|
|
493
|
+
|
|
494
|
+
# Add optimization when you have data
|
|
495
|
+
optimized_qa = optimizer.compile(qa, trainset=data)
|
|
496
|
+
```
|
|
497
|
+
|
|
498
|
+
### 2. Use Descriptive Signatures
|
|
499
|
+
|
|
500
|
+
```python
|
|
501
|
+
# ❌ Bad: Vague
|
|
502
|
+
class Task(dspy.Signature):
|
|
503
|
+
input = dspy.InputField()
|
|
504
|
+
output = dspy.OutputField()
|
|
505
|
+
|
|
506
|
+
# ✅ Good: Descriptive
|
|
507
|
+
class SummarizeArticle(dspy.Signature):
|
|
508
|
+
"""Summarize news articles into 3-5 key points."""
|
|
509
|
+
article = dspy.InputField(desc="full article text")
|
|
510
|
+
summary = dspy.OutputField(desc="bullet points, 3-5 items")
|
|
511
|
+
```
|
|
512
|
+
|
|
513
|
+
### 3. Optimize with Representative Data
|
|
514
|
+
|
|
515
|
+
```python
|
|
516
|
+
# Create diverse training examples
|
|
517
|
+
trainset = [
|
|
518
|
+
dspy.Example(question="factual", answer="...).with_inputs("question"),
|
|
519
|
+
dspy.Example(question="reasoning", answer="...").with_inputs("question"),
|
|
520
|
+
dspy.Example(question="calculation", answer="...").with_inputs("question"),
|
|
521
|
+
]
|
|
522
|
+
|
|
523
|
+
# Use validation set for metric
|
|
524
|
+
def metric(example, pred, trace=None):
|
|
525
|
+
return example.answer in pred.answer
|
|
526
|
+
```
|
|
527
|
+
|
|
528
|
+
### 4. Save and Load Optimized Models
|
|
529
|
+
|
|
530
|
+
```python
|
|
531
|
+
# Save
|
|
532
|
+
optimized_qa.save("models/qa_v1.json")
|
|
533
|
+
|
|
534
|
+
# Load
|
|
535
|
+
loaded_qa = dspy.ChainOfThought("question -> answer")
|
|
536
|
+
loaded_qa.load("models/qa_v1.json")
|
|
537
|
+
```
|
|
538
|
+
|
|
539
|
+
### 5. Monitor and Debug
|
|
540
|
+
|
|
541
|
+
```python
|
|
542
|
+
# Enable tracing
|
|
543
|
+
dspy.settings.configure(lm=lm, trace=[])
|
|
544
|
+
|
|
545
|
+
# Run prediction
|
|
546
|
+
result = qa(question="...")
|
|
547
|
+
|
|
548
|
+
# Inspect trace
|
|
549
|
+
for call in dspy.settings.trace:
|
|
550
|
+
print(f"Prompt: {call['prompt']}")
|
|
551
|
+
print(f"Response: {call['response']}")
|
|
552
|
+
```
|
|
553
|
+
|
|
554
|
+
## Comparison to Other Approaches
|
|
555
|
+
|
|
556
|
+
| Feature | Manual Prompting | LangChain | DSPy |
|
|
557
|
+
|---------|-----------------|-----------|------|
|
|
558
|
+
| Prompt Engineering | Manual | Manual | Automatic |
|
|
559
|
+
| Optimization | Trial & error | None | Data-driven |
|
|
560
|
+
| Modularity | Low | Medium | High |
|
|
561
|
+
| Type Safety | No | Limited | Yes (Signatures) |
|
|
562
|
+
| Portability | Low | Medium | High |
|
|
563
|
+
| Learning Curve | Low | Medium | Medium-High |
|
|
564
|
+
|
|
565
|
+
**When to choose DSPy:**
|
|
566
|
+
- You have training data or can generate it
|
|
567
|
+
- You need systematic prompt improvement
|
|
568
|
+
- You're building complex multi-stage systems
|
|
569
|
+
- You want to optimize across different LMs
|
|
570
|
+
|
|
571
|
+
**When to choose alternatives:**
|
|
572
|
+
- Quick prototypes (manual prompting)
|
|
573
|
+
- Simple chains with existing tools (LangChain)
|
|
574
|
+
- Custom optimization logic needed
|
|
575
|
+
|
|
576
|
+
## Resources
|
|
577
|
+
|
|
578
|
+
- **Documentation**: https://dspy.ai
|
|
579
|
+
- **GitHub**: https://github.com/stanfordnlp/dspy (22k+ stars)
|
|
580
|
+
- **Discord**: https://discord.gg/XCGy2WDCQB
|
|
581
|
+
- **Twitter**: @DSPyOSS
|
|
582
|
+
- **Paper**: "DSPy: Compiling Declarative Language Model Calls into Self-Improving Pipelines"
|
|
583
|
+
|
|
584
|
+
## See Also
|
|
585
|
+
|
|
586
|
+
- `references/modules.md` - Detailed module guide (Predict, ChainOfThought, ReAct, ProgramOfThought)
|
|
587
|
+
- `references/optimizers.md` - Optimization algorithms (BootstrapFewShot, MIPRO, BootstrapFinetune)
|
|
588
|
+
- `references/examples.md` - Real-world examples (RAG, agents, classifiers)
|
|
589
|
+
|
|
590
|
+
|