Agent skill
unsloth-cpt
Install this agent skill to your Project
npx add-skill https://github.com/cuba6112/skillfactory/tree/main/skills/unsloth-cpt
SKILL.md
Overview
Unsloth-cpt provides specific optimizations for Continued Pretraining (CPT) and domain adaptation. It addresses the critical need for training embedding layers and language modeling heads while stabilizing the training process using Rank Stabilized LoRA (rsLoRA) and differentiated learning rates.
When to Use
- When teaching a model a new language or highly specialized domain (e.g., legal, medical).
- When updating the
embed_tokensorlm_headlayers. - When using high LoRA ranks (e.g., r=256) which can become unstable without rsLoRA.
Decision Tree
- Are you training on a new domain with unique vocabulary?
- Yes: Include
lm_headandembed_tokensintarget_modules.
- Yes: Include
- Are you using a LoRA rank > 64?
- Yes: Set
use_rslora = True.
- Yes: Set
- Are you training embeddings?
- Yes: Set
embedding_learning_rateto 1/10th of the standard learning rate.
- Yes: Set
Workflows
- New Language Adaptation: Load the base model and configure
get_peft_modelto targetlm_head,embed_tokens, andgate_projwithuse_rslora = True. - Stabilizing Embedding Updates: Use
UnslothTrainerand setlearning_rate = 5e-5with a significantly lowerembedding_learning_rate(e.g., 5e-6). - Continued Finetuning from Adapters: Load existing adapters using
from_pretrainedand resume training on refined domain data.
Non-Obvious Insights
- Training on
lm_headandembed_tokenswith the standard learning rate often degrades performance; a 2-10x smaller learning rate is required for stability. - Including the
gate_projmatrix in LoRA modules is essential for CPT; omitting it leads to significantly faster catastrophic forgetting. - Rank Stabilized LoRA (rsLoRA) is mathematically necessary to maintain scaling stability when using very high ranks (r=256) for broad domain adaptation.
Evidence
- "Blindly training on the lm_head and embed_tokens does even worse! We must use a smaller learning rate for the lm_head and embed_tokens." Source
- "The paper showed how Llama-2 performed well on maths, but not code - this is because the lm_head & embed_tokens weren't trained." Source
Scripts
scripts/unsloth-cpt_tool.py: Configuration for rsLoRA and embedding learning rates.scripts/unsloth-cpt_tool.js: Helper for calculating rank-scaled learning rates.
Dependencies
unslothtorchpeft
References
- references/README.md
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
prompt-engineering
Comprehensive prompt engineering techniques for Claude models. Use this skill when crafting, optimizing, or debugging prompts for Claude API, Claude Code, or any Claude-powered application. Covers system prompts, role prompting, multishot examples, chain of thought, XML structuring, long context handling, extended thinking, prompt chaining, Claude 4.x-specific best practices, and agentic orchestration including subagents, agent loops, skills, MCP integration, and multi-agent workflows.
adk-rag-agent
Build RAG (Retrieval-Augmented Generation) agents with Google ADK and Vertex AI RAG Engine. Use when implementing document Q&A, knowledge base search, or citation-backed responses. Covers VertexAiRagRetrieval tool, corpus setup, and citation formatting.
headless-cli-agents
Build agentic systems using Claude CLI in headless mode or the Claude Agent SDK. Use when building automation pipelines, CI/CD integrations, multi-agent orchestration, or programmatic Claude interactions. Covers CLI flags (-p, --output-format), session management (--resume, --continue), Python SDK (claude-agent-sdk), custom tools, and agent loop patterns.
notion-knowledge-capture
Capture conversations and decisions into structured Notion pages; use when turning chats/notes into wiki entries, how-tos, decisions, or FAQs with proper linking.
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).
gh-fix-ci
Inspect GitHub PR checks with gh, pull failing GitHub Actions logs, summarize failure context, then create a fix plan and implement after user approval. Use when a user asks to debug or fix failing PR CI/CD checks on GitHub Actions and wants a plan + code changes; for external checks (e.g., Buildkite), only report the details URL and mark them out of scope.
Didn't find tool you were looking for?