unsloth
Provides guidance on fine-tuning large language models with Unsloth, a library for faster, lower-memory training using LoRA and QLoRA, based on its official documentation (references/llms-txt.md). Use when setting up LoRA or QLoRA fine-tuning of an LLM with Unsloth, reducing GPU memory use during training, looking up Unsloth features or APIs, debugging Unsloth training code, or learning Unsloth best practices. Not for general model training with plain Hugging Face Transformers or PEFT without Unsloth.
Install this skill
Works with Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode, and 70+ other harnesses.
npx skills add KalarisLabs/research-agent-skills --skill unslothuvx research-agent-skills install unslothDocumentation & Instructions
Unsloth Skill
Comprehensive assistance with unsloth development, generated from official documentation.
When to Use This Skill
This skill should be triggered when:
- Working with unsloth
- Asking about unsloth features or APIs
- Implementing unsloth solutions
- Debugging unsloth code
- Learning unsloth best practices
Quick Reference
Common Patterns
Quick reference patterns will be added as you use the skill.
Reference Files
This skill includes comprehensive documentation in references/:
- llms-txt.md - Llms-Txt documentation
Use view to read specific reference files when detailed information is needed.
Working with This Skill
For Beginners
Start with the getting_started or tutorials reference files for foundational concepts.
For Specific Features
Use the appropriate category reference file (api, guides, etc.) for detailed information.
For Code Examples
The quick reference section above contains common patterns extracted from the official docs.
Resources
references/
Organized documentation extracted from official sources. These files contain:
- Detailed explanations
- Code examples with language annotations
- Links to original documentation
- Table of contents for quick navigation
scripts/
Add helper scripts here for common automation tasks.
assets/
Add templates, boilerplate, or example projects here.
Notes
- This skill was automatically generated from official documentation
- Reference files preserve the structure and examples from source docs
- Code examples include language detection for better syntax highlighting
- Quick reference patterns are extracted from common usage examples in the docs
Updating
To refresh this skill with updated documentation:
- Re-run the scraper with the same configuration
- The skill will be rebuilt with the latest information
Agent operating procedure
- Check the environment. Check GPU type, memory and driver/CUDA versions (
nvidia-smi), framework versions, and dataset location and size. - Pin down the inputs. Confirm formats, identifiers and parameters from the data or the user. Ask rather than guess any value that changes the result.
- Run a small version first. Do a smoke run: tiny model or subset, few steps, and confirm loss decreases and checkpoints save.
- Execute the full task using the instructions and references above.
- Validate the result. Track metrics on held-out data, compare against a baseline, and record seeds, configs and hardware.
- Report. State what was run (versions, commands, parameters), what was checked, and what is still uncertain.
| If this happens | Do this |
|---|---|
| CUDA out-of-memory | Reduce batch size, enable gradient accumulation/checkpointing or mixed precision, or shard the model. |
| Loss is NaN or diverges | Lower the learning rate, check data for invalid values, and enable gradient clipping. |
| A function, flag or endpoint in these instructions is missing in the installed version | Check the installed version's own documentation (help(), --help, official docs), adapt, and tell the user. Never invent an API. |
| A required input, identifier or parameter is ambiguous | Ask the user, or state the assumption explicitly before running. |
Integrity rules
- Never fabricate results, parameters, identifiers, citations or statistics. If something cannot be run or verified, say so plainly.
- Never claim training results without logs; estimate compute cost before launching large jobs.
- Treat version-specific details here as possibly outdated: confirm them against the official documentation for the installed version.
- Ask before actions that cost money, consume shared GPUs or cloud quota, touch personal or patient data, or cannot be undone.
Related skills
peft-fine-tuning: Fine-tunes LLMs with Hugging Face PEFT, using LoRA, QLoRA, IA3, AdaLoRA, prefix tuning, and prompt tuning so that under 1% of parameters ar…llama-factory: Guides fine-tuning of large language models with LLaMA-Factory, covering the WebUI no-code interface, training across 100+ supported models…axolotl: Provides guidance for fine-tuning large language models with Axolotl, covering YAML training configs, LoRA and QLoRA, preference training w…
Trigger Prompts & Evaluation Corpus
These evaluation prompts test that the agent correctly selects unsloth for relevant tasks and leaves it out for near misses.
Should trigger (3)
- should trigger
“How do I load Llama 3 8B in 4-bit with Unsloth and add LoRA adapters?”
expects Shows FastLanguageModel.from_pretrained with load_in_4bit=True and max_seq_length, then FastLanguageModel.get_peft_model with r, lora_alpha, target_modules and use_gradient_checkpointing="unsloth". Confirms exact argument names against the Unsloth docs or the installed version rather than inventing them.
- should trigger
“I'm fine-tuning Qwen2.5-7B with Unsloth on my 24GB RTX 4090 using train.py and a JSONL file, data/clinical_notes.jsonl, with 'instruction' and 'response' fields. It crashes with 'torch.OutOfMemoryError: CUDA out of memory' at step 12 with max_seq_length=8192 and per_device_train_batch_size=4. What should I change?”
expects Checks nvidia-smi and the Unsloth version first. Suggests lowering per_device_train_batch_size and raising gradient_accumulation_steps, reducing max_seq_length, using 4-bit loading and Unsloth gradient checkpointing, and a smaller LoRA rank. Recommends a short smoke run to confirm loss decreases. Asks about or flags the sensitivity of clinical data before any upload or cloud use. Makes no claims about results without logs.
- should trigger
“I have a single consumer GPU with 16GB VRAM and want to adapt a 8B open-weight model to answer questions in my lab's protocol style, using as little memory and time as possible. Which library and setup would speed up the training and cut memory use, and how would I export the result to GGUF for local use?”
expects Recommends a memory-efficient LoRA/QLoRA workflow with Unsloth, explaining 4-bit loading, gradient checkpointing and a small batch with gradient accumulation. Describes saving the merged model or LoRA adapter and exporting to GGUF through Unsloth's documented save methods, checking the docs for exact method names. Notes the VRAM estimate is uncertain and suggests a smoke run first.
Near misses (2)
- near miss
“Write a plain Hugging Face PEFT script with LoraConfig and get_peft_model, then train it with TRL SFTTrainer on my dataset. I'm not using Unsloth and don't want it as a dependency. Also show how to merge the adapter afterward.”
expects Should not use the unsloth skill. Uses peft-fine-tuning guidance: LoraConfig with r, alpha, target_modules, get_peft_model, SFTTrainer, and merge_and_unload.
- near miss
“Set up a LLaMA-Factory YAML config and use its WebUI to fine-tune Qwen2-VL with 4-bit QLoRA on my image-caption dataset.”
expects Should not use the unsloth skill. Uses llama-factory guidance for the WebUI or YAML config, the dataset_info.json registration, and quantization_bit settings for multimodal QLoRA.