/vibe:distillation-expertfrom vibe
Guides teacher-student LLM distillation: hard-label SFT, soft-label KL, on-policy (GKD, MiniLLM), and context distillation. Use when compressing models or replacing API dependencies.
Ships in vibe. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
You are an expert in distilling large language model capabilities into smaller students. You pick between hard-label SFT distillation, soft-label (logit) KL distillation, on-policy distillation (e.g., DistillKit, MiniLLM, GKD), and context distillation for behavioral compression.
Generate completions with a strong teacher; SFT the student on those completions. This is by far the most common form in practice (e.g., Alpaca from text-davinci-003, OpenHermes from GPT-4).
Train the student to match the teacher's full output distribution token-by-token:
L_KD = α * KL(p_teacher(·|x, y_<t) || p_student(·|x, y_<t)) + (1-α) * L_SFT
Often with temperature T > 1 to soften both distributions and surface dark knowledge in the tails.
The student samples its own completions; the teacher scores or critiques them. Avoids exposure bias of pure off-policy KD and matches RL post-training distributions far better.
Distill behavior elicited by a long system prompt into a model that doesn't need that prompt at inference. Useful for compressing safety constitutions, complex personas, or long few-shot demos into the weights.
Skip if: the student is already near the teacher's capability (diminishing returns), or you can fine-tune the teacher directly (just do SFT/DPO).
# Step 1: generate completions with teacher (offline)
from transformers import pipeline
gen = pipeline("text-generation", model="Qwen/Qwen2.5-72B-Instruct", device_map="auto")
prompts = load_dataset("HuggingFaceH4/no_robots", split="train")["prompt"]
completions = [gen(p, max_new_tokens=512)[0]["generated_text"] for p in prompts]
# Step 2: SFT the student
from trl import SFTTrainer, SFTConfig
trainer = SFTTrainer(
model="Qwen/Qwen2.5-1.5B",
train_dataset=Dataset.from_dict({"prompt": prompts, "completion": completions}),
args=SFTConfig(completion_only_loss=True, learning_rate=2e-5),
)
trainer.train()
TRL provides GKDTrainer (Generalized Knowledge Distillation, Agarwal et al. 2024) which combines on-policy generation with teacher-distribution matching:
from trl import GKDTrainer, GKDConfig
from transformers import AutoModelForCausalLM
teacher = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2.5-72B-Instruct", torch_dtype="bfloat16")
student = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2.5-1.5B")
args = GKDConfig(
output_dir="qwen-gkd",
teacher_model_name_or_path=None, # use the loaded teacher object
lmbda=0.5, # student-self vs teacher-data mix (on-policy fraction)
beta=0.5, # JSD interpolation between forward/reverse KL
temperature=1.0,
learning_rate=2e-5,
bf16=True,
)
trainer = GKDTrainer(
model=student,
teacher_model=teacher,
args=args,
train_dataset=ds,
)
trainer.train()
# Run teacher with the long system prompt; capture its outputs.
LONG_SYSTEM = "You are SafetyBot. Always... [several KB of policy] ..."
teacher_outputs = [teacher(LONG_SYSTEM + "\n\n" + user_msg) for user_msg in user_msgs]
# Train student WITHOUT the system prompt to produce the same outputs.
student_dataset = [{"prompt": user_msg, "completion": out}
for user_msg, out in zip(user_msgs, teacher_outputs)]
# Standard SFT from here.
| Knob | Hard-label SFT | Logit KL / GKD |
|---|---|---|
learning_rate | 1e-5 to 5e-5 | 1e-5 to 2e-5 |
temperature (KL) | n/a | 1.0–2.0 |
lmbda (GKD on-policy fraction) | n/a | 0.25–0.5 |
beta (JSD mix in GKD) | n/a | 0.5 (JSD); 0 = forward KL, 1 = reverse KL |
| Dataset size | 50k–500k | 10k–100k (logits are richer per token) |
Forward KL (teacher mode-covering) tends to make the student bland but safe. Reverse KL (teacher mode-seeking) sharpens but can collapse to one mode. JSD at beta=0.5 is a robust default.
<think>...</think>); preserve them in the student's chat template or strip them consistently.(1-α) * L_SFT at α≈0.5.Activate when the user wants to compress a large model, mentions distillation / GKD / DistillKit / MiniLLM, asks about teacher-student training, or wants to bake a long system prompt into weights.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub anubhavg-icpl/vibe --plugin vibe5,304 skills in this plugin
/3d-pipelineChoose a 3D generation or reconstruction pipeline given input type, output format, and use case. Use when you need help with 3d pipeline./8-bit-orbit-video-templateHyperframes Video TemplateShip a premium template-mode Hyperframes composition with a ready default showcase and deterministic timeline behavior./a2a-agent-specProduce the Agent Card and skills schema for an agent that should be callable over A2A. Use when you need help with a2a agent spec.Other plugins' skills for the same job