Fine-Tuning Gemma 4 for K-12 Education: A Practical Low-Resource Framework on Apple Silicon
This work documents a practical end-to-end workflow for fine-tuning Google's Gemma 4 (4 billion parameter variant) on K-12 educational tasks using consumer hardware — specifically the Apple M3 with 16 GB unified memory. The process covers: (1) data preparation from 840 raw JSON examples across four schemas (Alpaca, ShareGPT, Chain-of-Thought, and domain-tagged); (2) an iterative repair pipeline producing a curated set of 517 high-quality examples after removing PII-contaminated, malformatted, and style-conflicting entries; (3) LoRA fine-tuning with batch-size 1 using MLX-LM with 4-bit quantisation within a 16 GB memory constraint; and (4) a single master K-12 LoRA adapter saved as k12_school_adapter/0000600_adapters.safetensors at iteration 600. Training achieved a final validation loss of 1.558 over 600 iterations with a train/validation gap of 0.031. A Multi-LoRA deployment architecture — where this master adapter serves as the base for subject-specific and grade-specific adapters — is proposed as the recommended next step for multi-tenant school deployment. Code scripts may be provided on request.
Authors
- Mudit Mehrotra
Publication Details
- Journal
- Zenodo (CERN European Organization for Nuclear Research)
- Published
- 2026-06-24
- DOI
- https://doi.org/10.5281/zenodo.20828138
- Primary Topic
- Teaching and Learning Programming
- Type
- preprint