Bánh mì chuyển ngữ — live translation subtitles, powered by Gemma 4
Bánh mì chuyển ngữ — Gemma 4 E4B Fine-Tuned with Unsloth QLoRA
Competition:The Gemma 4 Good Hackathon on Kaggle Tracks: Digital Equity & Inclusivity (primary) · Unsloth ($10K) · Future of Education Framework:Unsloth — 2× faster fine-tuning Base model:google/gemma-4-e4b-it (4B params, instruction-tuned)
This adapter powers Bánh mì chuyển ngữ ("Trans-Bread"), a macOS application that captures any audio playing on a user's device and renders it as live translated subtitles in a floating, click-through overlay — fully on-device, in 16 languages. Built for the 300M+ people worldwide who live in a country where they don't speak the dominant language.
Highlights
99.6% training loss reduction — from 2.916 (baseline) to 0.0115 (final)
5 epochs of QLoRA fine-tuning on 10,000 high-quality samples
Only 2.29% of parameters trained (146.8M / 6.4B) via rank-stabilized LoRA
~12 hours total training on a single NVIDIA L4 GPU (24 GB)
Deployed on-device via Apple MLX 4-bit on Apple Silicon — no cloud, no API keys
Use Case
The fine-tuned model is paired with the mlx-vlm runtime in a native macOS Swift app. ScreenCaptureKit captures system audio, a hysteresis VAD segments utterances, and a single-pass Gemma prompt produces the translated subtitle. End-to-end latency is sub-2 seconds, fully offline.
How to Use
With Unsloth (recommended)
python
1from unsloth import FastModel
23model, tokenizer = FastModel.from_pretrained(4"bradduy/banhmi-gemma4-e4b",5 max_seq_length=2048,6 load_in_4bit=True,7)8FastModel.for_inference(model)910messages =[11{"role":"user","content":"Translate to Vietnamese: The doctor will see you now."}12]1314inputs = tokenizer.apply_chat_template(15 messages, tokenize=True, add_generation_prompt=True, return_tensors="pt"16).to("cuda")1718outputs = model.generate(19 input_ids=inputs,20 max_new_tokens=128,21 temperature=0.3,22 do_sample=True,23)24print(tokenizer.decode(outputs[0][inputs.shape[1]:], skip_special_tokens=True))
1# Download the recommended Q4_K_M build2hf download bradduy/banhmi-gemma4-e4b banhmi-gemma4.Q4_K_M.gguf --local-dir .34# Build + run with Ollama5ollama create banhmi-gemma4 -f Modelfile
6ollama run banhmi-gemma4
The accompanying Modelfile uses the Gemma 4 chat template and ships a translation-specific system prompt out of the box. To switch to the smaller Q3_K_S variant, change the FROM line in the Modelfile.
Supported Languages (16)
English · Vietnamese · Spanish · Chinese (Simplified) · Japanese · Korean · French · German · Portuguese · Russian · Arabic · Hindi · Indonesian · Thai · Italian · Turkish
For the macOS app we use a smaller MLX-quantized variant of the family: unsloth/gemma-4-E2B-it-UD-MLX-4bit, which fits comfortably on Apple Silicon and produces sub-2-second per-utterance latency. The fine-tuned adapter in this repository targets the larger E4B variant for cloud/Ollama inference.
macOS App Source (apps/macos/)
The full Swift source for the Bánh mì chuyển ngữ menu-bar app is included in this repository under apps/macos/: