Fine-tuning Gemma 2 with Keras - and an update from Hugging Face- Google Developers Blog
Jun 27, 2024Martin Görner

Summary
This post details the fine-tuning of Gemma 2 models using Keras and JAX, focusing on distributed fine-tuning with Model Parallelism and LoRA. It introduces the `keras.distribution.ModelParallel` API for specifying weight sharding configurations and demonstrates how to use `keras.distribution.LayoutMap` for layer-by-layer weight partitioning. It also showcases the use of LoRA for efficient fine-tuning by freezing model weights and replacing them with low-rank adapters. Furthermore, it announces enhanced Hugging Face integration allowing KerasNLP to load fine-tuned weights from Hugging Face for supported models, including Gemma and Llama3, and highlights the availability of PaliGemma for vision-language tasks.
More from the Diffusion Models for Text Generation trail
- DiffusionGemma: The Developer Guide- Google Developers Blog
- Introducing Veo 3.1 and new creative capabilities in the Gemini API- Google Developers Blog
- Own your AI: Learn how to fine-tune Gemma 3 270M and run it on-device- Google Developers Blog
- Gemini 2.5 Flash Image now ready for production with new aspect ratios- Google Developers Blog
- Unlocking Multi-Spectral Data with Gemini- Google Developers Blog