技能创建器
skill-creator
创建、改进和评估自定义技能,把专业流程转化为可重复使用的 AI 能力。
fine-tuning【数据与研究】Supervised fine-tuning of LLaMA/OPT-style causal LMs with Alpaca data using Hugging Face Trainer, FSDP, and optional DeepSpeed offload.
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
Use this sub-skill when a task is about supervised fine-tuning an Alpaca-style causal language model with the Stanford Alpaca training flow: Hugging Face AutoModelForCausalLM, AutoTokenizer, Trainer, tokenizer special-token resizing, source-token label masking, FSDP recipes, or optional DeepSpeed ZeRO-3 CPU offload.
Do not use this sub-skill as the owner for data schema, prompt wording, OpenAI instruction generation, or weight-diff recovery. Route those parts to sibling sub-skills by id:
dataset-and-prompts: Alpaca JSON schema, prompt text, prompt/schema validation, and training-data quality checks.instruction-generation: OpenAI/Self-Instruct style instruction generation.weight-diff-recovery: recovering Alpaca weights from released weight diffs.This sub-skill is grounded in the repository's fine-tuning and OOM README sections, train.py, configs/default_offload_opt_param.json, and the prepared environment report signatures. Verified facts include:
train.py uses transformers.HfArgumentParser((ModelArguments, DataArguments, TrainingArguments)).--model_name_or_path, --data_path, --output_dir, --fsdp, --fsdp_transformer_layer_cls_to_wrap, --deepspeed, --model_max_length, --bf16, --tf32, and standard Hugging Face TrainingArguments fields.preprocess(sources, targets, tokenizer) concatenates prompt sources and targets, then masks source-token labels with IGNORE_INDEX = -100.references/api-reference.md.torchrun recipes, read references/workflows.md.references/configuration.md.references/troubleshooting.md.scripts/build_training_command.py. It prints command text and never launches training.scripts/train_alpaca_sft.py instead of depending on the original repository checkout.scripts/default_offload_opt_param.json config.dataset-and-prompts handoff: the training data_path must already point to a validated Alpaca-style JSON dataset. This sub-skill can explain how the trainer consumes that dataset, but not the full schema or prompt text.--fsdp "full_shard auto_wrap" and --fsdp_transformer_layer_cls_to_wrap LlamaDecoderLayer.OPTDecoderLayer for --fsdp_transformer_layer_cls_to_wrap.--fsdp "full_shard auto_wrap offload"; if that is still unsuitable, use the DeepSpeed ZeRO-3 offload recipe and bundled JSON config.2e-5, 3 epochs, max length 512, weight decay 0.1e-5, 5 epochs, max length 512, weight decay 0.per_device_train_batch_size=4, and gradient_accumulation_steps=8: 4 GPUs * 4 micro-batch * 8 accumulation = 128.TrainingArguments.model_max_length defaults to 512; tokenization right-pads and truncates to that length.pad, eos, bos, or unk tokenizer tokens are added before training and the model embeddings are resized.Full LLaMA/OPT training is expensive and GPU-dependent. A CPU-side check can validate imports, argument parsing, data loading, tokenization, command construction, and help surfaces, but it is not proof that a multi-GPU FSDP or DeepSpeed job will fit or converge. Treat GPU recipes as documented launch templates unless final verification explicitly runs them on suitable hardware.