Unsloth Zoo
Unsloth Zoo provides a collection of plug-and-play utilities and example modules designed to work with the Unsloth library for efficient LLM fine-tuning. It includes components for dataset loading, SFT (Supervised Fine-Tuning) trainers, tokenizer utilities, and metrics. As of version 2026.4.6, it aims to simplify and standardize common LLM fine-tuning workflows built on Unsloth, with frequent updates aligning with Unsloth's development.
Warnings
- breaking Unsloth Zoo's API and underlying logic are tightly coupled with the `unsloth` library. Major and even minor version updates of `unsloth` can introduce breaking changes that require `unsloth-zoo` to be updated simultaneously. Mismatched versions can lead to runtime errors or incorrect behavior.
- gotcha Dataset templates provided by `unsloth_zoo.data` expect specific JSON or text formats. When using custom datasets, ensure they strictly adhere to these templates (e.g., 'instruction', 'input', 'output' fields for chat templates) to avoid parsing errors or incorrect model training.
- gotcha Performance and resource usage of `unsloth-zoo` modules are heavily dependent on the `unsloth` backend and correct GPU setup. Misconfigurations (e.g., incorrect CUDA version, missing `bitsandbytes` installation, incompatible PyTorch) will result in poor performance or errors.
Install
-
pip install unsloth-zoo
Imports
- Trainer
from unsloth_zoo.sft.trainer import Trainer
- load_dataset
from unsloth_zoo.data.loader import load_dataset
- DatasetConfig
from unsloth_zoo.data.configs import DatasetConfig
Quickstart
from unsloth_zoo.data.configs import DatasetConfig
from unsloth_zoo.data.loader import load_dataset
# Configure a dataset, e.g., using a predefined template
config = DatasetConfig(dataset_name="alpaca_template")
# Load the dataset
dataset = load_dataset(config)
print(f"Loaded dataset with {len(dataset)} examples.")
if len(dataset) > 0:
print("First example:")
print(dataset[0])