Agent skill

unsloth-sft

Supervised fine-tuning using SFTTrainer, instruction formatting, and multi-turn dataset preparation with triggers like sft, instruction tuning, chat templates, sharegpt, alpaca, conversation_extension, and SFTTrainer.

Stars 0
Forks 0

Install this agent skill to your Project

npx add-skill https://github.com/cuba6112/skillfactory/tree/main/skills/unsloth-sft

SKILL.md

Overview

Supervised Fine-Tuning (SFT) in Unsloth focuses on training models to follow instructions using specific formats. It provides tools for chat template mapping, multi-turn conversation synthesis via conversation_extension, and optimized dataset processing.

When to Use

  • When training models on instruction-response datasets (e.g., Alpaca).
  • When developing multi-turn conversational agents.
  • When you need to standardize various dataset formats (ShareGPT, OpenAI) for training.

Decision Tree

  1. Is your dataset single-turn?
    • Yes: Use conversation_extension to synthetically create multi-turn samples.
    • No: Map columns using standardize_sharegpt.
  2. Are you training on Windows?
    • Yes: Set dataset_num_proc = 1 in SFTConfig.
    • No: Use multiple processes for faster mapping.
  3. Want to increase multi-turn accuracy?
    • Yes: Enable masking of inputs to train on completions only.

Workflows

Chat Template Implementation

  1. Select a template (e.g., 'chatml', 'llama-3.1') using get_chat_template(tokenizer, chat_template='...').
  2. Map dataset columns using the mapping parameter (e.g., mapping = {'role' : 'from', 'content' : 'value'}).
  3. Apply the formatting function to the dataset using dataset.map with batched=True.

Multi-turn Data Preparation

  1. Load a standard single-turn dataset like Alpaca.
  2. Use standardize_sharegpt(dataset) to unify the role and content keys.
  3. Apply conversation_extension=N to randomly concatenate N rows into single interactive samples.

Non-Obvious Insights

  • Training on completions only (masking out inputs) significantly increases accuracy, particularly for multi-turn conversations where input context is repetitive.
  • Standardizing datasets to ShareGPT format before mapping is the most robust way to ensure compatibility with Unsloth's internal formatting kernels.
  • On Windows, dataset_num_proc must be 1; otherwise, the multi-processing overhead or library incompatibilities will cause trainer crashes.

Evidence

  • "We introduced the conversation_extension parameter, which essentially selects some random rows in your single turn dataset, and merges them into 1 conversation!" Source
  • "Training on completions only (masking out inputs) increases accuracy by quite a bit, especially for multi-turn conversational finetunes!" Source

Scripts

  • scripts/unsloth-sft_tool.py: Python tool for formatting datasets into ShareGPT/ChatML format.
  • scripts/unsloth-sft_tool.js: JavaScript logic for mapping Alpaca-style datasets to conversation formats.

Dependencies

  • unsloth
  • trl
  • datasets

References

  • [[references/README.md]]

Expand your agent's capabilities with these related and highly-rated skills.

cuba6112/skillfactory

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.

0 0
Explore
cuba6112/skillfactory

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.

0 0
Explore
cuba6112/skillfactory

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.

0 0
Explore
cuba6112/skillfactory

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.

0 0
Explore
cuba6112/skillfactory

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).

0 0
Explore
cuba6112/skillfactory

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.

0 0
Explore

Didn't find tool you were looking for?

Be as detailed as possible for better results