Overview of gemma-skills
maingemma-skills repository provides specialized skills designed to enhance interactions with Gemma models and agents. It includes specific skills for application development and model training/fine-tuning.repository·main·Indexed 20 days ago
https://github.com/google-gemma/gemma-skillsA repository providing specialized capabilities for interacting with Gemma models. It includes gemma-dev for application development and general knowledge, and gemma-trainer for training, fine-tuning, and adapting models using methods such as SFT, DPO, RLHF, and Reward Modeling on local hardware.
gemma-skills repository provides specialized skills designed to enhance interactions with Gemma models and agents. It includes specific skills for application development and model training/fine-tuning.Select a training workflow based on your objective:
| Method | Goal | Prerequisites | Output |
|---|---|---|---|
| Supervised Fine-Tuning (SFT) | Teaching new domains, specialized tasks, or custom structures. | Raw text, instruction pairs, or chat logs. | Adaptor trained on prompt/completion pairs. |
| Direct Preference Optimization (DPO) | Aligning style, behavior, tone, or safety with human preferences. | A previously SFT-trained Gemma model and pairwise preference datasets. | Aligned model weights (no separate reward head). |
| Reward Modeling (RM) | Training a scoring system to evaluate response quality. | Binary preference pairwise datasets. | A classification-style reward head on top of Gemma. |
For lower latency, use Multi-Token Prediction (MTP). This uses a lightweight assistant model to propose multiple candidate tokens, which the target model verifies in a single pass.
Each Gemma 4 target model has a corresponding assistant model following the naming convention <target-model-id>-assistant.
Assistant Model Repos:
google/gemma-4-E2B-it-assistantgoogle/gemma-4-E4B-it-assistantgoogle/gemma-4-12B-it-assistantgoogle/gemma-4-31B-it-assistantgoogle/gemma-4-26B-A4B-it-assistantFormatting errors are a primary cause of training failure. Always validate your dataset files using the utility script assets/dataset_prep.py.
Ensure datasets match the official chat template:
system
Your instruction here
user
Your query here
model
Your response hereTip: Use the tokenizer's apply_chat_template during tokenization to avoid formatting drift.
Execute alignment using the assets/dpo_train.py template.
Critical Rules for DPO:
beta (DPO temperature) to 0.1. Values between 0.1 and 0.5 control how strictly the model adheres to the reference policy.You can manage and install skills using the Vercel skills CLI via npx.
To interactively browse and select skills from this repository, use the --list flag. To install a specific skill globally, use the --skill flag followed by the skill name.
# Interactively browse and install skills.
npx skills add google-gemma/gemma-skills --list
# Install a specific skill (e.g., gemma-dev).
npx skills add google-gemma/gemma-skills --skill gemma-dev --globalGemma 4 models (E2B/E4B/12B/26B/31B) support multimodal vision fine-tuning. Use standard Hugging Face SFTTrainer with a custom visual data collator.
Dataset Format: Prepare a dataset containing local image paths or PIL images within the message structure:
{
"messages": [
{"role": "user", "content": [
{"type": "image", "url": "path/to/image.png"},
{"type": "text", "text": "Describe this image."}
]},
{"role": "assistant", "content": [
{"type": "text", "text": "An abstract oil painting with vibrant warm gradients."}
]}
]
}Gemma 4 models (E2B/E4B/12B) support multimodal audio fine-tuning. Feed raw audio arrays (sampled at 16kHz) through the model processor to produce input_features.
Dataset Format:
Maintain conversational formatting, replacing the image type with audio type:
{
"messages": [
{"role": "user", "content": [
{"type": "text", "text": "Describe this audio."},
{"type": "audio", "url": "path/to/audio.wav"}
]},
{"role": "assistant", "content": [
{"type": "text", "text": "This is an audio file of a bird chirping."}
]}
]
}For mobile, web, and IoT hardware, use LiteRT-LM to run models like Gemma 4 E2B and Gemma 4 E4B. LiteRT-LM provides hardware acceleration for CPU, GPU, and NPU.
Models are deployed using the .litertlm format.
Use the assets/reward_train.py template to train an evaluation model. This process:
AutoModelForSequenceClassification with num_labels=1).After LoRA training, convert your model to GGUF for inference.
If you used Unsloth for training, you can export directly to GGUF natively. This handles both merging and quantization automatically.
If you did not use Unsloth, manually convert your merged Hugging Face model directory using llama.cpp.
Launch a local QLoRA fine-tuning session using the assets/sft_train.py script.
Recommended LoRA Hyperparameters:
r): 16 or 32.lora_alpha): 32 or 64 (Target lora_alpha = 2 * r).lora_dropout): 0.05 or 0.1.2e-4 for QLoRA; 2e-5 for full fine-tuning.