@synsci/cli-darwin-arm64 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,473 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: pyvene-interventions
|
|
3
|
+
description: Provides guidance for performing causal interventions on PyTorch models using pyvene's declarative intervention framework. Use when conducting causal tracing, activation patching, interchange intervention training, or testing causal hypotheses about model behavior.
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
author: Synthetic Sciences
|
|
6
|
+
license: MIT
|
|
7
|
+
tags: [Causal Intervention, pyvene, Activation Patching, Causal Tracing, Interpretability]
|
|
8
|
+
dependencies: [pyvene>=0.1.8, torch>=2.0.0, transformers>=4.30.0]
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# pyvene: Causal Interventions for Neural Networks
|
|
12
|
+
|
|
13
|
+
pyvene is Stanford NLP's library for performing causal interventions on PyTorch models. It provides a declarative, dict-based framework for activation patching, causal tracing, and interchange intervention training - making intervention experiments reproducible and shareable.
|
|
14
|
+
|
|
15
|
+
**GitHub**: [stanfordnlp/pyvene](https://github.com/stanfordnlp/pyvene) (840+ stars)
|
|
16
|
+
**Paper**: [pyvene: A Library for Understanding and Improving PyTorch Models via Interventions](https://aclanthology.org/2024.naacl-demo.16) (NAACL 2024)
|
|
17
|
+
|
|
18
|
+
## When to Use pyvene
|
|
19
|
+
|
|
20
|
+
**Use pyvene when you need to:**
|
|
21
|
+
- Perform causal tracing (ROME-style localization)
|
|
22
|
+
- Run activation patching experiments
|
|
23
|
+
- Conduct interchange intervention training (IIT)
|
|
24
|
+
- Test causal hypotheses about model components
|
|
25
|
+
- Share/reproduce intervention experiments via HuggingFace
|
|
26
|
+
- Work with any PyTorch architecture (not just transformers)
|
|
27
|
+
|
|
28
|
+
**Consider alternatives when:**
|
|
29
|
+
- You need exploratory activation analysis → Use **TransformerLens**
|
|
30
|
+
- You want to train/analyze SAEs → Use **SAELens**
|
|
31
|
+
- You need remote execution on massive models → Use **nnsight**
|
|
32
|
+
- You want lower-level control → Use **nnsight**
|
|
33
|
+
|
|
34
|
+
## Installation
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
pip install pyvene
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Standard import:
|
|
41
|
+
```python
|
|
42
|
+
import pyvene as pv
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Core Concepts
|
|
46
|
+
|
|
47
|
+
### IntervenableModel
|
|
48
|
+
|
|
49
|
+
The main class that wraps any PyTorch model with intervention capabilities:
|
|
50
|
+
|
|
51
|
+
```python
|
|
52
|
+
import pyvene as pv
|
|
53
|
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
|
54
|
+
|
|
55
|
+
# Load base model
|
|
56
|
+
model = AutoModelForCausalLM.from_pretrained("gpt2")
|
|
57
|
+
tokenizer = AutoTokenizer.from_pretrained("gpt2")
|
|
58
|
+
|
|
59
|
+
# Define intervention configuration
|
|
60
|
+
config = pv.IntervenableConfig(
|
|
61
|
+
representations=[
|
|
62
|
+
pv.RepresentationConfig(
|
|
63
|
+
layer=8,
|
|
64
|
+
component="block_output",
|
|
65
|
+
intervention_type=pv.VanillaIntervention,
|
|
66
|
+
)
|
|
67
|
+
]
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
# Create intervenable model
|
|
71
|
+
intervenable = pv.IntervenableModel(config, model)
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Intervention Types
|
|
75
|
+
|
|
76
|
+
| Type | Description | Use Case |
|
|
77
|
+
|------|-------------|----------|
|
|
78
|
+
| `VanillaIntervention` | Swap activations between runs | Activation patching |
|
|
79
|
+
| `AdditionIntervention` | Add activations to base run | Steering, ablation |
|
|
80
|
+
| `SubtractionIntervention` | Subtract activations | Ablation |
|
|
81
|
+
| `ZeroIntervention` | Zero out activations | Component knockout |
|
|
82
|
+
| `RotatedSpaceIntervention` | DAS trainable intervention | Causal discovery |
|
|
83
|
+
| `CollectIntervention` | Collect activations | Probing, analysis |
|
|
84
|
+
|
|
85
|
+
### Component Targets
|
|
86
|
+
|
|
87
|
+
```python
|
|
88
|
+
# Available components to intervene on
|
|
89
|
+
components = [
|
|
90
|
+
"block_input", # Input to transformer block
|
|
91
|
+
"block_output", # Output of transformer block
|
|
92
|
+
"mlp_input", # Input to MLP
|
|
93
|
+
"mlp_output", # Output of MLP
|
|
94
|
+
"mlp_activation", # MLP hidden activations
|
|
95
|
+
"attention_input", # Input to attention
|
|
96
|
+
"attention_output", # Output of attention
|
|
97
|
+
"attention_value_output", # Attention value vectors
|
|
98
|
+
"query_output", # Query vectors
|
|
99
|
+
"key_output", # Key vectors
|
|
100
|
+
"value_output", # Value vectors
|
|
101
|
+
"head_attention_value_output", # Per-head values
|
|
102
|
+
]
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## Workflow 1: Causal Tracing (ROME-style)
|
|
106
|
+
|
|
107
|
+
Locate where factual associations are stored by corrupting inputs and restoring activations.
|
|
108
|
+
|
|
109
|
+
### Step-by-Step
|
|
110
|
+
|
|
111
|
+
```python
|
|
112
|
+
import pyvene as pv
|
|
113
|
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
|
114
|
+
import torch
|
|
115
|
+
|
|
116
|
+
model = AutoModelForCausalLM.from_pretrained("gpt2-xl")
|
|
117
|
+
tokenizer = AutoTokenizer.from_pretrained("gpt2-xl")
|
|
118
|
+
|
|
119
|
+
# 1. Define clean and corrupted inputs
|
|
120
|
+
clean_prompt = "The Space Needle is in downtown"
|
|
121
|
+
corrupted_prompt = "The ##### ###### ## ## ########" # Noise
|
|
122
|
+
|
|
123
|
+
clean_tokens = tokenizer(clean_prompt, return_tensors="pt")
|
|
124
|
+
corrupted_tokens = tokenizer(corrupted_prompt, return_tensors="pt")
|
|
125
|
+
|
|
126
|
+
# 2. Get clean activations (source)
|
|
127
|
+
with torch.no_grad():
|
|
128
|
+
clean_outputs = model(**clean_tokens, output_hidden_states=True)
|
|
129
|
+
clean_states = clean_outputs.hidden_states
|
|
130
|
+
|
|
131
|
+
# 3. Define restoration intervention
|
|
132
|
+
def run_causal_trace(layer, position):
|
|
133
|
+
"""Restore clean activation at specific layer and position."""
|
|
134
|
+
config = pv.IntervenableConfig(
|
|
135
|
+
representations=[
|
|
136
|
+
pv.RepresentationConfig(
|
|
137
|
+
layer=layer,
|
|
138
|
+
component="block_output",
|
|
139
|
+
intervention_type=pv.VanillaIntervention,
|
|
140
|
+
unit="pos",
|
|
141
|
+
max_number_of_units=1,
|
|
142
|
+
)
|
|
143
|
+
]
|
|
144
|
+
)
|
|
145
|
+
|
|
146
|
+
intervenable = pv.IntervenableModel(config, model)
|
|
147
|
+
|
|
148
|
+
# Run with intervention
|
|
149
|
+
_, patched_outputs = intervenable(
|
|
150
|
+
base=corrupted_tokens,
|
|
151
|
+
sources=[clean_tokens],
|
|
152
|
+
unit_locations={"sources->base": ([[[position]]], [[[position]]])},
|
|
153
|
+
output_original_output=True,
|
|
154
|
+
)
|
|
155
|
+
|
|
156
|
+
# Return probability of correct token
|
|
157
|
+
probs = torch.softmax(patched_outputs.logits[0, -1], dim=-1)
|
|
158
|
+
seattle_token = tokenizer.encode(" Seattle")[0]
|
|
159
|
+
return probs[seattle_token].item()
|
|
160
|
+
|
|
161
|
+
# 4. Sweep over layers and positions
|
|
162
|
+
n_layers = model.config.n_layer
|
|
163
|
+
seq_len = clean_tokens["input_ids"].shape[1]
|
|
164
|
+
|
|
165
|
+
results = torch.zeros(n_layers, seq_len)
|
|
166
|
+
for layer in range(n_layers):
|
|
167
|
+
for pos in range(seq_len):
|
|
168
|
+
results[layer, pos] = run_causal_trace(layer, pos)
|
|
169
|
+
|
|
170
|
+
# 5. Visualize (layer x position heatmap)
|
|
171
|
+
# High values indicate causal importance
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### Checklist
|
|
175
|
+
- [ ] Prepare clean prompt with target factual association
|
|
176
|
+
- [ ] Create corrupted version (noise or counterfactual)
|
|
177
|
+
- [ ] Define intervention config for each (layer, position)
|
|
178
|
+
- [ ] Run patching sweep
|
|
179
|
+
- [ ] Identify causal hotspots in heatmap
|
|
180
|
+
|
|
181
|
+
## Workflow 2: Activation Patching for Circuit Analysis
|
|
182
|
+
|
|
183
|
+
Test which components are necessary for a specific behavior.
|
|
184
|
+
|
|
185
|
+
### Step-by-Step
|
|
186
|
+
|
|
187
|
+
```python
|
|
188
|
+
import pyvene as pv
|
|
189
|
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
|
190
|
+
import torch
|
|
191
|
+
|
|
192
|
+
model = AutoModelForCausalLM.from_pretrained("gpt2")
|
|
193
|
+
tokenizer = AutoTokenizer.from_pretrained("gpt2")
|
|
194
|
+
|
|
195
|
+
# IOI task setup
|
|
196
|
+
clean_prompt = "When John and Mary went to the store, Mary gave a bottle to"
|
|
197
|
+
corrupted_prompt = "When John and Mary went to the store, John gave a bottle to"
|
|
198
|
+
|
|
199
|
+
clean_tokens = tokenizer(clean_prompt, return_tensors="pt")
|
|
200
|
+
corrupted_tokens = tokenizer(corrupted_prompt, return_tensors="pt")
|
|
201
|
+
|
|
202
|
+
john_token = tokenizer.encode(" John")[0]
|
|
203
|
+
mary_token = tokenizer.encode(" Mary")[0]
|
|
204
|
+
|
|
205
|
+
def logit_diff(logits):
|
|
206
|
+
"""IO - S logit difference."""
|
|
207
|
+
return logits[0, -1, john_token] - logits[0, -1, mary_token]
|
|
208
|
+
|
|
209
|
+
# Patch attention output at each layer
|
|
210
|
+
def patch_attention(layer):
|
|
211
|
+
config = pv.IntervenableConfig(
|
|
212
|
+
representations=[
|
|
213
|
+
pv.RepresentationConfig(
|
|
214
|
+
layer=layer,
|
|
215
|
+
component="attention_output",
|
|
216
|
+
intervention_type=pv.VanillaIntervention,
|
|
217
|
+
)
|
|
218
|
+
]
|
|
219
|
+
)
|
|
220
|
+
|
|
221
|
+
intervenable = pv.IntervenableModel(config, model)
|
|
222
|
+
|
|
223
|
+
_, patched_outputs = intervenable(
|
|
224
|
+
base=corrupted_tokens,
|
|
225
|
+
sources=[clean_tokens],
|
|
226
|
+
)
|
|
227
|
+
|
|
228
|
+
return logit_diff(patched_outputs.logits).item()
|
|
229
|
+
|
|
230
|
+
# Find which layers matter
|
|
231
|
+
results = []
|
|
232
|
+
for layer in range(model.config.n_layer):
|
|
233
|
+
diff = patch_attention(layer)
|
|
234
|
+
results.append(diff)
|
|
235
|
+
print(f"Layer {layer}: logit diff = {diff:.3f}")
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
## Workflow 3: Interchange Intervention Training (IIT)
|
|
239
|
+
|
|
240
|
+
Train interventions to discover causal structure.
|
|
241
|
+
|
|
242
|
+
### Step-by-Step
|
|
243
|
+
|
|
244
|
+
```python
|
|
245
|
+
import pyvene as pv
|
|
246
|
+
from transformers import AutoModelForCausalLM
|
|
247
|
+
import torch
|
|
248
|
+
|
|
249
|
+
model = AutoModelForCausalLM.from_pretrained("gpt2")
|
|
250
|
+
|
|
251
|
+
# 1. Define trainable intervention
|
|
252
|
+
config = pv.IntervenableConfig(
|
|
253
|
+
representations=[
|
|
254
|
+
pv.RepresentationConfig(
|
|
255
|
+
layer=6,
|
|
256
|
+
component="block_output",
|
|
257
|
+
intervention_type=pv.RotatedSpaceIntervention, # Trainable
|
|
258
|
+
low_rank_dimension=64, # Learn 64-dim subspace
|
|
259
|
+
)
|
|
260
|
+
]
|
|
261
|
+
)
|
|
262
|
+
|
|
263
|
+
intervenable = pv.IntervenableModel(config, model)
|
|
264
|
+
|
|
265
|
+
# 2. Set up training
|
|
266
|
+
optimizer = torch.optim.Adam(
|
|
267
|
+
intervenable.get_trainable_parameters(),
|
|
268
|
+
lr=1e-4
|
|
269
|
+
)
|
|
270
|
+
|
|
271
|
+
# 3. Training loop (simplified)
|
|
272
|
+
for base_input, source_input, target_output in dataloader:
|
|
273
|
+
optimizer.zero_grad()
|
|
274
|
+
|
|
275
|
+
_, outputs = intervenable(
|
|
276
|
+
base=base_input,
|
|
277
|
+
sources=[source_input],
|
|
278
|
+
)
|
|
279
|
+
|
|
280
|
+
loss = criterion(outputs.logits, target_output)
|
|
281
|
+
loss.backward()
|
|
282
|
+
optimizer.step()
|
|
283
|
+
|
|
284
|
+
# 4. Analyze learned intervention
|
|
285
|
+
# The rotation matrix reveals causal subspace
|
|
286
|
+
rotation = intervenable.interventions["layer.6.block_output"][0].rotate_layer
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
### DAS (Distributed Alignment Search)
|
|
290
|
+
|
|
291
|
+
```python
|
|
292
|
+
# Low-rank rotation finds interpretable subspaces
|
|
293
|
+
config = pv.IntervenableConfig(
|
|
294
|
+
representations=[
|
|
295
|
+
pv.RepresentationConfig(
|
|
296
|
+
layer=8,
|
|
297
|
+
component="block_output",
|
|
298
|
+
intervention_type=pv.LowRankRotatedSpaceIntervention,
|
|
299
|
+
low_rank_dimension=1, # Find 1D causal direction
|
|
300
|
+
)
|
|
301
|
+
]
|
|
302
|
+
)
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
## Workflow 4: Model Steering (Honest LLaMA)
|
|
306
|
+
|
|
307
|
+
Steer model behavior during generation.
|
|
308
|
+
|
|
309
|
+
```python
|
|
310
|
+
import pyvene as pv
|
|
311
|
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
|
312
|
+
|
|
313
|
+
model = AutoModelForCausalLM.from_pretrained("meta-llama/Llama-2-7b-hf")
|
|
314
|
+
tokenizer = AutoTokenizer.from_pretrained("meta-llama/Llama-2-7b-hf")
|
|
315
|
+
|
|
316
|
+
# Load pre-trained steering intervention
|
|
317
|
+
intervenable = pv.IntervenableModel.load(
|
|
318
|
+
"zhengxuanzenwu/intervenable_honest_llama2_chat_7B",
|
|
319
|
+
model=model,
|
|
320
|
+
)
|
|
321
|
+
|
|
322
|
+
# Generate with steering
|
|
323
|
+
prompt = "Is the earth flat?"
|
|
324
|
+
inputs = tokenizer(prompt, return_tensors="pt")
|
|
325
|
+
|
|
326
|
+
# Intervention applied during generation
|
|
327
|
+
outputs = intervenable.generate(
|
|
328
|
+
inputs,
|
|
329
|
+
max_new_tokens=100,
|
|
330
|
+
do_sample=False,
|
|
331
|
+
)
|
|
332
|
+
|
|
333
|
+
print(tokenizer.decode(outputs[0]))
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
## Saving and Sharing Interventions
|
|
337
|
+
|
|
338
|
+
```python
|
|
339
|
+
# Save locally
|
|
340
|
+
intervenable.save("./my_intervention")
|
|
341
|
+
|
|
342
|
+
# Load from local
|
|
343
|
+
intervenable = pv.IntervenableModel.load(
|
|
344
|
+
"./my_intervention",
|
|
345
|
+
model=model,
|
|
346
|
+
)
|
|
347
|
+
|
|
348
|
+
# Share on HuggingFace
|
|
349
|
+
intervenable.save_intervention("username/my-intervention")
|
|
350
|
+
|
|
351
|
+
# Load from HuggingFace
|
|
352
|
+
intervenable = pv.IntervenableModel.load(
|
|
353
|
+
"username/my-intervention",
|
|
354
|
+
model=model,
|
|
355
|
+
)
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
## Common Issues & Solutions
|
|
359
|
+
|
|
360
|
+
### Issue: Wrong intervention location
|
|
361
|
+
```python
|
|
362
|
+
# WRONG: Incorrect component name
|
|
363
|
+
config = pv.RepresentationConfig(
|
|
364
|
+
component="mlp", # Not valid!
|
|
365
|
+
)
|
|
366
|
+
|
|
367
|
+
# RIGHT: Use exact component name
|
|
368
|
+
config = pv.RepresentationConfig(
|
|
369
|
+
component="mlp_output", # Valid
|
|
370
|
+
)
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
### Issue: Dimension mismatch
|
|
374
|
+
```python
|
|
375
|
+
# Ensure source and base have compatible shapes
|
|
376
|
+
# For position-specific interventions:
|
|
377
|
+
config = pv.RepresentationConfig(
|
|
378
|
+
unit="pos",
|
|
379
|
+
max_number_of_units=1, # Intervene on single position
|
|
380
|
+
)
|
|
381
|
+
|
|
382
|
+
# Specify locations explicitly
|
|
383
|
+
intervenable(
|
|
384
|
+
base=base_tokens,
|
|
385
|
+
sources=[source_tokens],
|
|
386
|
+
unit_locations={"sources->base": ([[[5]]], [[[5]]])}, # Position 5
|
|
387
|
+
)
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
### Issue: Memory with large models
|
|
391
|
+
```python
|
|
392
|
+
# Use gradient checkpointing
|
|
393
|
+
model.gradient_checkpointing_enable()
|
|
394
|
+
|
|
395
|
+
# Or intervene on fewer components
|
|
396
|
+
config = pv.IntervenableConfig(
|
|
397
|
+
representations=[
|
|
398
|
+
pv.RepresentationConfig(
|
|
399
|
+
layer=8, # Single layer instead of all
|
|
400
|
+
component="block_output",
|
|
401
|
+
)
|
|
402
|
+
]
|
|
403
|
+
)
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
### Issue: LoRA integration
|
|
407
|
+
```python
|
|
408
|
+
# pyvene v0.1.8+ supports LoRAs as interventions
|
|
409
|
+
config = pv.RepresentationConfig(
|
|
410
|
+
intervention_type=pv.LoRAIntervention,
|
|
411
|
+
low_rank_dimension=16,
|
|
412
|
+
)
|
|
413
|
+
```
|
|
414
|
+
|
|
415
|
+
## Key Classes Reference
|
|
416
|
+
|
|
417
|
+
| Class | Purpose |
|
|
418
|
+
|-------|---------|
|
|
419
|
+
| `IntervenableModel` | Main wrapper for interventions |
|
|
420
|
+
| `IntervenableConfig` | Configuration container |
|
|
421
|
+
| `RepresentationConfig` | Single intervention specification |
|
|
422
|
+
| `VanillaIntervention` | Activation swapping |
|
|
423
|
+
| `RotatedSpaceIntervention` | Trainable DAS intervention |
|
|
424
|
+
| `CollectIntervention` | Activation collection |
|
|
425
|
+
|
|
426
|
+
## Supported Models
|
|
427
|
+
|
|
428
|
+
pyvene works with any PyTorch model. Tested on:
|
|
429
|
+
- GPT-2 (all sizes)
|
|
430
|
+
- LLaMA / LLaMA-2
|
|
431
|
+
- Pythia
|
|
432
|
+
- Mistral / Mixtral
|
|
433
|
+
- OPT
|
|
434
|
+
- BLIP (vision-language)
|
|
435
|
+
- ESM (protein models)
|
|
436
|
+
- Mamba (state space)
|
|
437
|
+
|
|
438
|
+
## Reference Documentation
|
|
439
|
+
|
|
440
|
+
For detailed API documentation, tutorials, and advanced usage, see the `references/` folder:
|
|
441
|
+
|
|
442
|
+
| File | Contents |
|
|
443
|
+
|------|----------|
|
|
444
|
+
| [references/README.md](references/README.md) | Overview and quick start guide |
|
|
445
|
+
| [references/api.md](references/api.md) | Complete API reference for IntervenableModel, intervention types, configurations |
|
|
446
|
+
| [references/tutorials.md](references/tutorials.md) | Step-by-step tutorials for causal tracing, activation patching, DAS |
|
|
447
|
+
|
|
448
|
+
## External Resources
|
|
449
|
+
|
|
450
|
+
### Tutorials
|
|
451
|
+
- [pyvene 101](https://stanfordnlp.github.io/pyvene/tutorials/pyvene_101.html)
|
|
452
|
+
- [Causal Tracing Tutorial](https://stanfordnlp.github.io/pyvene/tutorials/advanced_tutorials/Causal_Tracing.html)
|
|
453
|
+
- [IOI Circuit Replication](https://stanfordnlp.github.io/pyvene/tutorials/advanced_tutorials/IOI_Replication.html)
|
|
454
|
+
- [DAS Introduction](https://stanfordnlp.github.io/pyvene/tutorials/advanced_tutorials/DAS_Main_Introduction.html)
|
|
455
|
+
|
|
456
|
+
### Papers
|
|
457
|
+
- [Locating and Editing Factual Associations in GPT](https://arxiv.org/abs/2202.05262) - Meng et al. (2022)
|
|
458
|
+
- [Inference-Time Intervention](https://arxiv.org/abs/2306.03341) - Li et al. (2023)
|
|
459
|
+
- [Interpretability in the Wild](https://arxiv.org/abs/2211.00593) - Wang et al. (2022)
|
|
460
|
+
|
|
461
|
+
### Official Documentation
|
|
462
|
+
- [Official Docs](https://stanfordnlp.github.io/pyvene/)
|
|
463
|
+
- [API Reference](https://stanfordnlp.github.io/pyvene/api/)
|
|
464
|
+
|
|
465
|
+
## Comparison with Other Tools
|
|
466
|
+
|
|
467
|
+
| Feature | pyvene | TransformerLens | nnsight |
|
|
468
|
+
|---------|--------|-----------------|---------|
|
|
469
|
+
| Declarative config | Yes | No | No |
|
|
470
|
+
| HuggingFace sharing | Yes | No | No |
|
|
471
|
+
| Trainable interventions | Yes | Limited | Yes |
|
|
472
|
+
| Any PyTorch model | Yes | Transformers only | Yes |
|
|
473
|
+
| Remote execution | No | No | Yes (NDIF) |
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# pyvene Reference Documentation
|
|
2
|
+
|
|
3
|
+
This directory contains comprehensive reference materials for pyvene.
|
|
4
|
+
|
|
5
|
+
## Contents
|
|
6
|
+
|
|
7
|
+
- [api.md](api.md) - Complete API reference for IntervenableModel, intervention types, and configurations
|
|
8
|
+
- [tutorials.md](tutorials.md) - Step-by-step tutorials for causal tracing, activation patching, and trainable interventions
|
|
9
|
+
|
|
10
|
+
## Quick Links
|
|
11
|
+
|
|
12
|
+
- **Official Documentation**: https://stanfordnlp.github.io/pyvene/
|
|
13
|
+
- **GitHub Repository**: https://github.com/stanfordnlp/pyvene
|
|
14
|
+
- **Paper**: https://arxiv.org/abs/2403.07809 (NAACL 2024)
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
pip install pyvene
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Basic Usage
|
|
23
|
+
|
|
24
|
+
```python
|
|
25
|
+
import pyvene as pv
|
|
26
|
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
|
27
|
+
|
|
28
|
+
# Load model
|
|
29
|
+
model = AutoModelForCausalLM.from_pretrained("gpt2")
|
|
30
|
+
tokenizer = AutoTokenizer.from_pretrained("gpt2")
|
|
31
|
+
|
|
32
|
+
# Define intervention
|
|
33
|
+
config = pv.IntervenableConfig(
|
|
34
|
+
representations=[
|
|
35
|
+
pv.RepresentationConfig(
|
|
36
|
+
layer=5,
|
|
37
|
+
component="block_output",
|
|
38
|
+
intervention_type=pv.VanillaIntervention,
|
|
39
|
+
)
|
|
40
|
+
]
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
# Create intervenable model
|
|
44
|
+
intervenable = pv.IntervenableModel(config, model)
|
|
45
|
+
|
|
46
|
+
# Run intervention (swap activations from source to base)
|
|
47
|
+
base_inputs = tokenizer("The cat sat on the", return_tensors="pt")
|
|
48
|
+
source_inputs = tokenizer("The dog ran through the", return_tensors="pt")
|
|
49
|
+
|
|
50
|
+
_, outputs = intervenable(
|
|
51
|
+
base=base_inputs,
|
|
52
|
+
sources=[source_inputs],
|
|
53
|
+
)
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Key Concepts
|
|
57
|
+
|
|
58
|
+
### Intervention Types
|
|
59
|
+
- **VanillaIntervention**: Swap activations between runs
|
|
60
|
+
- **AdditionIntervention**: Add source to base activations
|
|
61
|
+
- **ZeroIntervention**: Zero out activations (ablation)
|
|
62
|
+
- **CollectIntervention**: Collect activations without modifying
|
|
63
|
+
- **RotatedSpaceIntervention**: Trainable intervention for causal discovery
|
|
64
|
+
|
|
65
|
+
### Components
|
|
66
|
+
Target specific parts of the model:
|
|
67
|
+
- `block_input`, `block_output`
|
|
68
|
+
- `mlp_input`, `mlp_output`, `mlp_activation`
|
|
69
|
+
- `attention_input`, `attention_output`
|
|
70
|
+
- `query_output`, `key_output`, `value_output`
|
|
71
|
+
|
|
72
|
+
### HuggingFace Integration
|
|
73
|
+
Save and load interventions via HuggingFace Hub for reproducibility.
|