fine-tuning
LLM fine-tuning and prompt-tuning techniques
When & Why to Use This Skill
This Claude skill offers a comprehensive toolkit for LLM fine-tuning and prompt-tuning, enabling developers to optimize model performance through advanced PEFT techniques like LoRA, QLoRA, and Prefix Tuning. It provides structured workflows for dataset preparation, hyperparameter configuration, and rigorous evaluation to ensure high-quality model adaptation for specialized domains.
Use Cases
- Domain-Specific Adaptation: Fine-tuning base models on specialized datasets (e.g., medical, legal, or technical) to improve accuracy and industry-specific terminology.
- Resource-Efficient Training: Implementing LoRA or QLoRA to achieve high-performance model updates with minimal compute budget and consumer-grade hardware.
- Instruction Following Optimization: Using structured templates and quality checklists to prepare datasets that enhance a model's ability to follow complex instructions.
- Performance Benchmarking: Utilizing the built-in evaluation framework to track loss, accuracy, and perplexity, ensuring models meet quality targets before deployment.
- Prompt Engineering Automation: Applying prompt-tuning and prefix-tuning techniques to steer model behavior for specific generation tasks without full parameter retraining.
| name | fine-tuning |
|---|---|
| description | LLM fine-tuning and prompt-tuning techniques |
| sasmp_version | "1.3.0" |
| bonded_agent | 05-prompt-optimization-agent |
| bond_type | PRIMARY_BOND |
Fine-Tuning Skill
Bonded to: prompt-optimization-agent
Quick Start
Skill("custom-plugin-prompt-engineering:fine-tuning")
Parameter Schema
parameters:
tuning_method:
type: enum
values: [full, lora, qlora, prompt_tuning, prefix_tuning]
default: lora
dataset_size:
type: enum
values: [small, medium, large]
description: "<1k, 1k-10k, >10k examples"
compute_budget:
type: enum
values: [low, medium, high]
default: medium
Tuning Methods Comparison
| Method | Parameters | Compute | Quality | Best For |
|---|---|---|---|---|
| Full Fine-tune | All | Very High | Highest | Maximum customization |
| LoRA | ~0.1% | Low | High | Resource-constrained |
| QLoRA | ~0.1% | Very Low | Good | Consumer GPUs |
| Prompt Tuning | <0.01% | Minimal | Good | Simple tasks |
| Prefix Tuning | ~0.1% | Low | Good | Generation tasks |
Dataset Preparation
Format Templates
formats:
instruction:
template: |
### Instruction
{instruction}
### Response
{response}
chat:
template: |
<|user|>
{user_message}
<|assistant|>
{assistant_response}
completion:
template: "{input}{output}"
Quality Criteria
quality_checklist:
- [ ] No duplicate examples
- [ ] Consistent formatting
- [ ] Diverse examples
- [ ] Balanced categories
- [ ] High-quality outputs
- [ ] No harmful content
Training Configuration
training_config:
hyperparameters:
learning_rate: 2e-5
batch_size: 8
epochs: 3
warmup_ratio: 0.1
lora_config:
r: 16
alpha: 32
dropout: 0.05
target_modules: ["q_proj", "v_proj"]
evaluation:
eval_steps: 100
save_steps: 500
metric: loss
Evaluation Framework
| Metric | Purpose | Target |
|---|---|---|
| Loss | Training progress | Decreasing |
| Accuracy | Task performance | >90% |
| Perplexity | Model confidence | <10 |
| Human eval | Quality assessment | Preferred >80% |
Troubleshooting
| Issue | Cause | Solution |
|---|---|---|
| Overfitting | Small dataset | Add regularization |
| Underfitting | Low epochs | Increase training |
| Catastrophic forgetting | Aggressive tuning | Lower learning rate |
| Poor generalization | Data bias | Diversify dataset |
References
See: Hugging Face PEFT, OpenAI Fine-tuning Guide