[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7CBZY98ZRWJXZKWS5MD0R3A":3,"skill-same:01M7CBZY98ZRWJXZKWS5MD0R3A":61},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":33,"commitSha":34,"skillDirectory":35,"forksCount":36,"repositoryHtmlUrl":37,"repositoryHomepageUrl":6,"ownerHtmlUrl":38,"ownerBlogUrl":6,"ownerDescription":39,"updatedAt":40,"install":41,"resources":54},"01M7CBZY98ZRWJXZKWS5MD0R3A","fine-tuning-expert",null,"Use when fine-tuning LLMs, training custom models, or adapting foundation models for specific tasks. Invoke for configuring LoRA\u002FQLoRA adapters, preparing JSONL training datasets, setting hyperparameters for fine-tuning runs, adapter training, transfer learning, finetuning with Hugging Face PEFT, OpenAI fine-tuning, instruction tuning, RLHF, DPO, or quantizing and deploying fine-tuned models. Trigger terms include: LoRA, QLoRA, PEFT, finetuning, fine-tuning, adapter tuning, LLM training, model training, custom model.","om-scogo\u002Fskillsh-scraper","om-scogo","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F160466840?v=4","01M79AWB6DFVCQ7RK70CS34B96","Om Achrekar","01M79AWB6ZM9SKR8KDH1WSSM22",0,"MIT","https:\u002F\u002Fgithub.com\u002Fom-scogo\u002Fskillsh-scraper\u002Fblob\u002Fmain\u002Fdata\u002Fskills\u002Fjeffallan-claude-skills\u002Ffine-tuning-expert\u002FSkill.md",[],[],"2026-11-15 14:19:17",false,"---\nname: fine-tuning-expert\ndescription: \"Use when fine-tuning LLMs, training custom models, or adapting foundation models for specific tasks. Invoke for configuring LoRA\u002FQLoRA adapters, preparing JSONL training datasets, setting hyperparameters for fine-tuning runs, adapter training, transfer learning, finetuning with Hugging Face PEFT, OpenAI fine-tuning, instruction tuning, RLHF, DPO, or quantizing and deploying fine-tuned models. Trigger terms include: LoRA, QLoRA, PEFT, finetuning, fine-tuning, adapter tuning, LLM training, model training, custom model.\"\nlicense: MIT\nmetadata:\n  author: https:\u002F\u002Fgithub.com\u002FJeffallan\n  version: \"1.1.0\"\n  domain: data-ml\n  triggers: fine-tuning, fine tuning, finetuning, LoRA, QLoRA, PEFT, adapter tuning, transfer learning, model training, custom model, LLM training, instruction tuning, RLHF, model optimization, quantization\n  role: expert\n  scope: implementation\n  output-format: code\n  related-skills: devops-engineer\n---\n\n# Fine-Tuning Expert\n\nSenior ML engineer specializing in LLM fine-tuning, parameter-efficient methods, and production model optimization.\n\n## Core Workflow\n\n1. **Dataset preparation** — Validate and format data; run quality checks before training starts\n   - Checkpoint: `python validate_dataset.py --input data.jsonl` — fix all errors before proceeding\n2. **Method selection** — Choose PEFT technique based on GPU memory and task requirements\n   - Use LoRA for most tasks; QLoRA (4-bit) when GPU memory is constrained; full fine-tune only for small models\n3. **Training** — Configure hyperparameters, monitor loss curves, checkpoint regularly\n   - Checkpoint: validation loss must decrease; plateau or increase signals overfitting\n4. **Evaluation** — Benchmark against the base model; test on held-out set and edge cases\n   - Checkpoint: collect perplexity, task-specific metrics (BLEU\u002FROUGE), and latency numbers\n5. **Deployment** — Merge adapter weights, quantize, measure inference throughput before serving\n\n## Reference Guide\n\nLoad detailed guidance based on context:\n\n| Topic | Reference | Load When |\n|-------|-----------|-----------|\n| LoRA\u002FPEFT | `references\u002Flora-peft.md` | Parameter-efficient fine-tuning, adapters |\n| Dataset Prep | `references\u002Fdataset-preparation.md` | Training data formatting, quality checks |\n| Hyperparameters | `references\u002Fhyperparameter-tuning.md` | Learning rates, batch sizes, schedulers |\n| Evaluation | `references\u002Fevaluation-metrics.md` | Benchmarking, metrics, model comparison |\n| Deployment | `references\u002Fdeployment-optimization.md` | Model merging, quantization, serving |\n\n## Minimal Working Example — LoRA Fine-Tuning with Hugging Face PEFT\n\n```python\nfrom datasets import load_dataset\nfrom transformers import AutoTokenizer, AutoModelForCausalLM, TrainingArguments\nfrom peft import LoraConfig, get_peft_model, TaskType\nfrom trl import SFTTrainer\nimport torch\n\n# 1. Load base model and tokenizer\nmodel_id = \"meta-llama\u002FLlama-3-8B\"\ntokenizer = AutoTokenizer.from_pretrained(model_id)\ntokenizer.pad_token = tokenizer.eos_token\n\nmodel = AutoModelForCausalLM.from_pretrained(\n    model_id,\n    torch_dtype=torch.bfloat16,\n    device_map=\"auto\",\n)\n\n# 2. Configure LoRA adapter\nlora_config = LoraConfig(\n    task_type=TaskType.CAUSAL_LM,\n    r=16,               # rank — increase for more capacity, decrease to save memory\n    lora_alpha=32,      # scaling factor; typically 2× rank\n    target_modules=[\"q_proj\", \"v_proj\"],\n    lora_dropout=0.05,\n    bias=\"none\",\n)\nmodel = get_peft_model(model, lora_config)\nmodel.print_trainable_parameters()  # verify: should be ~0.1–1% of total params\n\n# 3. Load and format dataset (Alpaca-style JSONL)\ndataset = load_dataset(\"json\", data_files={\"train\": \"train.jsonl\", \"test\": \"test.jsonl\"})\n\ndef format_prompt(example):\n    return {\"text\": f\"### Instruction:\\n{example['instruction']}\\n\\n### Response:\\n{example['output']}\"}\n\ndataset = dataset.map(format_prompt)\n\n# 4. Training arguments\ntraining_args = TrainingArguments(\n    output_dir=\".\u002Fcheckpoints\",\n    num_train_epochs=3,\n    per_device_train_batch_size=4,\n    gradient_accumulation_steps=4,     # effective batch size = 16\n    learning_rate=2e-4,\n    lr_scheduler_type=\"cosine\",\n    warmup_ratio=0.03,                 # always use warmup\n    fp16=False,\n    bf16=True,\n    logging_steps=10,\n    eval_strategy=\"steps\",\n    eval_steps=100,\n    save_steps=200,\n    load_best_model_at_end=True,\n)\n\n# 5. Train\ntrainer = SFTTrainer(\n    model=model,\n    args=training_args,\n    train_dataset=dataset[\"train\"],\n    eval_dataset=dataset[\"test\"],\n    dataset_text_field=\"text\",\n    max_seq_length=2048,\n)\ntrainer.train()\n\n# 6. Save adapter weights only\nmodel.save_pretrained(\".\u002Flora-adapter\")\ntokenizer.save_pretrained(\".\u002Flora-adapter\")\n```\n\n**QLoRA variant** — add these lines before loading the model to enable 4-bit quantization:\n```python\nfrom transformers import BitsAndBytesConfig\n\nbnb_config = BitsAndBytesConfig(\n    load_in_4bit=True,\n    bnb_4bit_quant_type=\"nf4\",\n    bnb_4bit_compute_dtype=torch.bfloat16,\n    bnb_4bit_use_double_quant=True,\n)\nmodel = AutoModelForCausalLM.from_pretrained(model_id, quantization_config=bnb_config, device_map=\"auto\")\n```\n\n**Merge adapter into base model for deployment:**\n```python\nfrom peft import PeftModel\n\nbase = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.bfloat16)\nmerged = PeftModel.from_pretrained(base, \".\u002Flora-adapter\").merge_and_unload()\nmerged.save_pretrained(\".\u002Fmerged-model\")\n```\n\n## Constraints\n\n### MUST DO\n- Validate dataset quality before training\n- Use parameter-efficient methods for large models (>7B)\n- Monitor training\u002Fvalidation loss curves\n- Document hyperparameters and training config\n- Version datasets and model checkpoints\n- Always include a learning rate warmup\n\n### MUST NOT DO\n- Skip data quality validation\n- Overfit on small datasets — use regularisation (dropout, weight decay) and early stopping\n- Merge incompatible adapters (mismatched rank, base model, or target modules)\n- Deploy without evaluation against a held-out set and latency benchmark\n\n## Output Templates\n\nWhen implementing fine-tuning, always provide:\n1. **Dataset preparation script** with validation logic (schema checks, token-length histogram, deduplication)\n2. **Training configuration** (full `TrainingArguments` + `LoraConfig` block, commented)\n3. **Evaluation script** reporting perplexity, task-specific metrics, and latency\n4. **Brief design rationale** — why this PEFT method, rank, and learning rate were chosen for this task\n\n[Documentation](https:\u002F\u002Fjeffallan.github.io\u002Fclaude-skills\u002Fskills\u002Fdata-ml\u002Ffine-tuning-expert\u002F)\n","# Fine-Tuning Expert\n\nSenior ML engineer specializing in LLM fine-tuning, parameter-efficient methods, and production model optimization.\n\n## Core Workflow\n\n1. **Dataset preparation** — Validate and format data; run quality checks before training starts\n   - Checkpoint: `python validate_dataset.py --input data.jsonl` — fix all errors before proceeding\n2. **Method selection** — Choose PEFT technique based on GPU memory and task requirements\n   - Use LoRA for most tasks; QLoRA (4-bit) when GPU memory is constrained; full fine-tune only for small models\n3. **Training** — Configure hyperparameters, monitor loss curves, checkpoint regularly\n   - Checkpoint: validation loss must decrease; plateau or increase signals overfitting\n4. **Evaluation** — Benchmark against the base model; test on held-out set and edge cases\n   - Checkpoint: collect perplexity, task-specific metrics (BLEU\u002FROUGE), and latency numbers\n5. **Deployment** — Merge adapter weights, quantize, measure inference throughput before serving\n\n## Reference Guide\n\nLoad detailed guidance based on context:\n\n| Topic | Reference | Load When |\n|-------|-----------|-----------|\n| LoRA\u002FPEFT | `references\u002Flora-peft.md` | Parameter-efficient fine-tuning, adapters |\n| Dataset Prep | `references\u002Fdataset-preparation.md` | Training data formatting, quality checks |\n| Hyperparameters | `references\u002Fhyperparameter-tuning.md` | Learning rates, batch sizes, schedulers |\n| Evaluation | `references\u002Fevaluation-metrics.md` | Benchmarking, metrics, model comparison |\n| Deployment | `references\u002Fdeployment-optimization.md` | Model merging, quantization, serving |\n\n## Minimal Working Example — LoRA Fine-Tuning with Hugging Face PEFT\n\n```python\nfrom datasets import load_dataset\nfrom transformers import AutoTokenizer, AutoModelForCausalLM, TrainingArguments\nfrom peft import LoraConfig, get_peft_model, TaskType\nfrom trl import SFTTrainer\nimport torch\n\n# 1. Load base model and tokenizer\nmodel_id = \"meta-llama\u002FLlama-3-8B\"\ntokenizer = AutoTokenizer.from_pretrained(model_id)\ntokenizer.pad_token = tokenizer.eos_token\n\nmodel = AutoModelForCausalLM.from_pretrained(\n    model_id,\n    torch_dtype=torch.bfloat16,\n    device_map=\"auto\",\n)\n\n# 2. Configure LoRA adapter\nlora_config = LoraConfig(\n    task_type=TaskType.CAUSAL_LM,\n    r=16,               # rank — increase for more capacity, decrease to save memory\n    lora_alpha=32,      # scaling factor; typically 2× rank\n    target_modules=[\"q_proj\", \"v_proj\"],\n    lora_dropout=0.05,\n    bias=\"none\",\n)\nmodel = get_peft_model(model, lora_config)\nmodel.print_trainable_parameters()  # verify: should be ~0.1–1% of total params\n\n# 3. Load and format dataset (Alpaca-style JSONL)\ndataset = load_dataset(\"json\", data_files={\"train\": \"train.jsonl\", \"test\": \"test.jsonl\"})\n\ndef format_prompt(example):\n    return {\"text\": f\"### Instruction:\\n{example['instruction']}\\n\\n### Response:\\n{example['output']}\"}\n\ndataset = dataset.map(format_prompt)\n\n# 4. Training arguments\ntraining_args = TrainingArguments(\n    output_dir=\".\u002Fcheckpoints\",\n    num_train_epochs=3,\n    per_device_train_batch_size=4,\n    gradient_accumulation_steps=4,     # effective batch size = 16\n    learning_rate=2e-4,\n    lr_scheduler_type=\"cosine\",\n    warmup_ratio=0.03,                 # always use warmup\n    fp16=False,\n    bf16=True,\n    logging_steps=10,\n    eval_strategy=\"steps\",\n    eval_steps=100,\n    save_steps=200,\n    load_best_model_at_end=True,\n)\n\n# 5. Train\ntrainer = SFTTrainer(\n    model=model,\n    args=training_args,\n    train_dataset=dataset[\"train\"],\n    eval_dataset=dataset[\"test\"],\n    dataset_text_field=\"text\",\n    max_seq_length=2048,\n)\ntrainer.train()\n\n# 6. Save adapter weights only\nmodel.save_pretrained(\".\u002Flora-adapter\")\ntokenizer.save_pretrained(\".\u002Flora-adapter\")\n```\n\n**QLoRA variant** — add these lines before loading the model to enable 4-bit quantization:\n```python\nfrom transformers import BitsAndBytesConfig\n\nbnb_config = BitsAndBytesConfig(\n    load_in_4bit=True,\n    bnb_4bit_quant_type=\"nf4\",\n    bnb_4bit_compute_dtype=torch.bfloat16,\n    bnb_4bit_use_double_quant=True,\n)\nmodel = AutoModelForCausalLM.from_pretrained(model_id, quantization_config=bnb_config, device_map=\"auto\")\n```\n\n**Merge adapter into base model for deployment:**\n```python\nfrom peft import PeftModel\n\nbase = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.bfloat16)\nmerged = PeftModel.from_pretrained(base, \".\u002Flora-adapter\").merge_and_unload()\nmerged.save_pretrained(\".\u002Fmerged-model\")\n```\n\n## Constraints\n\n### MUST DO\n- Validate dataset quality before training\n- Use parameter-efficient methods for large models (>7B)\n- Monitor training\u002Fvalidation loss curves\n- Document hyperparameters and training config\n- Version datasets and model checkpoints\n- Always include a learning rate warmup\n\n### MUST NOT DO\n- Skip data quality validation\n- Overfit on small datasets — use regularisation (dropout, weight decay) and early stopping\n- Merge incompatible adapters (mismatched rank, base model, or target modules)\n- Deploy without evaluation against a held-out set and latency benchmark\n\n## Output Templates\n\nWhen implementing fine-tuning, always provide:\n1. **Dataset preparation script** with validation logic (schema checks, token-length histogram, deduplication)\n2. **Training configuration** (full `TrainingArguments` + `LoraConfig` block, commented)\n3. **Evaluation script** reporting perplexity, task-specific metrics, and latency\n4. **Brief design rationale** — why this PEFT method, rank, and learning rate were chosen for this task\n\n[Documentation](https:\u002F\u002Fjeffallan.github.io\u002Fclaude-skills\u002Fskills\u002Fdata-ml\u002Ffine-tuning-expert\u002F)\n",{"name":5,"license":15,"metadata":24,"description":7},{"role":25,"scope":26,"author":27,"domain":28,"version":29,"triggers":30,"output-format":31,"related-skills":32},"expert","implementation","https:\u002F\u002Fgithub.com\u002FJeffallan","data-ml","1.1.0","fine-tuning, fine tuning, finetuning, LoRA, QLoRA, PEFT, adapter tuning, transfer learning, model training, custom model, LLM training, instruction tuning, RLHF, model optimization, quantization","code","devops-engineer","main","8859218955d9504cd18b59e7892100718039d3b4","data\u002Fskills\u002Fjeffallan-claude-skills\u002Ffine-tuning-expert",1,"https:\u002F\u002Fgithub.com\u002Fom-scogo\u002Fskillsh-scraper","https:\u002F\u002Fgithub.com\u002Fom-scogo","SDE-1 @ Scogo ","2026-07-18 12:22:46",{"source":8,"skillName":5,"commands":42,"prompt":52,"zipAvailable":53},[43,46,49],{"tool":44,"command":45},"npx","npx skills add om-scogo\u002Fskillsh-scraper --skill fine-tuning-expert",{"tool":47,"command":48},"bunx","bunx skills add om-scogo\u002Fskillsh-scraper --skill fine-tuning-expert",{"tool":50,"command":51},"pnpm","pnpm dlx skills add om-scogo\u002Fskillsh-scraper --skill fine-tuning-expert","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fom-scogo\u002Fskillsh-scraper\u002Fblob\u002Fmain\u002Fdata\u002Fskills\u002Fjeffallan-claude-skills\u002Ffine-tuning-expert\u002FSkill.md",true,[55],{"path":56,"resourceType":57,"resourceTypeDesc":58,"sizeBytes":59,"sourceHtmlUrl":60},"metadata.json","REFERENCE","参考文档",472,"https:\u002F\u002Fgithub.com\u002Fom-scogo\u002Fskillsh-scraper\u002Fblob\u002Fmain\u002Fdata\u002Fskills\u002Fjeffallan-claude-skills\u002Ffine-tuning-expert\u002Fmetadata.json",[62,69,74,81,86,93],{"skillNo":63,"name":64,"nameZh":6,"description":65,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":66,"categories":67,"keywords":68,"publishedAt":19},"01M7D6MC9FAAEV4CMNYX8W7JTG","arxiv-search","Search arXiv physics, math, and computer science preprints using natural language queries. Powered by Valyu semantic search.","https:\u002F\u002Fgithub.com\u002Fom-scogo\u002Fskillsh-scraper\u002Fblob\u002Fmain\u002Fdata\u002Fskills\u002Fyorkeccak-scientific-skills\u002Farxiv-search\u002Fskills\u002Farxiv-search\u002FSKILL.md",[],[],{"skillNo":70,"name":64,"nameZh":6,"description":65,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":71,"categories":72,"keywords":73,"publishedAt":19},"01M7D6M85CKKN87TA98VCQV4H7","https:\u002F\u002Fgithub.com\u002Fom-scogo\u002Fskillsh-scraper\u002Fblob\u002Fmain\u002Fdata\u002Fskills\u002Fyorkeccak-scientific-skills\u002Farxiv-search\u002FSkill.md",[],[],{"skillNo":75,"name":76,"nameZh":6,"description":77,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":78,"categories":79,"keywords":80,"publishedAt":19},"01M7D4ZTCS4DR3CE4JY06X84T2","working-with-legacy-code","Safely change and test untested codebases using Feathers' \"Working Effectively with Legacy Code\". Use when the user mentions \"legacy code\", \"no tests\", \"untested codebase\", \"how do I test this\", \"seams\", \"characterization tests\", \"golden master\", \"sprout method\", \"afraid to change this code\", \"monster method\", \"dependency breaking\", or \"inherited a messy codebase\". Also trigger when changing code without tests safely, getting a class under test when constructors, statics, or singletons block it, adding features to tangled modules, or planning incremental test coverage for an old codebase. Covers the legacy-code change algorithm, seams, characterization tests, sprout\u002Fwrap, and dependency-breaking techniques. For refactoring code that already has tests, see refactoring-patterns. For day-to-day code quality, see clean-code.","https:\u002F\u002Fgithub.com\u002Fom-scogo\u002Fskillsh-scraper\u002Fblob\u002Fmain\u002Fdata\u002Fskills\u002Fwondelai-skills\u002Fworking-with-legacy-code\u002Fworking-with-legacy-code\u002FSKILL.md",[],[],{"skillNo":82,"name":76,"nameZh":6,"description":77,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":83,"categories":84,"keywords":85,"publishedAt":19},"01M7D4ZHZKJD2RSNGAF63V14P4","https:\u002F\u002Fgithub.com\u002Fom-scogo\u002Fskillsh-scraper\u002Fblob\u002Fmain\u002Fdata\u002Fskills\u002Fwondelai-skills\u002Fworking-with-legacy-code\u002FSkill.md",[],[],{"skillNo":87,"name":88,"nameZh":6,"description":89,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":90,"categories":91,"keywords":92,"publishedAt":19},"01M7D4ZB4CJBFW5JE67CPH2QRV","web-typography","Select, pair, and implement typefaces for web projects. Use when the user mentions \"font pairing\", \"which typeface\", \"line height\", \"responsive typography\", \"web font loading\", \"type hierarchy\", \"variable fonts\", \"FOUT\u002FFOIT\", \"typographic scale\", or \"the text is hard to read\". Also trigger when choosing between system fonts and web fonts, optimizing font-loading performance, or designing readable long-form content. Covers readability evaluation, CSS implementation, and performance optimization. For overall UI design systems, see refactoring-ui. For dramatic typographic experiences, see top-design.","https:\u002F\u002Fgithub.com\u002Fom-scogo\u002Fskillsh-scraper\u002Fblob\u002Fmain\u002Fdata\u002Fskills\u002Fwondelai-skills\u002Fweb-typography\u002Fweb-typography\u002FSKILL.md",[],[],{"skillNo":94,"name":88,"nameZh":6,"description":89,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":95,"categories":96,"keywords":97,"publishedAt":19},"01M7D4Z4MVYVY3NMJ18BNV6WNA","https:\u002F\u002Fgithub.com\u002Fom-scogo\u002Fskillsh-scraper\u002Fblob\u002Fmain\u002Fdata\u002Fskills\u002Fwondelai-skills\u002Fweb-typography\u002FSkill.md",[],[]]