ai-llm
This skill guides supervised fine-tuning and parameter-efficient adaptation of language models through LoRA, QLoRA, full fine-tuning, distillation, and…
Community author
- Agents
- Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode
- License
- MIT (permissive)
- Pin
- 1238832pinned Oct 9, 2026
- Context cost
- about 2,800 tokenswhen the skill loads
- GitHub stars
- 92on vasilyu1983/ai-agents-public
- Scripts
- None found
What it does
“Adapts LLMs: SFT dataset loss masking, LoRA and QLoRA, full FT vs PEFT, distillation, pruning, tokenizer fragmentation. Use when fine-tuning or compressing a model.”
Generated summary from the skill's own text
This skill guides supervised fine-tuning and parameter-efficient adaptation of language models through LoRA, QLoRA, full fine-tuning, distillation, and dataset preparation. It covers configuration decisions, tokenizer diagnostics, loss masking, packing strategies, and ROI analysis to determine whether adaptation is worth the cost. Use this skill after you have decided that fine-tuning or distillation is the right approach for your task.
When to use it
- Configuring LoRA or QLoRA rank, alpha, target modules, and learning rates
- Choosing between full fine-tuning and PEFT or escalating when LoRA plateaus
- Building an SFT dataset with proper chat templates and loss masking
- Distilling a large model into a smaller student or recovering quality after compression
When not to
- Deciding whether to fine-tune at all; use the architecture advisor first
- Implementing RLHF, DPO, or other preference-based post-training methods
- Handling knowledge gaps better solved by retrieval or reasoning budget
Install
These commands install from the publisher's repository and need no account.
skills CLI
npx skills add vasilyu1983/ai-agents-public --skill ai-llmInstalls from the repository's default branch, which may have changed since the commit we checked.
GitHub CLI 2.90 or later
gh skill install vasilyu1983/ai-agents-public ai-llm@12388321df35e0cb9ec8b01f03fbafb0a4c91b92Installs the commit we checked (1238832).
Copy by hand
Download the folder at 1238832 and put it in .claude/skills/ai-llm for Claude Code and in .agents/skills/ai-llm for Codex, Cursor, Gemini CLI, GitHub Copilot and OpenCode.
Copy for your agent
A prompt for any coding agent. It installs this skill from GitHub at the pinned commit, copies the files as they are, and runs nothing unless you ask.
Prompt
Install the agent skill "ai-llm" by vasilyu1983. Source, pinned to commit 12388321df35e0cb9ec8b01f03fbafb0a4c91b92: https://github.com/vasilyu1983/ai-agents-public/tree/12388321df35e0cb9ec8b01f03fbafb0a4c91b92/skills/universal/ai-llm 1. Download that folder at exactly this commit. Do not use the default branch. 2. Copy every file unchanged, keeping the folder structure, into .claude/skills/ai-llm/ for Claude Code and .agents/skills/ai-llm/ for Codex, Cursor, Gemini CLI, GitHub Copilot and OpenCode. Create the folders if they do not exist. 3. Do not edit the files, and do not run any script in the folder unless I ask you to. 4. When you are done, list the files you copied and where you put them. Listing and checks: https://www.agentnative.dev/skills/vasilyu1983/ai-llm
SKILL.md at the pin
--- name: ai-llm description: "Adapts LLMs: SFT dataset loss masking, LoRA and QLoRA, full FT vs PEFT, distillation, pruning, tokenizer fragmentation. Use when fine-tuning or compressing a model." compatibility: Portable core. Works on Claude Code and Codex. version: "2.3" last_validated: 2026-09-26 --- # LLM Adaptation Change a model's weights so it does a task better: supervised fine-tuning (SFT), parameter-efficient fine-tuning (PEFT: LoRA, QLoRA, DoRA), full fine-tuning, distillation and compression recovery, plus the dataset and tokenizer work that decides whether any of it succeeds. Deciding *whether* to adapt at all (prompt vs thinking vs RAG vs fine-tune vs post-train) is not this skill. Use the single build ladder in [ai-architecture-advisor](../ai-architecture-advisor/SKILL.md#llm-lane-prompt---thinking---rag---fine-tune---post-train-agent-is-a-separate-axis) first, and come here once it says "fine-tune" or "distill". ## When to Use This Skill - Configuring LoRA or QLoRA: rank, alpha, alpha convention, target modules, learning rate - Choosing full fine-tuning vs PEFT, or escalating when LoRA plateaus - Building an SFT dataset: chat templates, prompt-token loss masking, packing, contamination control - Distilling a large teacher into a smaller student, or recovering quality after pruning - Diagnosing tokenizer fragmentation, fertility, or glitch tokens on a subset of inputs - Deciding whether a fine-tune pays back (break-even on volume and stability) ## Scope Boundaries | Need | Go to | |---|---| | Which approach at all; model and provider choice; MoE vs dense | [ai-architecture-advisor](../ai-architecture-advisor/SKILL.md) | | Preference and RL post-training: RLHF/PPO, DPO, GRPO, RLVR, reward models | [ai-post-training](../ai-post-training/SKILL.md) | | Eval design, judge calibration, thresholds, benchmark harnesses | [ai-evals](../ai-evals/SKILL.md) | | Prompts, structured outputs, schema enforcement | [ai-prompt-engineering](../ai-prompt-engineering/SKILL.md) | | Context assembly and memory | [ai-context-layer](../ai-context-layer/SKILL.md) | | RAG and agents | [ai-rag](../ai-rag/SKILL.md), [ai-agents](../ai-agents/SKILL.md) | | Serving, quantization formats, pruning runtime support | [ai-llm-inference](../ai-llm-inference/SKILL.md) | | Local runs and GGUF packaging | [ai-local-model-ops](../ai-local-model-ops/SKILL.md) | | Deployment, rollout, monitoring, model/provider migration | [ai-mlops](../ai-mlops/SKILL.md) | | API cost model, caching, self-host breakeven | [ops-cost-optimization](../ops-cost-optimization/references/ai-api-cost-guide.md) | | Pretraining, tokenizer building, scaling laws | [ai-pretraining](../ai-pretraining/SKILL.md), [ai-scaling-laws](../ai-scaling-laws/SKILL.md) | | Multi-GPU parallelism | [ai-distributed-training](../ai-distributed-training/SKILL.md) | | Hugging Face TRL trainer specifics | the `huggingface-skills:` plugin (external) | ## Default Workflow 1. **Confirm the gap is behavior, not knowledge or reasoning.** Missing facts belong in retrieval and multi-step logic in the thinking budget (see the advisor ladder). Fine-tune for a stable behavior, format, or style gap that survives prompt and RAG fixes. 2. **Build the eval before the dataset.** Hold out a task set by slice, capture a same-seed baseline of the untuned model, and add an out-of-domain forgetting set. 3. **Build the dataset.** Group duplicate and near-duplicate source examples, then assign whole groups to train or eval before augmentation or synthetic generation; check for residual overlap. Apply the model's own chat template, and use the same template at train and at serve (generation prompt and end-of-turn token included): render one example through the training pipeline and through the serving engine and diff the token IDs, because a mismatch raises no error and looks like a fine-tune that did nothing ([§5E](references/dataset-formatting-guide.md#e-chat-sft-loss-on-assistant-turns-packing-stays-inside-examples)). Compute loss on assistant tokens only (`ignore_index=-100` on prompt tokens). Packing must not let attention or loss cross example boundaries. See [dataset-formatting-guide.md](references/dataset-formatting-guide.md). 4. **Start with PEFT.** LoRA or QLoRA on all linear layers; record rank, alpha, alpha convention, target modules, and effective batch (micro × accumulation × world size). Trainable share = Σ r·(d_in + d_out) over adapted matrices ÷ total parameters; compute it for your model instead of quoting a percentage. 5. **Escalate only on evidence.** If LoRA plateaus on a hard, far-from-pretraining domain, follow the escalation order in [fine-tuning-recipes.md](references/fine-tuning-recipes.md#when-full-fine-tuning-instead) and keep the forgetting eval. 6. **Distillation step.** Before any teacher call, confirm the teacher's terms permit training a competing model, and record the licence. Then pick the supervision signal your access gives you (logits, generated text, or rationales) per [advanced-llm-patterns.md](references/advanced-llm-patterns.md#knowledge-distillation-workflow). 7. **Gate the release.** Run the gate on the exact serving artifact and configuration: test the adapter loaded separately if that is how it will serve, or test the merged and quantized artifact if that is the deployment path. A delta that appears only after quantization is not the fine-tune's ([merge and quantize](references/fine-tuning-recipes.md#lora-configuration)). Pick the release checkpoint on the task and forgetting slices; validation loss only ranks checkpoints for early stopping. Compare against the baseline by slice, schema-valid and tool-call rates, and the forgetting set. Hand deployment to [ai-mlops](../ai-mlops/SKILL.md). ## Quick Reference | Decision | Default | Change when | Avoid | |---|---|---|---| | Method | LoRA/QLoRA, all-linear targets | Plateau on a hard domain after rank and DoRA tries → GaLore, then full FT | Jumping to rank 256 | | Memory | QLoRA when the base does not fit in BF16 | Base fits → plain LoRA | Sizing MoE by active params (all experts load) | | Multi-GPU | Data parallel when the frozen base fits one GPU | Base does not fit → FSDP / ZeRO-3 ([memory model](../ai-distributed-training/references/fsdp-vs-zero.md#memory-model-comparison)) | Sharding by reflex | | Loss | Assistant tokens only | Pretraining-style continued training on raw text | Training on system and user tokens | | Distillation | Sequence KD from teacher outputs | Logit access → soft-label KD; reasoning traces → trace KD | Any teacher whose terms forbid training a competitor | | Payback | Use the ROI calculator | Volume is high and the domain is stable | Fine-tuning for knowledge that changes | ## Known Traps - fine-tuning for information that should live in retrieval, or for a reasoning gap that a larger thinking budget closes - quoting a LoRA parameter percentage instead of computing Σ r·(d_in + d_out) for the actual model - computing loss on prompt tokens, or packing examples so attention crosses boundaries - splitting near-duplicate source examples across train/eval, or augmenting before assigning source groups to a split - distilling from a hosted model whose terms forbid training a competing model - gating a compressed or tuned model on perplexity; reasoning, schema-valid, and tool-call slices break first - treating a too-good eval score as success instead of a leakage alarm - sizing an MoE fine-tune by active parameters, or ignoring router drift toward a few experts Trainer features, supported losses, and framework maintenance status change often. 1. Check the trainer's own docs for supported methods and losses before promising one (for example, whether a preference loss is built in). 2. Check the model card and `config.json` for architecture facts (layers, hidden size, KV heads, MoE experts) instead of recalling them. 3. Check a framework's repository status before starting new work on it; some fine-tuning libraries have wound down. ## Scripts This skill ships no scripts. The per-call cost estimator is in [ops-cost-optimization](../ops-cost-optimization/SKILL.md) (`scripts/cost_estimator.py`), and the offline prompt regression runner is in [ai-evals](../ai-evals/SKILL.md) (`scripts/prompt_eval_runner.py`). ## Navigation: References - **[Fine-Tuning Recipes](references/fine-tuning-recipes.md)**: SFT, instruction tuning, LoRA/QLoRA configuration, PEFT method family, full-FT escalation, multi-GPU and MoE notes, safety data, mid-training, data feedback loops, contamination control - **[Dataset Formatting Guide](references/dataset-formatting-guide.md)**: instruction, chat, and transformation formats; dataset hygiene; loss masking (`ignore_index=-100`, first EOS unmasked); packing inside example boundaries. `ai-pretraining` delegates SFT formatting here. - **[Adaptation Patterns](references/advanced-llm-patterns.md)**: task-specific tuning, synthetic data, knowledge distillation (logit, sequence, on-policy, rationale, prune-then-distill, reasoning-trace) with the teacher licence gate, compression checklist, multi-task learning. `ai-architecture-advisor` owns whether to distill; `ai-pretraining` delegates distillation here. - **[Tokenizer Diagnostics](references/tokenizer-diagnostics.md)**: fertility and parity, glitch and undertrained tokens, domain fragmentation, number tokenization, typo brittleness. Building a BPE tokenizer is [ai-pretraining](../ai-pretraining/references/bpe-tokenizer.md). - **[Multimodal Patterns](references/multimodal-patterns.md)**: vision, audio, and document workflows. Outside the adaptation scope; kept here until it has an owner. Moved out of this skill: post-training → [ai-post-training](../ai-post-training/SKILL.md); eval patterns → [ai-evals](../ai-evals/SKILL.md); cost economics → [ai-api-cost-guide](../ops-cost-optimization/references/ai-api-cost-guide.md); deployment, migration, and monitoring → [ai-mlops](../ai-mlops/SKILL.md); the build ladder and model selection → [ai-architecture-advisor](../ai-architecture-advisor/SKILL.md). ## Templates - **[Fine-Tuning Config](assets/fine-tuning/template-config.md)**: reproducible SFT/LoRA config record - **[SFT Chat Dataset](assets/fine-tuning/template-sft-dataset.jsonl)** and **[Instruction Dataset](assets/fine-tuning/template-instruction.jsonl)**: minimal record shapes - **[Data Quality](assets/data-pipelines/template-data-quality.md)**: dedupe, PII, and quality checks for training data - **[Fine-Tuning ROI Calculator](assets/selection/fine-tuning-roi-calculator.md)**: break-even analysis for an adaptation investment ## External Sources See [data/sources.json](data/sources.json) for the papers and docs behind the recipes (LoRA, QLoRA, DoRA, rsLoRA, IA³, LoRA-vs-full-FT, distillation) and provider lookup pages for current-fact checks. ## Learnings Loop When prior decisions or pitfalls are relevant, consult `learnings.consolidated.md` if present; use `learnings.md` only for needed history or as the available fallback. Otherwise skip both. After applying it, if you encountered a pattern worth remembering, a mistake worth preventing, or a domain fact that surprised you, append one dated bullet to `learnings.md` via `agents-skills-feedback-loop/scripts/append_learning.py`. Do not modify `SKILL.md` itself.
From vasilyu1983/ai-agents-public at 1238832, shown as plain text under its license: MIT (permissive). The license text is in LICENSE.
View SKILL.md on GitHub at 1238832Files
- SKILL.md11 KB · 538a991271e1
- agents/
- openai.yaml344 B · b7ae937a24fb
- assets/
- data-pipelines/
- template-data-quality.md3.4 KB · b3b2ee5981a3
- fine-tuning/
- template-config.md864 B · 780e1710ddd2
- template-instruction.jsonl459 B · edd5d10c59a1
- template-sft-dataset.jsonl304 B · 24c202730cee
- selection/
- fine-tuning-roi-calculator.md8.3 KB · e4338ea7150c
- data/
- sources.json32 KB · 0ce72e2be060
- learnings.consolidated.md582 B · dd7f329b9e26
- learnings.md359 B · a2beeb7ca986
- references/
- advanced-llm-patterns.md20 KB · b1c750fad980
- dataset-formatting-guide.md6.8 KB · da92942489f0
- fine-tuning-recipes.md39 KB · d24cfff838bc
- multimodal-patterns.md16 KB · 93901e6ac34b
- tokenizer-diagnostics.md11 KB · 392f1df44fd9
15 files, 151 KB in total. Each file has a sha256 in the pin's manifest; the first 12 characters are shown.
Skill folder on GitHub at 1238832Related in AI and agents
agent-builder
Agent Builder orchestrates the creation, modification, testing, and publishing of n8n Agents.
by n8nOfficial publisher
Claude Code, Codex, Cursor +3 · about 2.3K tokens · pinned 6 days ago
intent-recognition
Classifies automation requests by determining which primitive owns the top-level control flow (workflow, agent, needs clarification, or out-of-scope) and…
by n8nOfficial publisher
Claude Code, Codex, Cursor +4 · about 6.9K tokens · pinned 6 days ago
planned-task-runtime
This skill manages follow-up interactions with a background task execution system, handling task completion synthesis, failure replanning, workflow building…
by n8nOfficial publisher
Claude Code, Codex, Cursor +3 · about 2.2K tokens · pinned 6 days ago
skill-creator
This skill guides agents through creating new skills that extend Gemini CLI with specialized knowledge, workflows, and tool integrations.
by GoogleOfficial publisher
Contains scripts
Gemini CLI · about 5K tokens · pinned 6 days ago
-21risk-automation
This skill automates 21risk operations by connecting to the 21risk toolkit through Composio's Rube MCP server.
by ComposioOfficial publisher
Claude Code, Codex, Cursor +3 · about 690 tokens · pinned 6 days ago
-2chat-automation
This skill automates 2chat tasks by integrating with Composio's 2chat toolkit through Rube MCP.
by ComposioOfficial publisher
Agents not labelled yet · about 680 tokens · pinned 6 days ago