DEV Community

Cover image for Master Local Fine-Tuning with "gemma-trainer"
bebechien for Google AI

Posted on • Originally published at bebechien.github.io

Master Local Fine-Tuning with "gemma-trainer"

Agent-led guardrails for model capabilities

Remember back in May when I introduced the gemma-skills repository? It's been rewarding to see how many of you have used my previous post to streamline your workflows. (And hey, even if we aren't swimming in GitHub stars yet, I think we're off to a great start!๐Ÿ˜‰)

But as I built more custom applications, I kept hitting the same roadblock: how to take a great base model and adapt it to my specific needs.

Fine-tuning a model usually requires wading through complex setups and confusing guides. To make this process straightforward and quick, we created our newest skill: gemma-trainer

What is gemma-trainer?

gemma-trainer is your blueprint for training and adapting Gemma models on your local hardware. It handles the "how-to" so you can focus on your specific project goals, whether you are teaching a model a new domain or aligning its behavior to your preferences.

Why You'll Use It

  • Faster, Lighter Training: We recommend using Unsloth for single-GPU training, making it fast and using less memory so it runs easily on personal hardware.

  • Three Key Methods: It guides you through Supervised Fine-Tuning (SFT) to teach new info, Direct Preference Optimization (DPO) to align with preferences, and Reward Modeling (RM) to rate responses.

  • Teach Models to See and Hear: It includes clear instructions for training models with images and audio (multimodal learning) alongside text.

  • Run Anywhere: Quickly convert your models to lightweight formats (like GGUF) and run them on mobile or smart devices (IoT) using LiteRT-LM.

  • Up-to-Date Best Practices: The skill is continuously updated with the latest optimized settings and training techniques, ensuring you're always using the best methods.

Practical Use Case

To see this in action, recall how we turned Gemma 4 into an expert translator for Classical Korean literature in my previous post. With gemma-trainer, you don't need to manually piece together a pipeline. You can simply ask your agent:

"Fine-tune Gemma 4 E2B on the dataset bebechien/HongGildongJeon."

With the gemma-trainer skill, your agent will partner with you to:

  1. Verify your data: Use the validation script to ensure your training data matches template requirements.

  2. Set up parameters: Select the best LoRA settings to teach the model linguistic nuances without running out of video memory (VRAM).

  3. Run the training: Launch the training session using optimized, resource-efficient defaults.

  4. Evaluate and iterate: Review the model's performance and adjust settings to get the exact results you need.

Here is an example showing the agent starting a fine-tuning run on a Gemma 4 12B model for audio tasks:

audio-tuning start

Once configured, the agent kicks off the training process using your designated dataset:

audio-tuning training

Even if you make a mistake, the agent has your back. For instance, when I accidentally requested training a Gemma 4 31B model (which is a text-and-vision model and has no audio capability), it suggested using Gemma 4 E2B or 12B for audio tuning instead:

audio-tuning fix

Once training is complete, the agent presents the results and outlines the next steps:

audio-tuning finish

You can also ask your agent to write a custom evaluation script based on your specific requirements. In this case, I asked the agent to create a script that checks transcription similarity:

audio-tuning eval

Finally, you will receive a comprehensive report summarizing the training performance, making it clear where you can make improvements in the next run:

audio-tuning report

Let's try!

gemma-trainer is a living, structured document. Drop it into your agent's skills directory, and your AI assistant will immediately know how to guide you through the process.

Check out the repository, add the skill to your toolbox, and let's build something amazing!

Thanks for reading and happy training!

Top comments (10)

Collapse
 
nazar-boyko profile image
Nazar Boyko

That moment where the agent caught you trying to audio-tune a vision-only model and pointed you at E2B instead is the feature that sells this for me. So I'm curious how the guardrail knows: is the model-to-capability map hard-coded into the skill, or does the agent read it off the model card at runtime? New checkpoints tend to show up faster than any static list gets updated, so if it's hard-coded, a fresh Gemma release with a new capability would quietly fall through until someone patches the skill. Which way did you build it?

Collapse
 
bebechien profile image
bebechien Google AI

Exactly! The skill file include specific guidelines, like using the Gemma 4 E2B through 31B models for vision SFT, and the E2B through 12B models for audio SFT. So if you explain exactly what you're trying to do, your agent can spot errors for you.

To maximize the value of these skills, we will continuously update it alongside every new Gemma release.

Collapse
 
nazar-boyko profile image
Nazar Boyko

thanks for sharing!

Collapse
 
motedb profile image
mote

The LiteRT-LM angle for IoT is where this gets genuinely interesting รขย€ย” not just because you can shrink the model, but because the fine-tuned model now has state that needs to survive alongside the device. When you fine-tune locally and deploy on an edge device, the model weights travel with the hardware, but the training metadata (what data shaped it, which epochs actually improved evaluation, what the failure modes were during SFT) usually gets left behind on the workstation.

That gap matters more than people think. A model that "knows" classical Korean translation but can't tell you why it knows it is a model you can't debug when it drifts. We ran into this building moteDB รขย€ย” an embedded multimodal database in Rust รขย€ย” where the storage layer lives on the same device as the inference engine. The fine-tuned weights, the training logs, the evaluation curves, and the raw training samples all coexist in one store. When the model degrades at month six on a Raspberry Pi, you can actually trace what happened instead of just re-running the whole pipeline.

Has anyone here tried persisting fine-tuning metadata alongside the deployed model? I'd be curious how you handle the "why does this model know what it knows" problem on devices that don't have cloud access.

Collapse
 
quick_bi_lydaas profile image
Quick BI

Great article! The agent-led guardrail approach is really impressive โ€” having the agent automatically catch model capability mismatches (like the audio-tuning on a vision-only model) saves a lot of debugging time. Looking forward to trying gemma-trainer with multimodal fine-tuning. Thanks for sharing!

Collapse
 
dainguyen202 profile image
Dai Nguyen

yeah, so good for everyone

Collapse
 
tahami_akservices_cb075e profile image
Tahami AK SERVICES

Assalamualaikum,
This looks really interesting, Iโ€™m still a beginner so some parts are new to me.
Just curious, where should someone like me start before learning this?

Collapse
 
laxmansubadi profile image
laxman Subedi

as problem and this problem a one platform fully one work space

Collapse
 
laxmansubadi profile image
laxman Subedi

One workspace for developers. Analyze, review, explain, test, and debug your code in one place.โ€

Some comments may only be visible to logged-in visitors. Sign in to view all comments.