DEV Community

Cover image for Darija Buddy: A Local Gemma-Powered Tutor for a Friend
Soufiane Zaari
Soufiane Zaari

Posted on

Darija Buddy: A Local Gemma-Powered Tutor for a Friend

Hacktoberfest Weekend Challenge: Build for a Friend Submission 🤝

The Friend & The Problem

Moving to Morocco as an international student comes with a unique linguistic hurdle: Moroccan Darija. While formal Arabic (MSA) or French might get you through official paperwork, everyday social life happens in Darija.

My university classmate, Alex, has been struggling to fit into group banter and daily conversations. He understands some basics, but when people talk fast or switch between Arabizi (Latin-script Darija using numbers like 3, 7, 9) and spoken phrases, he freezes.

Traditional language apps don't support Moroccan Darija well—they usually default to Modern Standard Arabic, which locals rarely speak on the street. Human tutoring is expensive, and practicing with friends can feel intimidating when you're afraid of making mistakes.

He needed a safe, patient, and conversational practice partner that speaks genuine Darija, understands phonetically typed Arabizi, and explains nuances in French.


What I Built: Darija Buddy 🇲🇦

Darija Buddy is a lightweight, local conversational tutor designed to help non-Moroccan beginners practice real-life Darija speech.

Key Capabilities:

  • Speaks authentic Darija: It avoids rigid Modern Standard Arabic and replies in natural Moroccan expressions.
  • Multilingual input handling: It comprehends Latin-script Darija (Arabizi), French, and standard Arabic.
  • Bilingual feedback loop: Whenever it introduces colloquial vocabulary or idioms, it appends concise pedagogical explanations in French.
  • Gentle error correction: If the learner makes a grammar or lexical slip, Darija Buddy reformulates the phrase constructively before keeping the conversation flowing.

Technical Architecture & How It Works

The whole project runs entirely offline on a personal laptop — no expensive cloud infrastructure needed.
+-----------------------------------------------------------+
| Local Machine |
| |
| +-------------------+ +--------------------+ |
| | Gradio Web UI | <------> | Ollama Runtime | |
| | (darija_buddy.py) | | (gemma3:4b Model) | |
| +-------------------+ +--------------------+ |
+-----------------------------------------------------------+

1. The Core Model: Google Gemma 3 (4B)

I selected Gemma 3 (4B) as the reasoning engine. For a compact 4B-parameter open-weight model, Gemma 3 showcases remarkable multilingual understanding, easily deciphering transliterated Arabizi and grasping cultural Moroccan idioms.

2. Local Inference with Ollama

Instead of relying on remote APIs with variable latency and pay-per-token pricing, the model runs via Ollama. The quantized 4B weights run smoothly on consumer hardware (CPU-only), keeping RAM consumption under ~4 GB.

3. Gradio Interface

The frontend is encapsulated in a single Python script using gradio.ChatInterface, making it instantly accessible in any local browser window at http://127.0.0.1:7860.

4. Pedagogical System Prompt Engineering

The behavior is governed by a system prompt (full prompt in darija_buddy.py on GitHub) enforcing: authentic Darija instead of MSA, short French explanations, Arabizi/French/English input handling, gentle error correction, and short conversational replies.

Demo & Interaction

Here is a practice session where the user initiates in Arabizi, receives natural conversational responses, and gets immediate French vocabulary breakdowns:


Why Open Innovation Matters for This Project
This project highlights why open-weight models and local inference triumph over proprietary closed APIs:

Zero Operational Cost: Language practice requires repetitive, daily micro-conversations. Running Gemma 3 locally means zero token costs, no API credits expiring, and no credit card requirements for students.
Total Privacy for the Learner: Practicing a new language involves vulnerability and personal conversations. All inference happens in-memory on the laptop; no conversation logs or personal data are ever uploaded to remote commercial servers.
Offline Reliability: University Wi-Fi and mobile data can be unpredictable. Darija Buddy works entirely on a plane, on a train, or in a cafe without an active internet connection.
Customizability: With open weights, I'm not locked into proprietary censorship or forced model upgrades. I can easily fine-tune Gemma on dialectal corpora or swap weights as newer open models release.
What My Friend Said
When I showed it to Alex on a video call:

"C'est magnifique... et ça va beaucoup m'aider à apprendre le Darija."

Prize Categories

  • Best Use of Gemma

Code Repository
The code is completely open-source and easy to reproduce:

GitHub Repository: https://github.com/SoufianeZaari/darija-buddy

Top comments (0)