@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,652 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: outlines
|
|
3
|
+
description: Guarantee valid JSON/XML/code structure during generation, use Pydantic models for type-safe outputs, support local models (Transformers, vLLM), and maximize inference speed with Outlines - dottxt.ai's structured generation library
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
author: Synthetic Sciences
|
|
6
|
+
license: MIT
|
|
7
|
+
tags: [Prompt Engineering, Outlines, Structured Generation, JSON Schema, Pydantic, Local Models, Grammar-Based Generation, vLLM, Transformers, Type Safety]
|
|
8
|
+
dependencies: [outlines, transformers, vllm, pydantic]
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# Outlines: Structured Text Generation
|
|
12
|
+
|
|
13
|
+
## When to Use This Skill
|
|
14
|
+
|
|
15
|
+
Use Outlines when you need to:
|
|
16
|
+
- **Guarantee valid JSON/XML/code** structure during generation
|
|
17
|
+
- **Use Pydantic models** for type-safe outputs
|
|
18
|
+
- **Support local models** (Transformers, llama.cpp, vLLM)
|
|
19
|
+
- **Maximize inference speed** with zero-overhead structured generation
|
|
20
|
+
- **Generate against JSON schemas** automatically
|
|
21
|
+
- **Control token sampling** at the grammar level
|
|
22
|
+
|
|
23
|
+
**GitHub Stars**: 8,000+ | **From**: dottxt.ai (formerly .txt)
|
|
24
|
+
|
|
25
|
+
## Installation
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
# Base installation
|
|
29
|
+
pip install outlines
|
|
30
|
+
|
|
31
|
+
# With specific backends
|
|
32
|
+
pip install outlines transformers # Hugging Face models
|
|
33
|
+
pip install outlines llama-cpp-python # llama.cpp
|
|
34
|
+
pip install outlines vllm # vLLM for high-throughput
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Quick Start
|
|
38
|
+
|
|
39
|
+
### Basic Example: Classification
|
|
40
|
+
|
|
41
|
+
```python
|
|
42
|
+
import outlines
|
|
43
|
+
from typing import Literal
|
|
44
|
+
|
|
45
|
+
# Load model
|
|
46
|
+
model = outlines.models.transformers("microsoft/Phi-3-mini-4k-instruct")
|
|
47
|
+
|
|
48
|
+
# Generate with type constraint
|
|
49
|
+
prompt = "Sentiment of 'This product is amazing!': "
|
|
50
|
+
generator = outlines.generate.choice(model, ["positive", "negative", "neutral"])
|
|
51
|
+
sentiment = generator(prompt)
|
|
52
|
+
|
|
53
|
+
print(sentiment) # "positive" (guaranteed one of these)
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### With Pydantic Models
|
|
57
|
+
|
|
58
|
+
```python
|
|
59
|
+
from pydantic import BaseModel
|
|
60
|
+
import outlines
|
|
61
|
+
|
|
62
|
+
class User(BaseModel):
|
|
63
|
+
name: str
|
|
64
|
+
age: int
|
|
65
|
+
email: str
|
|
66
|
+
|
|
67
|
+
model = outlines.models.transformers("microsoft/Phi-3-mini-4k-instruct")
|
|
68
|
+
|
|
69
|
+
# Generate structured output
|
|
70
|
+
prompt = "Extract user: John Doe, 30 years old, john@example.com"
|
|
71
|
+
generator = outlines.generate.json(model, User)
|
|
72
|
+
user = generator(prompt)
|
|
73
|
+
|
|
74
|
+
print(user.name) # "John Doe"
|
|
75
|
+
print(user.age) # 30
|
|
76
|
+
print(user.email) # "john@example.com"
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Core Concepts
|
|
80
|
+
|
|
81
|
+
### 1. Constrained Token Sampling
|
|
82
|
+
|
|
83
|
+
Outlines uses Finite State Machines (FSM) to constrain token generation at the logit level.
|
|
84
|
+
|
|
85
|
+
**How it works:**
|
|
86
|
+
1. Convert schema (JSON/Pydantic/regex) to context-free grammar (CFG)
|
|
87
|
+
2. Transform CFG into Finite State Machine (FSM)
|
|
88
|
+
3. Filter invalid tokens at each step during generation
|
|
89
|
+
4. Fast-forward when only one valid token exists
|
|
90
|
+
|
|
91
|
+
**Benefits:**
|
|
92
|
+
- **Zero overhead**: Filtering happens at token level
|
|
93
|
+
- **Speed improvement**: Fast-forward through deterministic paths
|
|
94
|
+
- **Guaranteed validity**: Invalid outputs impossible
|
|
95
|
+
|
|
96
|
+
```python
|
|
97
|
+
import outlines
|
|
98
|
+
|
|
99
|
+
# Pydantic model -> JSON schema -> CFG -> FSM
|
|
100
|
+
class Person(BaseModel):
|
|
101
|
+
name: str
|
|
102
|
+
age: int
|
|
103
|
+
|
|
104
|
+
model = outlines.models.transformers("microsoft/Phi-3-mini-4k-instruct")
|
|
105
|
+
|
|
106
|
+
# Behind the scenes:
|
|
107
|
+
# 1. Person -> JSON schema
|
|
108
|
+
# 2. JSON schema -> CFG
|
|
109
|
+
# 3. CFG -> FSM
|
|
110
|
+
# 4. FSM filters tokens during generation
|
|
111
|
+
|
|
112
|
+
generator = outlines.generate.json(model, Person)
|
|
113
|
+
result = generator("Generate person: Alice, 25")
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### 2. Structured Generators
|
|
117
|
+
|
|
118
|
+
Outlines provides specialized generators for different output types.
|
|
119
|
+
|
|
120
|
+
#### Choice Generator
|
|
121
|
+
|
|
122
|
+
```python
|
|
123
|
+
# Multiple choice selection
|
|
124
|
+
generator = outlines.generate.choice(
|
|
125
|
+
model,
|
|
126
|
+
["positive", "negative", "neutral"]
|
|
127
|
+
)
|
|
128
|
+
|
|
129
|
+
sentiment = generator("Review: This is great!")
|
|
130
|
+
# Result: One of the three choices
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
#### JSON Generator
|
|
134
|
+
|
|
135
|
+
```python
|
|
136
|
+
from pydantic import BaseModel
|
|
137
|
+
|
|
138
|
+
class Product(BaseModel):
|
|
139
|
+
name: str
|
|
140
|
+
price: float
|
|
141
|
+
in_stock: bool
|
|
142
|
+
|
|
143
|
+
# Generate valid JSON matching schema
|
|
144
|
+
generator = outlines.generate.json(model, Product)
|
|
145
|
+
product = generator("Extract: iPhone 15, $999, available")
|
|
146
|
+
|
|
147
|
+
# Guaranteed valid Product instance
|
|
148
|
+
print(type(product)) # <class '__main__.Product'>
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
#### Regex Generator
|
|
152
|
+
|
|
153
|
+
```python
|
|
154
|
+
# Generate text matching regex
|
|
155
|
+
generator = outlines.generate.regex(
|
|
156
|
+
model,
|
|
157
|
+
r"[0-9]{3}-[0-9]{3}-[0-9]{4}" # Phone number pattern
|
|
158
|
+
)
|
|
159
|
+
|
|
160
|
+
phone = generator("Generate phone number:")
|
|
161
|
+
# Result: "555-123-4567" (guaranteed to match pattern)
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
#### Integer/Float Generators
|
|
165
|
+
|
|
166
|
+
```python
|
|
167
|
+
# Generate specific numeric types
|
|
168
|
+
int_generator = outlines.generate.integer(model)
|
|
169
|
+
age = int_generator("Person's age:") # Guaranteed integer
|
|
170
|
+
|
|
171
|
+
float_generator = outlines.generate.float(model)
|
|
172
|
+
price = float_generator("Product price:") # Guaranteed float
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### 3. Model Backends
|
|
176
|
+
|
|
177
|
+
Outlines supports multiple local and API-based backends.
|
|
178
|
+
|
|
179
|
+
#### Transformers (Hugging Face)
|
|
180
|
+
|
|
181
|
+
```python
|
|
182
|
+
import outlines
|
|
183
|
+
|
|
184
|
+
# Load from Hugging Face
|
|
185
|
+
model = outlines.models.transformers(
|
|
186
|
+
"microsoft/Phi-3-mini-4k-instruct",
|
|
187
|
+
device="cuda" # Or "cpu"
|
|
188
|
+
)
|
|
189
|
+
|
|
190
|
+
# Use with any generator
|
|
191
|
+
generator = outlines.generate.json(model, YourModel)
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
#### llama.cpp
|
|
195
|
+
|
|
196
|
+
```python
|
|
197
|
+
# Load GGUF model
|
|
198
|
+
model = outlines.models.llamacpp(
|
|
199
|
+
"./models/llama-3.1-8b-instruct.Q4_K_M.gguf",
|
|
200
|
+
n_gpu_layers=35
|
|
201
|
+
)
|
|
202
|
+
|
|
203
|
+
generator = outlines.generate.json(model, YourModel)
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
#### vLLM (High Throughput)
|
|
207
|
+
|
|
208
|
+
```python
|
|
209
|
+
# For production deployments
|
|
210
|
+
model = outlines.models.vllm(
|
|
211
|
+
"meta-llama/Llama-3.1-8B-Instruct",
|
|
212
|
+
tensor_parallel_size=2 # Multi-GPU
|
|
213
|
+
)
|
|
214
|
+
|
|
215
|
+
generator = outlines.generate.json(model, YourModel)
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
#### OpenAI (Limited Support)
|
|
219
|
+
|
|
220
|
+
```python
|
|
221
|
+
# Basic OpenAI support
|
|
222
|
+
model = outlines.models.openai(
|
|
223
|
+
"gpt-4o-mini",
|
|
224
|
+
api_key="your-api-key"
|
|
225
|
+
)
|
|
226
|
+
|
|
227
|
+
# Note: Some features limited with API models
|
|
228
|
+
generator = outlines.generate.json(model, YourModel)
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
### 4. Pydantic Integration
|
|
232
|
+
|
|
233
|
+
Outlines has first-class Pydantic support with automatic schema translation.
|
|
234
|
+
|
|
235
|
+
#### Basic Models
|
|
236
|
+
|
|
237
|
+
```python
|
|
238
|
+
from pydantic import BaseModel, Field
|
|
239
|
+
|
|
240
|
+
class Article(BaseModel):
|
|
241
|
+
title: str = Field(description="Article title")
|
|
242
|
+
author: str = Field(description="Author name")
|
|
243
|
+
word_count: int = Field(description="Number of words", gt=0)
|
|
244
|
+
tags: list[str] = Field(description="List of tags")
|
|
245
|
+
|
|
246
|
+
model = outlines.models.transformers("microsoft/Phi-3-mini-4k-instruct")
|
|
247
|
+
generator = outlines.generate.json(model, Article)
|
|
248
|
+
|
|
249
|
+
article = generator("Generate article about AI")
|
|
250
|
+
print(article.title)
|
|
251
|
+
print(article.word_count) # Guaranteed > 0
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
#### Nested Models
|
|
255
|
+
|
|
256
|
+
```python
|
|
257
|
+
class Address(BaseModel):
|
|
258
|
+
street: str
|
|
259
|
+
city: str
|
|
260
|
+
country: str
|
|
261
|
+
|
|
262
|
+
class Person(BaseModel):
|
|
263
|
+
name: str
|
|
264
|
+
age: int
|
|
265
|
+
address: Address # Nested model
|
|
266
|
+
|
|
267
|
+
generator = outlines.generate.json(model, Person)
|
|
268
|
+
person = generator("Generate person in New York")
|
|
269
|
+
|
|
270
|
+
print(person.address.city) # "New York"
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
#### Enums and Literals
|
|
274
|
+
|
|
275
|
+
```python
|
|
276
|
+
from enum import Enum
|
|
277
|
+
from typing import Literal
|
|
278
|
+
|
|
279
|
+
class Status(str, Enum):
|
|
280
|
+
PENDING = "pending"
|
|
281
|
+
APPROVED = "approved"
|
|
282
|
+
REJECTED = "rejected"
|
|
283
|
+
|
|
284
|
+
class Application(BaseModel):
|
|
285
|
+
applicant: str
|
|
286
|
+
status: Status # Must be one of enum values
|
|
287
|
+
priority: Literal["low", "medium", "high"] # Must be one of literals
|
|
288
|
+
|
|
289
|
+
generator = outlines.generate.json(model, Application)
|
|
290
|
+
app = generator("Generate application")
|
|
291
|
+
|
|
292
|
+
print(app.status) # Status.PENDING (or APPROVED/REJECTED)
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
## Common Patterns
|
|
296
|
+
|
|
297
|
+
### Pattern 1: Data Extraction
|
|
298
|
+
|
|
299
|
+
```python
|
|
300
|
+
from pydantic import BaseModel
|
|
301
|
+
import outlines
|
|
302
|
+
|
|
303
|
+
class CompanyInfo(BaseModel):
|
|
304
|
+
name: str
|
|
305
|
+
founded_year: int
|
|
306
|
+
industry: str
|
|
307
|
+
employees: int
|
|
308
|
+
|
|
309
|
+
model = outlines.models.transformers("microsoft/Phi-3-mini-4k-instruct")
|
|
310
|
+
generator = outlines.generate.json(model, CompanyInfo)
|
|
311
|
+
|
|
312
|
+
text = """
|
|
313
|
+
Apple Inc. was founded in 1976 in the technology industry.
|
|
314
|
+
The company employs approximately 164,000 people worldwide.
|
|
315
|
+
"""
|
|
316
|
+
|
|
317
|
+
prompt = f"Extract company information:\n{text}\n\nCompany:"
|
|
318
|
+
company = generator(prompt)
|
|
319
|
+
|
|
320
|
+
print(f"Name: {company.name}")
|
|
321
|
+
print(f"Founded: {company.founded_year}")
|
|
322
|
+
print(f"Industry: {company.industry}")
|
|
323
|
+
print(f"Employees: {company.employees}")
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
### Pattern 2: Classification
|
|
327
|
+
|
|
328
|
+
```python
|
|
329
|
+
from typing import Literal
|
|
330
|
+
import outlines
|
|
331
|
+
|
|
332
|
+
model = outlines.models.transformers("microsoft/Phi-3-mini-4k-instruct")
|
|
333
|
+
|
|
334
|
+
# Binary classification
|
|
335
|
+
generator = outlines.generate.choice(model, ["spam", "not_spam"])
|
|
336
|
+
result = generator("Email: Buy now! 50% off!")
|
|
337
|
+
|
|
338
|
+
# Multi-class classification
|
|
339
|
+
categories = ["technology", "business", "sports", "entertainment"]
|
|
340
|
+
category_gen = outlines.generate.choice(model, categories)
|
|
341
|
+
category = category_gen("Article: Apple announces new iPhone...")
|
|
342
|
+
|
|
343
|
+
# With confidence
|
|
344
|
+
class Classification(BaseModel):
|
|
345
|
+
label: Literal["positive", "negative", "neutral"]
|
|
346
|
+
confidence: float
|
|
347
|
+
|
|
348
|
+
classifier = outlines.generate.json(model, Classification)
|
|
349
|
+
result = classifier("Review: This product is okay, nothing special")
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
### Pattern 3: Structured Forms
|
|
353
|
+
|
|
354
|
+
```python
|
|
355
|
+
class UserProfile(BaseModel):
|
|
356
|
+
full_name: str
|
|
357
|
+
age: int
|
|
358
|
+
email: str
|
|
359
|
+
phone: str
|
|
360
|
+
country: str
|
|
361
|
+
interests: list[str]
|
|
362
|
+
|
|
363
|
+
model = outlines.models.transformers("microsoft/Phi-3-mini-4k-instruct")
|
|
364
|
+
generator = outlines.generate.json(model, UserProfile)
|
|
365
|
+
|
|
366
|
+
prompt = """
|
|
367
|
+
Extract user profile from:
|
|
368
|
+
Name: Alice Johnson
|
|
369
|
+
Age: 28
|
|
370
|
+
Email: alice@example.com
|
|
371
|
+
Phone: 555-0123
|
|
372
|
+
Country: USA
|
|
373
|
+
Interests: hiking, photography, cooking
|
|
374
|
+
"""
|
|
375
|
+
|
|
376
|
+
profile = generator(prompt)
|
|
377
|
+
print(profile.full_name)
|
|
378
|
+
print(profile.interests) # ["hiking", "photography", "cooking"]
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
### Pattern 4: Multi-Entity Extraction
|
|
382
|
+
|
|
383
|
+
```python
|
|
384
|
+
class Entity(BaseModel):
|
|
385
|
+
name: str
|
|
386
|
+
type: Literal["PERSON", "ORGANIZATION", "LOCATION"]
|
|
387
|
+
|
|
388
|
+
class DocumentEntities(BaseModel):
|
|
389
|
+
entities: list[Entity]
|
|
390
|
+
|
|
391
|
+
model = outlines.models.transformers("microsoft/Phi-3-mini-4k-instruct")
|
|
392
|
+
generator = outlines.generate.json(model, DocumentEntities)
|
|
393
|
+
|
|
394
|
+
text = "Tim Cook met with Satya Nadella at Microsoft headquarters in Redmond."
|
|
395
|
+
prompt = f"Extract entities from: {text}"
|
|
396
|
+
|
|
397
|
+
result = generator(prompt)
|
|
398
|
+
for entity in result.entities:
|
|
399
|
+
print(f"{entity.name} ({entity.type})")
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
### Pattern 5: Code Generation
|
|
403
|
+
|
|
404
|
+
```python
|
|
405
|
+
class PythonFunction(BaseModel):
|
|
406
|
+
function_name: str
|
|
407
|
+
parameters: list[str]
|
|
408
|
+
docstring: str
|
|
409
|
+
body: str
|
|
410
|
+
|
|
411
|
+
model = outlines.models.transformers("microsoft/Phi-3-mini-4k-instruct")
|
|
412
|
+
generator = outlines.generate.json(model, PythonFunction)
|
|
413
|
+
|
|
414
|
+
prompt = "Generate a Python function to calculate factorial"
|
|
415
|
+
func = generator(prompt)
|
|
416
|
+
|
|
417
|
+
print(f"def {func.function_name}({', '.join(func.parameters)}):")
|
|
418
|
+
print(f' """{func.docstring}"""')
|
|
419
|
+
print(f" {func.body}")
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
### Pattern 6: Batch Processing
|
|
423
|
+
|
|
424
|
+
```python
|
|
425
|
+
def batch_extract(texts: list[str], schema: type[BaseModel]):
|
|
426
|
+
"""Extract structured data from multiple texts."""
|
|
427
|
+
model = outlines.models.transformers("microsoft/Phi-3-mini-4k-instruct")
|
|
428
|
+
generator = outlines.generate.json(model, schema)
|
|
429
|
+
|
|
430
|
+
results = []
|
|
431
|
+
for text in texts:
|
|
432
|
+
result = generator(f"Extract from: {text}")
|
|
433
|
+
results.append(result)
|
|
434
|
+
|
|
435
|
+
return results
|
|
436
|
+
|
|
437
|
+
class Person(BaseModel):
|
|
438
|
+
name: str
|
|
439
|
+
age: int
|
|
440
|
+
|
|
441
|
+
texts = [
|
|
442
|
+
"John is 30 years old",
|
|
443
|
+
"Alice is 25 years old",
|
|
444
|
+
"Bob is 40 years old"
|
|
445
|
+
]
|
|
446
|
+
|
|
447
|
+
people = batch_extract(texts, Person)
|
|
448
|
+
for person in people:
|
|
449
|
+
print(f"{person.name}: {person.age}")
|
|
450
|
+
```
|
|
451
|
+
|
|
452
|
+
## Backend Configuration
|
|
453
|
+
|
|
454
|
+
### Transformers
|
|
455
|
+
|
|
456
|
+
```python
|
|
457
|
+
import outlines
|
|
458
|
+
|
|
459
|
+
# Basic usage
|
|
460
|
+
model = outlines.models.transformers("microsoft/Phi-3-mini-4k-instruct")
|
|
461
|
+
|
|
462
|
+
# GPU configuration
|
|
463
|
+
model = outlines.models.transformers(
|
|
464
|
+
"microsoft/Phi-3-mini-4k-instruct",
|
|
465
|
+
device="cuda",
|
|
466
|
+
model_kwargs={"torch_dtype": "float16"}
|
|
467
|
+
)
|
|
468
|
+
|
|
469
|
+
# Popular models
|
|
470
|
+
model = outlines.models.transformers("meta-llama/Llama-3.1-8B-Instruct")
|
|
471
|
+
model = outlines.models.transformers("mistralai/Mistral-7B-Instruct-v0.3")
|
|
472
|
+
model = outlines.models.transformers("Qwen/Qwen2.5-7B-Instruct")
|
|
473
|
+
```
|
|
474
|
+
|
|
475
|
+
### llama.cpp
|
|
476
|
+
|
|
477
|
+
```python
|
|
478
|
+
# Load GGUF model
|
|
479
|
+
model = outlines.models.llamacpp(
|
|
480
|
+
"./models/llama-3.1-8b.Q4_K_M.gguf",
|
|
481
|
+
n_ctx=4096, # Context window
|
|
482
|
+
n_gpu_layers=35, # GPU layers
|
|
483
|
+
n_threads=8 # CPU threads
|
|
484
|
+
)
|
|
485
|
+
|
|
486
|
+
# Full GPU offload
|
|
487
|
+
model = outlines.models.llamacpp(
|
|
488
|
+
"./models/model.gguf",
|
|
489
|
+
n_gpu_layers=-1 # All layers on GPU
|
|
490
|
+
)
|
|
491
|
+
```
|
|
492
|
+
|
|
493
|
+
### vLLM (Production)
|
|
494
|
+
|
|
495
|
+
```python
|
|
496
|
+
# Single GPU
|
|
497
|
+
model = outlines.models.vllm("meta-llama/Llama-3.1-8B-Instruct")
|
|
498
|
+
|
|
499
|
+
# Multi-GPU
|
|
500
|
+
model = outlines.models.vllm(
|
|
501
|
+
"meta-llama/Llama-3.1-70B-Instruct",
|
|
502
|
+
tensor_parallel_size=4 # 4 GPUs
|
|
503
|
+
)
|
|
504
|
+
|
|
505
|
+
# With quantization
|
|
506
|
+
model = outlines.models.vllm(
|
|
507
|
+
"meta-llama/Llama-3.1-8B-Instruct",
|
|
508
|
+
quantization="awq" # Or "gptq"
|
|
509
|
+
)
|
|
510
|
+
```
|
|
511
|
+
|
|
512
|
+
## Best Practices
|
|
513
|
+
|
|
514
|
+
### 1. Use Specific Types
|
|
515
|
+
|
|
516
|
+
```python
|
|
517
|
+
# ✅ Good: Specific types
|
|
518
|
+
class Product(BaseModel):
|
|
519
|
+
name: str
|
|
520
|
+
price: float # Not str
|
|
521
|
+
quantity: int # Not str
|
|
522
|
+
in_stock: bool # Not str
|
|
523
|
+
|
|
524
|
+
# ❌ Bad: Everything as string
|
|
525
|
+
class Product(BaseModel):
|
|
526
|
+
name: str
|
|
527
|
+
price: str # Should be float
|
|
528
|
+
quantity: str # Should be int
|
|
529
|
+
```
|
|
530
|
+
|
|
531
|
+
### 2. Add Constraints
|
|
532
|
+
|
|
533
|
+
```python
|
|
534
|
+
from pydantic import Field
|
|
535
|
+
|
|
536
|
+
# ✅ Good: With constraints
|
|
537
|
+
class User(BaseModel):
|
|
538
|
+
name: str = Field(min_length=1, max_length=100)
|
|
539
|
+
age: int = Field(ge=0, le=120)
|
|
540
|
+
email: str = Field(pattern=r"^[\w\.-]+@[\w\.-]+\.\w+$")
|
|
541
|
+
|
|
542
|
+
# ❌ Bad: No constraints
|
|
543
|
+
class User(BaseModel):
|
|
544
|
+
name: str
|
|
545
|
+
age: int
|
|
546
|
+
email: str
|
|
547
|
+
```
|
|
548
|
+
|
|
549
|
+
### 3. Use Enums for Categories
|
|
550
|
+
|
|
551
|
+
```python
|
|
552
|
+
# ✅ Good: Enum for fixed set
|
|
553
|
+
class Priority(str, Enum):
|
|
554
|
+
LOW = "low"
|
|
555
|
+
MEDIUM = "medium"
|
|
556
|
+
HIGH = "high"
|
|
557
|
+
|
|
558
|
+
class Task(BaseModel):
|
|
559
|
+
title: str
|
|
560
|
+
priority: Priority
|
|
561
|
+
|
|
562
|
+
# ❌ Bad: Free-form string
|
|
563
|
+
class Task(BaseModel):
|
|
564
|
+
title: str
|
|
565
|
+
priority: str # Can be anything
|
|
566
|
+
```
|
|
567
|
+
|
|
568
|
+
### 4. Provide Context in Prompts
|
|
569
|
+
|
|
570
|
+
```python
|
|
571
|
+
# ✅ Good: Clear context
|
|
572
|
+
prompt = """
|
|
573
|
+
Extract product information from the following text.
|
|
574
|
+
Text: iPhone 15 Pro costs $999 and is currently in stock.
|
|
575
|
+
Product:
|
|
576
|
+
"""
|
|
577
|
+
|
|
578
|
+
# ❌ Bad: Minimal context
|
|
579
|
+
prompt = "iPhone 15 Pro costs $999 and is currently in stock."
|
|
580
|
+
```
|
|
581
|
+
|
|
582
|
+
### 5. Handle Optional Fields
|
|
583
|
+
|
|
584
|
+
```python
|
|
585
|
+
from typing import Optional
|
|
586
|
+
|
|
587
|
+
# ✅ Good: Optional fields for incomplete data
|
|
588
|
+
class Article(BaseModel):
|
|
589
|
+
title: str # Required
|
|
590
|
+
author: Optional[str] = None # Optional
|
|
591
|
+
date: Optional[str] = None # Optional
|
|
592
|
+
tags: list[str] = [] # Default empty list
|
|
593
|
+
|
|
594
|
+
# Can succeed even if author/date missing
|
|
595
|
+
```
|
|
596
|
+
|
|
597
|
+
## Comparison to Alternatives
|
|
598
|
+
|
|
599
|
+
| Feature | Outlines | Instructor | Guidance | LMQL |
|
|
600
|
+
|---------|----------|------------|----------|------|
|
|
601
|
+
| Pydantic Support | ✅ Native | ✅ Native | ❌ No | ❌ No |
|
|
602
|
+
| JSON Schema | ✅ Yes | ✅ Yes | ⚠️ Limited | ✅ Yes |
|
|
603
|
+
| Regex Constraints | ✅ Yes | ❌ No | ✅ Yes | ✅ Yes |
|
|
604
|
+
| Local Models | ✅ Full | ⚠️ Limited | ✅ Full | ✅ Full |
|
|
605
|
+
| API Models | ⚠️ Limited | ✅ Full | ✅ Full | ✅ Full |
|
|
606
|
+
| Zero Overhead | ✅ Yes | ❌ No | ⚠️ Partial | ✅ Yes |
|
|
607
|
+
| Automatic Retrying | ❌ No | ✅ Yes | ❌ No | ❌ No |
|
|
608
|
+
| Learning Curve | Low | Low | Low | High |
|
|
609
|
+
|
|
610
|
+
**When to choose Outlines:**
|
|
611
|
+
- Using local models (Transformers, llama.cpp, vLLM)
|
|
612
|
+
- Need maximum inference speed
|
|
613
|
+
- Want Pydantic model support
|
|
614
|
+
- Require zero-overhead structured generation
|
|
615
|
+
- Control token sampling process
|
|
616
|
+
|
|
617
|
+
**When to choose alternatives:**
|
|
618
|
+
- Instructor: Need API models with automatic retrying
|
|
619
|
+
- Guidance: Need token healing and complex workflows
|
|
620
|
+
- LMQL: Prefer declarative query syntax
|
|
621
|
+
|
|
622
|
+
## Performance Characteristics
|
|
623
|
+
|
|
624
|
+
**Speed:**
|
|
625
|
+
- **Zero overhead**: Structured generation as fast as unconstrained
|
|
626
|
+
- **Fast-forward optimization**: Skips deterministic tokens
|
|
627
|
+
- **1.2-2x faster** than post-generation validation approaches
|
|
628
|
+
|
|
629
|
+
**Memory:**
|
|
630
|
+
- FSM compiled once per schema (cached)
|
|
631
|
+
- Minimal runtime overhead
|
|
632
|
+
- Efficient with vLLM for high throughput
|
|
633
|
+
|
|
634
|
+
**Accuracy:**
|
|
635
|
+
- **100% valid outputs** (guaranteed by FSM)
|
|
636
|
+
- No retry loops needed
|
|
637
|
+
- Deterministic token filtering
|
|
638
|
+
|
|
639
|
+
## Resources
|
|
640
|
+
|
|
641
|
+
- **Documentation**: https://outlines-dev.github.io/outlines
|
|
642
|
+
- **GitHub**: https://github.com/outlines-dev/outlines (8k+ stars)
|
|
643
|
+
- **Discord**: https://discord.gg/R9DSu34mGd
|
|
644
|
+
- **Blog**: https://blog.dottxt.co
|
|
645
|
+
|
|
646
|
+
## See Also
|
|
647
|
+
|
|
648
|
+
- `references/json_generation.md` - Comprehensive JSON and Pydantic patterns
|
|
649
|
+
- `references/backends.md` - Backend-specific configuration
|
|
650
|
+
- `references/examples.md` - Production-ready examples
|
|
651
|
+
|
|
652
|
+
|