@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,773 @@
|
|
|
1
|
+
# Production-Ready Examples
|
|
2
|
+
|
|
3
|
+
Real-world examples of using Outlines for structured generation in production systems.
|
|
4
|
+
|
|
5
|
+
## Table of Contents
|
|
6
|
+
- Data Extraction
|
|
7
|
+
- Classification Systems
|
|
8
|
+
- Form Processing
|
|
9
|
+
- Multi-Entity Extraction
|
|
10
|
+
- Code Generation
|
|
11
|
+
- Batch Processing
|
|
12
|
+
- Production Patterns
|
|
13
|
+
|
|
14
|
+
## Data Extraction
|
|
15
|
+
|
|
16
|
+
### Basic Information Extraction
|
|
17
|
+
|
|
18
|
+
```python
|
|
19
|
+
from pydantic import BaseModel, Field
|
|
20
|
+
import outlines
|
|
21
|
+
|
|
22
|
+
class PersonInfo(BaseModel):
|
|
23
|
+
name: str = Field(description="Full name")
|
|
24
|
+
age: int = Field(ge=0, le=120)
|
|
25
|
+
occupation: str
|
|
26
|
+
email: str = Field(pattern=r"^[\w\.-]+@[\w\.-]+\.\w+$")
|
|
27
|
+
location: str
|
|
28
|
+
|
|
29
|
+
model = outlines.models.transformers("microsoft/Phi-3-mini-4k-instruct")
|
|
30
|
+
generator = outlines.generate.json(model, PersonInfo)
|
|
31
|
+
|
|
32
|
+
text = """
|
|
33
|
+
Dr. Sarah Johnson is a 42-year-old research scientist at MIT.
|
|
34
|
+
She can be reached at sarah.j@mit.edu and currently lives in Cambridge, MA.
|
|
35
|
+
"""
|
|
36
|
+
|
|
37
|
+
prompt = f"Extract person information from:\n{text}\n\nPerson:"
|
|
38
|
+
person = generator(prompt)
|
|
39
|
+
|
|
40
|
+
print(f"Name: {person.name}")
|
|
41
|
+
print(f"Age: {person.age}")
|
|
42
|
+
print(f"Occupation: {person.occupation}")
|
|
43
|
+
print(f"Email: {person.email}")
|
|
44
|
+
print(f"Location: {person.location}")
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Company Information
|
|
48
|
+
|
|
49
|
+
```python
|
|
50
|
+
class CompanyInfo(BaseModel):
|
|
51
|
+
name: str
|
|
52
|
+
founded_year: int = Field(ge=1800, le=2025)
|
|
53
|
+
industry: str
|
|
54
|
+
headquarters: str
|
|
55
|
+
employees: int = Field(gt=0)
|
|
56
|
+
revenue: Optional[str] = None
|
|
57
|
+
|
|
58
|
+
model = outlines.models.transformers("meta-llama/Llama-3.1-8B-Instruct")
|
|
59
|
+
generator = outlines.generate.json(model, CompanyInfo)
|
|
60
|
+
|
|
61
|
+
text = """
|
|
62
|
+
Tesla, Inc. was founded in 2003 and operates primarily in the automotive
|
|
63
|
+
and energy industries. The company is headquartered in Austin, Texas,
|
|
64
|
+
and employs approximately 140,000 people worldwide.
|
|
65
|
+
"""
|
|
66
|
+
|
|
67
|
+
company = generator(f"Extract company information:\n{text}\n\nCompany:")
|
|
68
|
+
|
|
69
|
+
print(f"Company: {company.name}")
|
|
70
|
+
print(f"Founded: {company.founded_year}")
|
|
71
|
+
print(f"Industry: {company.industry}")
|
|
72
|
+
print(f"HQ: {company.headquarters}")
|
|
73
|
+
print(f"Employees: {company.employees:,}")
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Product Specifications
|
|
77
|
+
|
|
78
|
+
```python
|
|
79
|
+
class ProductSpec(BaseModel):
|
|
80
|
+
name: str
|
|
81
|
+
brand: str
|
|
82
|
+
price: float = Field(gt=0)
|
|
83
|
+
dimensions: str
|
|
84
|
+
weight: str
|
|
85
|
+
features: list[str]
|
|
86
|
+
rating: Optional[float] = Field(None, ge=0, le=5)
|
|
87
|
+
|
|
88
|
+
generator = outlines.generate.json(model, ProductSpec)
|
|
89
|
+
|
|
90
|
+
text = """
|
|
91
|
+
The Apple iPhone 15 Pro is priced at $999. It measures 146.6 x 70.6 x 8.25 mm
|
|
92
|
+
and weighs 187 grams. Key features include the A17 Pro chip, titanium design,
|
|
93
|
+
action button, and USB-C port. It has an average customer rating of 4.5 stars.
|
|
94
|
+
"""
|
|
95
|
+
|
|
96
|
+
product = generator(f"Extract product specifications:\n{text}\n\nProduct:")
|
|
97
|
+
|
|
98
|
+
print(f"Product: {product.brand} {product.name}")
|
|
99
|
+
print(f"Price: ${product.price}")
|
|
100
|
+
print(f"Features: {', '.join(product.features)}")
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## Classification Systems
|
|
104
|
+
|
|
105
|
+
### Sentiment Analysis
|
|
106
|
+
|
|
107
|
+
```python
|
|
108
|
+
from typing import Literal
|
|
109
|
+
from enum import Enum
|
|
110
|
+
|
|
111
|
+
class Sentiment(str, Enum):
|
|
112
|
+
VERY_POSITIVE = "very_positive"
|
|
113
|
+
POSITIVE = "positive"
|
|
114
|
+
NEUTRAL = "neutral"
|
|
115
|
+
NEGATIVE = "negative"
|
|
116
|
+
VERY_NEGATIVE = "very_negative"
|
|
117
|
+
|
|
118
|
+
class SentimentAnalysis(BaseModel):
|
|
119
|
+
text: str
|
|
120
|
+
sentiment: Sentiment
|
|
121
|
+
confidence: float = Field(ge=0.0, le=1.0)
|
|
122
|
+
aspects: list[str] # What aspects were mentioned
|
|
123
|
+
reasoning: str
|
|
124
|
+
|
|
125
|
+
model = outlines.models.transformers("microsoft/Phi-3-mini-4k-instruct")
|
|
126
|
+
generator = outlines.generate.json(model, SentimentAnalysis)
|
|
127
|
+
|
|
128
|
+
review = """
|
|
129
|
+
This product completely exceeded my expectations! The build quality is
|
|
130
|
+
outstanding, and customer service was incredibly helpful. My only minor
|
|
131
|
+
complaint is the packaging could be better.
|
|
132
|
+
"""
|
|
133
|
+
|
|
134
|
+
result = generator(f"Analyze sentiment:\n{review}\n\nAnalysis:")
|
|
135
|
+
|
|
136
|
+
print(f"Sentiment: {result.sentiment.value}")
|
|
137
|
+
print(f"Confidence: {result.confidence:.2%}")
|
|
138
|
+
print(f"Aspects: {', '.join(result.aspects)}")
|
|
139
|
+
print(f"Reasoning: {result.reasoning}")
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### Content Classification
|
|
143
|
+
|
|
144
|
+
```python
|
|
145
|
+
class Category(str, Enum):
|
|
146
|
+
TECHNOLOGY = "technology"
|
|
147
|
+
BUSINESS = "business"
|
|
148
|
+
SCIENCE = "science"
|
|
149
|
+
POLITICS = "politics"
|
|
150
|
+
ENTERTAINMENT = "entertainment"
|
|
151
|
+
SPORTS = "sports"
|
|
152
|
+
HEALTH = "health"
|
|
153
|
+
|
|
154
|
+
class ArticleClassification(BaseModel):
|
|
155
|
+
primary_category: Category
|
|
156
|
+
secondary_categories: list[Category]
|
|
157
|
+
keywords: list[str] = Field(min_items=3, max_items=10)
|
|
158
|
+
target_audience: Literal["general", "expert", "beginner"]
|
|
159
|
+
reading_level: Literal["elementary", "intermediate", "advanced"]
|
|
160
|
+
|
|
161
|
+
generator = outlines.generate.json(model, ArticleClassification)
|
|
162
|
+
|
|
163
|
+
article = """
|
|
164
|
+
Apple announced groundbreaking advancements in its AI capabilities with the
|
|
165
|
+
release of iOS 18. The new features leverage machine learning to significantly
|
|
166
|
+
improve battery life and overall device performance. Industry analysts predict
|
|
167
|
+
this will strengthen Apple's position in the competitive smartphone market.
|
|
168
|
+
"""
|
|
169
|
+
|
|
170
|
+
classification = generator(f"Classify article:\n{article}\n\nClassification:")
|
|
171
|
+
|
|
172
|
+
print(f"Primary: {classification.primary_category.value}")
|
|
173
|
+
print(f"Secondary: {[c.value for c in classification.secondary_categories]}")
|
|
174
|
+
print(f"Keywords: {classification.keywords}")
|
|
175
|
+
print(f"Audience: {classification.target_audience}")
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### Intent Recognition
|
|
179
|
+
|
|
180
|
+
```python
|
|
181
|
+
class Intent(str, Enum):
|
|
182
|
+
QUESTION = "question"
|
|
183
|
+
COMPLAINT = "complaint"
|
|
184
|
+
REQUEST = "request"
|
|
185
|
+
FEEDBACK = "feedback"
|
|
186
|
+
CANCEL = "cancel"
|
|
187
|
+
UPGRADE = "upgrade"
|
|
188
|
+
|
|
189
|
+
class UserMessage(BaseModel):
|
|
190
|
+
original_message: str
|
|
191
|
+
intent: Intent
|
|
192
|
+
urgency: Literal["low", "medium", "high", "critical"]
|
|
193
|
+
department: Literal["support", "sales", "billing", "technical"]
|
|
194
|
+
sentiment: Literal["positive", "neutral", "negative"]
|
|
195
|
+
action_required: bool
|
|
196
|
+
summary: str
|
|
197
|
+
|
|
198
|
+
generator = outlines.generate.json(model, UserMessage)
|
|
199
|
+
|
|
200
|
+
message = """
|
|
201
|
+
I've been charged twice for my subscription this month! This is the third
|
|
202
|
+
time this has happened. I need someone to fix this immediately and refund
|
|
203
|
+
the extra charge. Very disappointed with this service.
|
|
204
|
+
"""
|
|
205
|
+
|
|
206
|
+
result = generator(f"Analyze message:\n{message}\n\nAnalysis:")
|
|
207
|
+
|
|
208
|
+
print(f"Intent: {result.intent.value}")
|
|
209
|
+
print(f"Urgency: {result.urgency}")
|
|
210
|
+
print(f"Route to: {result.department}")
|
|
211
|
+
print(f"Action required: {result.action_required}")
|
|
212
|
+
print(f"Summary: {result.summary}")
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
## Form Processing
|
|
216
|
+
|
|
217
|
+
### Job Application
|
|
218
|
+
|
|
219
|
+
```python
|
|
220
|
+
class Education(BaseModel):
|
|
221
|
+
degree: str
|
|
222
|
+
field: str
|
|
223
|
+
institution: str
|
|
224
|
+
year: int
|
|
225
|
+
|
|
226
|
+
class Experience(BaseModel):
|
|
227
|
+
title: str
|
|
228
|
+
company: str
|
|
229
|
+
duration: str
|
|
230
|
+
responsibilities: list[str]
|
|
231
|
+
|
|
232
|
+
class JobApplication(BaseModel):
|
|
233
|
+
full_name: str
|
|
234
|
+
email: str
|
|
235
|
+
phone: str
|
|
236
|
+
education: list[Education]
|
|
237
|
+
experience: list[Experience]
|
|
238
|
+
skills: list[str]
|
|
239
|
+
availability: str
|
|
240
|
+
|
|
241
|
+
model = outlines.models.transformers("meta-llama/Llama-3.1-8B-Instruct")
|
|
242
|
+
generator = outlines.generate.json(model, JobApplication)
|
|
243
|
+
|
|
244
|
+
resume_text = """
|
|
245
|
+
John Smith
|
|
246
|
+
Email: john.smith@email.com | Phone: 555-0123
|
|
247
|
+
|
|
248
|
+
EDUCATION
|
|
249
|
+
- BS in Computer Science, MIT, 2018
|
|
250
|
+
- MS in Artificial Intelligence, Stanford, 2020
|
|
251
|
+
|
|
252
|
+
EXPERIENCE
|
|
253
|
+
Software Engineer, Google (2020-2023)
|
|
254
|
+
- Developed ML pipelines for search ranking
|
|
255
|
+
- Led team of 5 engineers
|
|
256
|
+
- Improved search quality by 15%
|
|
257
|
+
|
|
258
|
+
SKILLS: Python, Machine Learning, TensorFlow, System Design
|
|
259
|
+
|
|
260
|
+
AVAILABILITY: Immediate
|
|
261
|
+
"""
|
|
262
|
+
|
|
263
|
+
application = generator(f"Extract job application:\n{resume_text}\n\nApplication:")
|
|
264
|
+
|
|
265
|
+
print(f"Applicant: {application.full_name}")
|
|
266
|
+
print(f"Email: {application.email}")
|
|
267
|
+
print(f"Education: {len(application.education)} degrees")
|
|
268
|
+
for edu in application.education:
|
|
269
|
+
print(f" - {edu.degree} in {edu.field}, {edu.institution} ({edu.year})")
|
|
270
|
+
print(f"Experience: {len(application.experience)} positions")
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
### Invoice Processing
|
|
274
|
+
|
|
275
|
+
```python
|
|
276
|
+
class InvoiceItem(BaseModel):
|
|
277
|
+
description: str
|
|
278
|
+
quantity: int = Field(gt=0)
|
|
279
|
+
unit_price: float = Field(gt=0)
|
|
280
|
+
total: float = Field(gt=0)
|
|
281
|
+
|
|
282
|
+
class Invoice(BaseModel):
|
|
283
|
+
invoice_number: str
|
|
284
|
+
date: str = Field(pattern=r"\d{4}-\d{2}-\d{2}")
|
|
285
|
+
vendor: str
|
|
286
|
+
customer: str
|
|
287
|
+
items: list[InvoiceItem]
|
|
288
|
+
subtotal: float = Field(gt=0)
|
|
289
|
+
tax: float = Field(ge=0)
|
|
290
|
+
total: float = Field(gt=0)
|
|
291
|
+
|
|
292
|
+
generator = outlines.generate.json(model, Invoice)
|
|
293
|
+
|
|
294
|
+
invoice_text = """
|
|
295
|
+
INVOICE #INV-2024-001
|
|
296
|
+
Date: 2024-01-15
|
|
297
|
+
|
|
298
|
+
From: Acme Corp
|
|
299
|
+
To: Smith & Co
|
|
300
|
+
|
|
301
|
+
Items:
|
|
302
|
+
- Widget A: 10 units @ $50.00 = $500.00
|
|
303
|
+
- Widget B: 5 units @ $75.00 = $375.00
|
|
304
|
+
- Service Fee: 1 @ $100.00 = $100.00
|
|
305
|
+
|
|
306
|
+
Subtotal: $975.00
|
|
307
|
+
Tax (8%): $78.00
|
|
308
|
+
TOTAL: $1,053.00
|
|
309
|
+
"""
|
|
310
|
+
|
|
311
|
+
invoice = generator(f"Extract invoice:\n{invoice_text}\n\nInvoice:")
|
|
312
|
+
|
|
313
|
+
print(f"Invoice: {invoice.invoice_number}")
|
|
314
|
+
print(f"From: {invoice.vendor} → To: {invoice.customer}")
|
|
315
|
+
print(f"Items: {len(invoice.items)}")
|
|
316
|
+
for item in invoice.items:
|
|
317
|
+
print(f" - {item.description}: {item.quantity} × ${item.unit_price} = ${item.total}")
|
|
318
|
+
print(f"Total: ${invoice.total}")
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
### Survey Responses
|
|
322
|
+
|
|
323
|
+
```python
|
|
324
|
+
class SurveyResponse(BaseModel):
|
|
325
|
+
respondent_id: str
|
|
326
|
+
completion_date: str
|
|
327
|
+
satisfaction: Literal[1, 2, 3, 4, 5]
|
|
328
|
+
would_recommend: bool
|
|
329
|
+
favorite_features: list[str]
|
|
330
|
+
improvement_areas: list[str]
|
|
331
|
+
additional_comments: Optional[str] = None
|
|
332
|
+
|
|
333
|
+
generator = outlines.generate.json(model, SurveyResponse)
|
|
334
|
+
|
|
335
|
+
survey_text = """
|
|
336
|
+
Survey ID: RESP-12345
|
|
337
|
+
Completed: 2024-01-20
|
|
338
|
+
|
|
339
|
+
How satisfied are you with our product? 4 out of 5
|
|
340
|
+
|
|
341
|
+
Would you recommend to a friend? Yes
|
|
342
|
+
|
|
343
|
+
What features do you like most?
|
|
344
|
+
- Fast performance
|
|
345
|
+
- Easy to use
|
|
346
|
+
- Great customer support
|
|
347
|
+
|
|
348
|
+
What could we improve?
|
|
349
|
+
- Better documentation
|
|
350
|
+
- More integrations
|
|
351
|
+
|
|
352
|
+
Additional feedback: Overall great product, keep up the good work!
|
|
353
|
+
"""
|
|
354
|
+
|
|
355
|
+
response = generator(f"Extract survey response:\n{survey_text}\n\nResponse:")
|
|
356
|
+
|
|
357
|
+
print(f"Respondent: {response.respondent_id}")
|
|
358
|
+
print(f"Satisfaction: {response.satisfaction}/5")
|
|
359
|
+
print(f"Would recommend: {response.would_recommend}")
|
|
360
|
+
print(f"Favorite features: {response.favorite_features}")
|
|
361
|
+
print(f"Improvement areas: {response.improvement_areas}")
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
## Multi-Entity Extraction
|
|
365
|
+
|
|
366
|
+
### News Article Entities
|
|
367
|
+
|
|
368
|
+
```python
|
|
369
|
+
class Person(BaseModel):
|
|
370
|
+
name: str
|
|
371
|
+
role: Optional[str] = None
|
|
372
|
+
affiliation: Optional[str] = None
|
|
373
|
+
|
|
374
|
+
class Organization(BaseModel):
|
|
375
|
+
name: str
|
|
376
|
+
type: Optional[str] = None
|
|
377
|
+
|
|
378
|
+
class Location(BaseModel):
|
|
379
|
+
name: str
|
|
380
|
+
type: Literal["city", "state", "country", "region"]
|
|
381
|
+
|
|
382
|
+
class Event(BaseModel):
|
|
383
|
+
name: str
|
|
384
|
+
date: Optional[str] = None
|
|
385
|
+
location: Optional[str] = None
|
|
386
|
+
|
|
387
|
+
class ArticleEntities(BaseModel):
|
|
388
|
+
people: list[Person]
|
|
389
|
+
organizations: list[Organization]
|
|
390
|
+
locations: list[Location]
|
|
391
|
+
events: list[Event]
|
|
392
|
+
dates: list[str]
|
|
393
|
+
|
|
394
|
+
model = outlines.models.transformers("meta-llama/Llama-3.1-8B-Instruct")
|
|
395
|
+
generator = outlines.generate.json(model, ArticleEntities)
|
|
396
|
+
|
|
397
|
+
article = """
|
|
398
|
+
Apple CEO Tim Cook met with Microsoft CEO Satya Nadella at Microsoft
|
|
399
|
+
headquarters in Redmond, Washington on September 15, 2024, to discuss
|
|
400
|
+
potential collaboration opportunities. The meeting was attended by executives
|
|
401
|
+
from both companies and focused on AI integration strategies. Apple's
|
|
402
|
+
Cupertino offices will host a follow-up meeting on October 20, 2024.
|
|
403
|
+
"""
|
|
404
|
+
|
|
405
|
+
entities = generator(f"Extract all entities:\n{article}\n\nEntities:")
|
|
406
|
+
|
|
407
|
+
print("People:")
|
|
408
|
+
for person in entities.people:
|
|
409
|
+
print(f" - {person.name} ({person.role}) @ {person.affiliation}")
|
|
410
|
+
|
|
411
|
+
print("\nOrganizations:")
|
|
412
|
+
for org in entities.organizations:
|
|
413
|
+
print(f" - {org.name} ({org.type})")
|
|
414
|
+
|
|
415
|
+
print("\nLocations:")
|
|
416
|
+
for loc in entities.locations:
|
|
417
|
+
print(f" - {loc.name} ({loc.type})")
|
|
418
|
+
|
|
419
|
+
print("\nEvents:")
|
|
420
|
+
for event in entities.events:
|
|
421
|
+
print(f" - {event.name} on {event.date}")
|
|
422
|
+
```
|
|
423
|
+
|
|
424
|
+
### Document Metadata
|
|
425
|
+
|
|
426
|
+
```python
|
|
427
|
+
class Author(BaseModel):
|
|
428
|
+
name: str
|
|
429
|
+
email: Optional[str] = None
|
|
430
|
+
affiliation: Optional[str] = None
|
|
431
|
+
|
|
432
|
+
class Reference(BaseModel):
|
|
433
|
+
title: str
|
|
434
|
+
authors: list[str]
|
|
435
|
+
year: int
|
|
436
|
+
source: str
|
|
437
|
+
|
|
438
|
+
class DocumentMetadata(BaseModel):
|
|
439
|
+
title: str
|
|
440
|
+
authors: list[Author]
|
|
441
|
+
abstract: str
|
|
442
|
+
keywords: list[str]
|
|
443
|
+
publication_date: str
|
|
444
|
+
journal: str
|
|
445
|
+
doi: Optional[str] = None
|
|
446
|
+
references: list[Reference]
|
|
447
|
+
|
|
448
|
+
generator = outlines.generate.json(model, DocumentMetadata)
|
|
449
|
+
|
|
450
|
+
paper = """
|
|
451
|
+
Title: Advances in Neural Machine Translation
|
|
452
|
+
|
|
453
|
+
Authors:
|
|
454
|
+
- Dr. Jane Smith (jane@university.edu), MIT
|
|
455
|
+
- Prof. John Doe (jdoe@stanford.edu), Stanford University
|
|
456
|
+
|
|
457
|
+
Abstract: This paper presents novel approaches to neural machine translation
|
|
458
|
+
using transformer architectures. We demonstrate significant improvements in
|
|
459
|
+
translation quality across multiple language pairs.
|
|
460
|
+
|
|
461
|
+
Keywords: Neural Networks, Machine Translation, Transformers, NLP
|
|
462
|
+
|
|
463
|
+
Published: Journal of AI Research, 2024-03-15
|
|
464
|
+
DOI: 10.1234/jair.2024.001
|
|
465
|
+
|
|
466
|
+
References:
|
|
467
|
+
1. "Attention Is All You Need" by Vaswani et al., 2017, NeurIPS
|
|
468
|
+
2. "BERT: Pre-training of Deep Bidirectional Transformers" by Devlin et al., 2019, NAACL
|
|
469
|
+
"""
|
|
470
|
+
|
|
471
|
+
metadata = generator(f"Extract document metadata:\n{paper}\n\nMetadata:")
|
|
472
|
+
|
|
473
|
+
print(f"Title: {metadata.title}")
|
|
474
|
+
print(f"Authors: {', '.join(a.name for a in metadata.authors)}")
|
|
475
|
+
print(f"Keywords: {', '.join(metadata.keywords)}")
|
|
476
|
+
print(f"References: {len(metadata.references)}")
|
|
477
|
+
```
|
|
478
|
+
|
|
479
|
+
## Code Generation
|
|
480
|
+
|
|
481
|
+
### Python Function Generation
|
|
482
|
+
|
|
483
|
+
```python
|
|
484
|
+
class Parameter(BaseModel):
|
|
485
|
+
name: str = Field(pattern=r"^[a-z_][a-z0-9_]*$")
|
|
486
|
+
type_hint: str
|
|
487
|
+
default: Optional[str] = None
|
|
488
|
+
|
|
489
|
+
class PythonFunction(BaseModel):
|
|
490
|
+
function_name: str = Field(pattern=r"^[a-z_][a-z0-9_]*$")
|
|
491
|
+
parameters: list[Parameter]
|
|
492
|
+
return_type: str
|
|
493
|
+
docstring: str
|
|
494
|
+
body: list[str] # Lines of code
|
|
495
|
+
|
|
496
|
+
model = outlines.models.transformers("microsoft/Phi-3-mini-4k-instruct")
|
|
497
|
+
generator = outlines.generate.json(model, PythonFunction)
|
|
498
|
+
|
|
499
|
+
spec = "Create a function to calculate the factorial of a number"
|
|
500
|
+
|
|
501
|
+
func = generator(f"Generate Python function:\n{spec}\n\nFunction:")
|
|
502
|
+
|
|
503
|
+
print(f"def {func.function_name}(", end="")
|
|
504
|
+
print(", ".join(f"{p.name}: {p.type_hint}" for p in func.parameters), end="")
|
|
505
|
+
print(f") -> {func.return_type}:")
|
|
506
|
+
print(f' """{func.docstring}"""')
|
|
507
|
+
for line in func.body:
|
|
508
|
+
print(f" {line}")
|
|
509
|
+
```
|
|
510
|
+
|
|
511
|
+
### SQL Query Generation
|
|
512
|
+
|
|
513
|
+
```python
|
|
514
|
+
class SQLQuery(BaseModel):
|
|
515
|
+
query_type: Literal["SELECT", "INSERT", "UPDATE", "DELETE"]
|
|
516
|
+
select_columns: Optional[list[str]] = None
|
|
517
|
+
from_tables: list[str]
|
|
518
|
+
joins: Optional[list[str]] = None
|
|
519
|
+
where_conditions: Optional[list[str]] = None
|
|
520
|
+
group_by: Optional[list[str]] = None
|
|
521
|
+
order_by: Optional[list[str]] = None
|
|
522
|
+
limit: Optional[int] = None
|
|
523
|
+
|
|
524
|
+
generator = outlines.generate.json(model, SQLQuery)
|
|
525
|
+
|
|
526
|
+
request = "Get top 10 users who made purchases in the last 30 days, ordered by total spent"
|
|
527
|
+
|
|
528
|
+
sql = generator(f"Generate SQL query:\n{request}\n\nQuery:")
|
|
529
|
+
|
|
530
|
+
print(f"Query type: {sql.query_type}")
|
|
531
|
+
print(f"SELECT {', '.join(sql.select_columns)}")
|
|
532
|
+
print(f"FROM {', '.join(sql.from_tables)}")
|
|
533
|
+
if sql.joins:
|
|
534
|
+
for join in sql.joins:
|
|
535
|
+
print(f" {join}")
|
|
536
|
+
if sql.where_conditions:
|
|
537
|
+
print(f"WHERE {' AND '.join(sql.where_conditions)}")
|
|
538
|
+
if sql.order_by:
|
|
539
|
+
print(f"ORDER BY {', '.join(sql.order_by)}")
|
|
540
|
+
if sql.limit:
|
|
541
|
+
print(f"LIMIT {sql.limit}")
|
|
542
|
+
```
|
|
543
|
+
|
|
544
|
+
### API Endpoint Spec
|
|
545
|
+
|
|
546
|
+
```python
|
|
547
|
+
class Parameter(BaseModel):
|
|
548
|
+
name: str
|
|
549
|
+
type: str
|
|
550
|
+
required: bool
|
|
551
|
+
description: str
|
|
552
|
+
|
|
553
|
+
class APIEndpoint(BaseModel):
|
|
554
|
+
method: Literal["GET", "POST", "PUT", "DELETE", "PATCH"]
|
|
555
|
+
path: str
|
|
556
|
+
description: str
|
|
557
|
+
parameters: list[Parameter]
|
|
558
|
+
request_body: Optional[dict] = None
|
|
559
|
+
response_schema: dict
|
|
560
|
+
status_codes: dict[int, str]
|
|
561
|
+
|
|
562
|
+
generator = outlines.generate.json(model, APIEndpoint)
|
|
563
|
+
|
|
564
|
+
spec = "Create user endpoint"
|
|
565
|
+
|
|
566
|
+
endpoint = generator(f"Generate API endpoint:\n{spec}\n\nEndpoint:")
|
|
567
|
+
|
|
568
|
+
print(f"{endpoint.method} {endpoint.path}")
|
|
569
|
+
print(f"Description: {endpoint.description}")
|
|
570
|
+
print("\nParameters:")
|
|
571
|
+
for param in endpoint.parameters:
|
|
572
|
+
req = "required" if param.required else "optional"
|
|
573
|
+
print(f" - {param.name} ({param.type}, {req}): {param.description}")
|
|
574
|
+
```
|
|
575
|
+
|
|
576
|
+
## Batch Processing
|
|
577
|
+
|
|
578
|
+
### Parallel Extraction
|
|
579
|
+
|
|
580
|
+
```python
|
|
581
|
+
def batch_extract(texts: list[str], schema: type[BaseModel], model_name: str):
|
|
582
|
+
"""Extract structured data from multiple texts."""
|
|
583
|
+
model = outlines.models.transformers(model_name)
|
|
584
|
+
generator = outlines.generate.json(model, schema)
|
|
585
|
+
|
|
586
|
+
results = []
|
|
587
|
+
for i, text in enumerate(texts):
|
|
588
|
+
print(f"Processing {i+1}/{len(texts)}...", end="\r")
|
|
589
|
+
result = generator(f"Extract:\n{text}\n\nData:")
|
|
590
|
+
results.append(result)
|
|
591
|
+
|
|
592
|
+
return results
|
|
593
|
+
|
|
594
|
+
class Product(BaseModel):
|
|
595
|
+
name: str
|
|
596
|
+
price: float
|
|
597
|
+
category: str
|
|
598
|
+
|
|
599
|
+
texts = [
|
|
600
|
+
"iPhone 15 Pro costs $999 in Electronics",
|
|
601
|
+
"Running Shoes are $89.99 in Sports",
|
|
602
|
+
"Coffee Maker priced at $49.99 in Home & Kitchen"
|
|
603
|
+
]
|
|
604
|
+
|
|
605
|
+
products = batch_extract(texts, Product, "microsoft/Phi-3-mini-4k-instruct")
|
|
606
|
+
|
|
607
|
+
for product in products:
|
|
608
|
+
print(f"{product.name}: ${product.price} ({product.category})")
|
|
609
|
+
```
|
|
610
|
+
|
|
611
|
+
### CSV Processing
|
|
612
|
+
|
|
613
|
+
```python
|
|
614
|
+
import csv
|
|
615
|
+
|
|
616
|
+
def process_csv(csv_file: str, schema: type[BaseModel]):
|
|
617
|
+
"""Process CSV file and extract structured data."""
|
|
618
|
+
model = outlines.models.transformers("microsoft/Phi-3-mini-4k-instruct")
|
|
619
|
+
generator = outlines.generate.json(model, schema)
|
|
620
|
+
|
|
621
|
+
results = []
|
|
622
|
+
with open(csv_file, 'r') as f:
|
|
623
|
+
reader = csv.DictReader(f)
|
|
624
|
+
for row in reader:
|
|
625
|
+
text = " | ".join(f"{k}: {v}" for k, v in row.items())
|
|
626
|
+
result = generator(f"Extract:\n{text}\n\nData:")
|
|
627
|
+
results.append(result)
|
|
628
|
+
|
|
629
|
+
return results
|
|
630
|
+
|
|
631
|
+
class Customer(BaseModel):
|
|
632
|
+
name: str
|
|
633
|
+
email: str
|
|
634
|
+
tier: Literal["basic", "premium", "enterprise"]
|
|
635
|
+
mrr: float
|
|
636
|
+
|
|
637
|
+
# customers = process_csv("customers.csv", Customer)
|
|
638
|
+
```
|
|
639
|
+
|
|
640
|
+
## Production Patterns
|
|
641
|
+
|
|
642
|
+
### Error Handling
|
|
643
|
+
|
|
644
|
+
```python
|
|
645
|
+
from pydantic import ValidationError
|
|
646
|
+
|
|
647
|
+
def safe_extract(text: str, schema: type[BaseModel], retries: int = 3):
|
|
648
|
+
"""Extract with error handling and retries."""
|
|
649
|
+
model = outlines.models.transformers("microsoft/Phi-3-mini-4k-instruct")
|
|
650
|
+
generator = outlines.generate.json(model, schema)
|
|
651
|
+
|
|
652
|
+
for attempt in range(retries):
|
|
653
|
+
try:
|
|
654
|
+
result = generator(f"Extract:\n{text}\n\nData:")
|
|
655
|
+
return result
|
|
656
|
+
except ValidationError as e:
|
|
657
|
+
print(f"Attempt {attempt + 1} failed: {e}")
|
|
658
|
+
if attempt == retries - 1:
|
|
659
|
+
raise
|
|
660
|
+
except Exception as e:
|
|
661
|
+
print(f"Unexpected error: {e}")
|
|
662
|
+
if attempt == retries - 1:
|
|
663
|
+
raise
|
|
664
|
+
|
|
665
|
+
return None
|
|
666
|
+
```
|
|
667
|
+
|
|
668
|
+
### Caching
|
|
669
|
+
|
|
670
|
+
```python
|
|
671
|
+
from functools import lru_cache
|
|
672
|
+
import hashlib
|
|
673
|
+
|
|
674
|
+
@lru_cache(maxsize=1000)
|
|
675
|
+
def cached_extract(text_hash: str, schema_name: str):
|
|
676
|
+
"""Cache extraction results."""
|
|
677
|
+
# This would be called with actual extraction logic
|
|
678
|
+
pass
|
|
679
|
+
|
|
680
|
+
def extract_with_cache(text: str, schema: type[BaseModel]):
|
|
681
|
+
"""Extract with caching."""
|
|
682
|
+
text_hash = hashlib.md5(text.encode()).hexdigest()
|
|
683
|
+
schema_name = schema.__name__
|
|
684
|
+
|
|
685
|
+
cached_result = cached_extract(text_hash, schema_name)
|
|
686
|
+
if cached_result:
|
|
687
|
+
return cached_result
|
|
688
|
+
|
|
689
|
+
# Perform actual extraction
|
|
690
|
+
model = outlines.models.transformers("microsoft/Phi-3-mini-4k-instruct")
|
|
691
|
+
generator = outlines.generate.json(model, schema)
|
|
692
|
+
result = generator(f"Extract:\n{text}\n\nData:")
|
|
693
|
+
|
|
694
|
+
return result
|
|
695
|
+
```
|
|
696
|
+
|
|
697
|
+
### Monitoring
|
|
698
|
+
|
|
699
|
+
```python
|
|
700
|
+
import time
|
|
701
|
+
import logging
|
|
702
|
+
|
|
703
|
+
logging.basicConfig(level=logging.INFO)
|
|
704
|
+
logger = logging.getLogger(__name__)
|
|
705
|
+
|
|
706
|
+
def monitored_extract(text: str, schema: type[BaseModel]):
|
|
707
|
+
"""Extract with monitoring and logging."""
|
|
708
|
+
start_time = time.time()
|
|
709
|
+
|
|
710
|
+
try:
|
|
711
|
+
model = outlines.models.transformers("microsoft/Phi-3-mini-4k-instruct")
|
|
712
|
+
generator = outlines.generate.json(model, schema)
|
|
713
|
+
|
|
714
|
+
result = generator(f"Extract:\n{text}\n\nData:")
|
|
715
|
+
|
|
716
|
+
elapsed = time.time() - start_time
|
|
717
|
+
logger.info(f"Extraction succeeded in {elapsed:.2f}s")
|
|
718
|
+
logger.info(f"Input length: {len(text)} chars")
|
|
719
|
+
|
|
720
|
+
return result
|
|
721
|
+
|
|
722
|
+
except Exception as e:
|
|
723
|
+
elapsed = time.time() - start_time
|
|
724
|
+
logger.error(f"Extraction failed after {elapsed:.2f}s: {e}")
|
|
725
|
+
raise
|
|
726
|
+
```
|
|
727
|
+
|
|
728
|
+
### Rate Limiting
|
|
729
|
+
|
|
730
|
+
```python
|
|
731
|
+
import time
|
|
732
|
+
from threading import Lock
|
|
733
|
+
|
|
734
|
+
class RateLimiter:
|
|
735
|
+
def __init__(self, max_requests: int, time_window: int):
|
|
736
|
+
self.max_requests = max_requests
|
|
737
|
+
self.time_window = time_window
|
|
738
|
+
self.requests = []
|
|
739
|
+
self.lock = Lock()
|
|
740
|
+
|
|
741
|
+
def wait_if_needed(self):
|
|
742
|
+
with self.lock:
|
|
743
|
+
now = time.time()
|
|
744
|
+
# Remove old requests
|
|
745
|
+
self.requests = [r for r in self.requests if now - r < self.time_window]
|
|
746
|
+
|
|
747
|
+
if len(self.requests) >= self.max_requests:
|
|
748
|
+
sleep_time = self.time_window - (now - self.requests[0])
|
|
749
|
+
time.sleep(sleep_time)
|
|
750
|
+
self.requests = []
|
|
751
|
+
|
|
752
|
+
self.requests.append(now)
|
|
753
|
+
|
|
754
|
+
def rate_limited_extract(texts: list[str], schema: type[BaseModel]):
|
|
755
|
+
"""Extract with rate limiting."""
|
|
756
|
+
limiter = RateLimiter(max_requests=10, time_window=60) # 10 req/min
|
|
757
|
+
model = outlines.models.transformers("microsoft/Phi-3-mini-4k-instruct")
|
|
758
|
+
generator = outlines.generate.json(model, schema)
|
|
759
|
+
|
|
760
|
+
results = []
|
|
761
|
+
for text in texts:
|
|
762
|
+
limiter.wait_if_needed()
|
|
763
|
+
result = generator(f"Extract:\n{text}\n\nData:")
|
|
764
|
+
results.append(result)
|
|
765
|
+
|
|
766
|
+
return results
|
|
767
|
+
```
|
|
768
|
+
|
|
769
|
+
## Resources
|
|
770
|
+
|
|
771
|
+
- **Outlines Documentation**: https://outlines-dev.github.io/outlines
|
|
772
|
+
- **Pydantic Documentation**: https://docs.pydantic.dev
|
|
773
|
+
- **GitHub Examples**: https://github.com/outlines-dev/outlines/tree/main/examples
|