gemma-trainer
Train and adapt Gemma models on consumer hardware through supervised fine-tuning, direct preference optimization, and reward modeling workflows. The skill guides you through memory-efficient setups with Unsloth and TRL, dataset formatting, multimodal training for vision and audio, and deployment via GGUF or LiteRT.
Gemma-trainer enables efficient local fine-tuning of Gemma models using QLoRA, SFT, DPO, and reward modeling.
AI-generated summary based on this skill's SKILL.md
Install
google-gemma/gemma-skills/gemma-trainer · repository language: Python
git clone https://github.com/google-gemma/gemma-skills
cp -r gemma-skills/skills/gemma-trainer ~/.claude/skills/gemma-trainernpx skillfed install google-gemma/gemma-skills/gemma-trainerFrequently asked questions
AI-generated answers based on this skill's SKILL.md and metadata
How do I fine-tune Gemma locally on consumer hardware?
gemma-trainer guides you through fine-tuning Gemma models on local hardware using memory-efficient methods like QLoRA and Unsloth. The skill covers supervised fine-tuning workflows that let you adapt Gemma on single GPUs, including hyperparameter configuration, training loops, and checkpoint management for practical consumer-grade setups.
What dataset formats does gemma-trainer support for training?
gemma-trainer handles dataset preparation and validation for Gemma training workflows, including chat template formatting and structured data layouts. The skill guides you through preparing datasets in formats compatible with supervised fine-tuning, DPO alignment, and reward modeling pipelines, ensuring your data integrates smoothly with TRL and Unsloth frameworks.
How can I use DPO alignment with Gemma models?
gemma-trainer covers direct preference optimization (DPO) techniques for aligning Gemma model behavior without reward models. The skill walks through DPO training setup, preference pair formatting, and training loops to refine model outputs based on human preferences, complementing supervised fine-tuning for more nuanced behavioral control.
How do I deploy trained Gemma models to mobile devices?
gemma-trainer supports deployment workflows via GGUF conversion and LiteRT optimization for edge and mobile environments. The skill covers model format conversion, inference optimization, and device-specific configurations to run your fine-tuned Gemma models efficiently on resource-constrained platforms.
Does gemma-trainer support multimodal fine-tuning for vision and audio?
Yes, gemma-trainer includes guidance for multimodal training workflows extending Gemma to vision and audio modalities. The skill covers dataset preparation, training loops, and model adaptation techniques for multimodal fine-tuning, enabling you to extend Gemma's capabilities beyond text on local hardware.
What memory-efficient training methods does gemma-trainer use?
gemma-trainer leverages Unsloth and TRL for memory-efficient training, including QLoRA quantization and LoRA adapters. The skill provides hyperparameter tuning guidance and setup instructions to maximize training efficiency on limited VRAM, making Gemma fine-tuning accessible on consumer GPUs.
SKILL.md
rendered from the published skill — quoted content, verbatim
Gemma Training and Fine-Tuning Skill
1. Core Principles: Local Fine-Tuning Setup
When training locally, memory efficiency and execution speed are huge. Always guide the user to follow these best practices:
- Prioritize Unsloth: For local single-GPU training, always recommend Unsloth. It supports Gemma 4 natively, uses up to 70% less memory, and is up to 2x faster than standard Hugging Face PEFT training.
- Fall Back to TRL: For multi-GPU environments (using DDP/FSDP) or when Unsloth is unavailable, use Hugging Face TRL (
SFTTrainer,DPOTrainer) coupled with PEFT and bitsandbytes (for QLoRA). - Always use QLoRA (4-bit Quantization): Crucial for fitting Gemma models (like Gemma 4 12B/31B) into consumer VRAM.
- Manage Context Window & Max Length: Although Gemma 4 supports up to a 256K context window, recommend training with a context window of 2048 to 8192 tokens locally to
(truncated - see the full file via the links below)
Read as markdown · JSON record · Browse the source repository
File tree — 6 files
skills/gemma-trainer/SKILL.md
skills/gemma-trainer/assets/dataset_prep.py
skills/gemma-trainer/assets/distill_dataset.py
skills/gemma-trainer/assets/dpo_train.py
skills/gemma-trainer/assets/reward_train.py
skills/gemma-trainer/assets/sft_train.py