File size: 9,783 Bytes
3b397e8
0a4cfed
 
c9234fc
0a4cfed
 
c9234fc
0a4cfed
 
 
 
 
 
 
 
 
 
 
 
 
 
3b397e8
 
c9234fc
3b397e8
d66ee3d
0a4cfed
2c97b04
 
 
 
 
 
 
 
7254b4d
0130afa
 
 
0b6161b
eab8f10
0b6161b
0130afa
0b6161b
0a4cfed
0b6161b
 
0a4cfed
0130afa
3b397e8
0b6161b
 
 
 
eab8f10
0b6161b
 
 
 
eab8f10
3b397e8
c9234fc
 
3b397e8
 
 
c9234fc
3b397e8
 
 
c9234fc
3b397e8
c9234fc
3b397e8
 
 
 
 
c9234fc
 
 
 
 
3b397e8
 
 
3e103ff
c9234fc
3e103ff
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c9234fc
3e103ff
3b397e8
c9234fc
3b397e8
 
 
c9234fc
3b397e8
c9234fc
3b397e8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3e103ff
3b397e8
 
 
 
c9234fc
3b397e8
 
 
c9234fc
3b397e8
 
 
c9234fc
 
3b397e8
15ea4a4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ef41217
 
 
15ea4a4
3b397e8
15ea4a4
c9234fc
d66ee3d
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
---
pipeline_tag: text-generation
library_name: transformers
language:
  - my
  - en
license: mit
base_model: google/gemma-3-4b-it
datasets:
  - WYNN747/burmese-mbpp
  - WYNN747/burmese-human-eval
tags:
  - burmese
  - myanmar
  - code-generation
  - coding-assistant
  - low-resource-language
  - llm
  - gemma-3
  - dpo
  - sft
---

# Burmese Coder 🏹🔥 

Created by Dr. Wai Yan Nyein Naing, a Myanmar AI researcher specializing in Burmese language AI, low-resource LLMs, and practical AI systems. Related work includes Burmese GPT, an open Burmese foundation model for the research and developer community.

**Author:** Dr. Wai Yan Nyein Naing  
**Focus:** Burmese code generation + technical explanation  
**Base model:** Gemma 3 4B  
**Languages:** Burmese, English  
**Best for:** Burmese coding tasks, low-resource LLM evaluation  
**Paper:** [Burmese-Coder-4B Paper](https://waiyannyeinnaing.github.io/assets/pdf/burmese_coder_4b.pdf)  
**Datasets:** burmese-mbpp, burmese-human-eval  
**Related repos:** GGUF, MLX, Burmese-GPT
 

## 🚀 How to Use (Local Inference)

This model is exported in **GGUF (Q8_0)** format and is optimized for local execution via **Ollama**. Follow these three simple steps to set it up:

**1. Download the GGUF Model & Modelfile**:
```bash
# Download the GGUF weights
huggingface-cli download WYNN747/burmese-coder-4b gemma-3n-e4b-it.Q8_0.gguf --local-dir . --local-dir-use-symlinks False

# Download the Modelfile
curl -L https://huggingface.co/WYNN747/burmese-coder-4b/resolve/main/Modelfile -o Modelfile
```

**2. Register the Model**:
```bash
ollama create burmese_coder_4b -f Modelfile
```

**3. Run and Test**:
```bash
ollama run burmese_coder_4b
```

## 📖 Model Description

**Burmese Coder** is a state-of-the-art, fine-tuned large language model specifically optimized for professional technical software development and programming assistance in the **Burmese language**. Built on top of the powerful Gemma-3 4B architecture, this model bridges the gap for Myanmar developers by providing highly accurate, conversational, and culturally nuances technical explanations without language barriers.

The model underwent rigorous training phases, starting with Supervised Fine-Tuning (SFT) on an enriched MBPP (Mostly Basic Python Problems) dataset translated and expanded with step-by-step Burmese explanations. To ensure linguistic purity and eliminate multilingual hallucinations, the model was ultra-hardened using Direct Preference Optimization (DPO) with targeted On-Policy Rejections.

### Best-Suited Uses
- **Educational Exploration:** Learning and experimenting with fine-tuned Small Language Models (SLMs) tailored for the Burmese language.
- **Code Generation & Prompt Testing:** Evaluating the model's ability to write scripts and algorithms based on Burmese instructions in a controlled environment.
- **Academic Research:** Serving as a baseline or case study for localized, non-English programming assistants.
- **Local Prototyping:** Optimized for edge deployment and local inference testing via Ollama / GGUF on consumer hardware (macOS/Windows/Linux).

### Out-of-Scope & Limitations
- **Not for Production or Commercial Use:** The model is an experimental research prototype. Its outputs must not be relied upon for production environments or commercial software systems.
- **Domain Restriction:** The model's primary focus strictly remains on programming and software engineering. General-purpose conversations outside technical domains may not be robust or highly coherent.

## 🛠️ Training Details

### Training Paradigm
1. **Supervised Fine-Tuning (SFT):** Initial instruction fine-tuning to teach the model structured technical problem-solving and accurate Burmese translation.
2. **Preference Alignment (DPO):** Phase 4 ultra-hardening using Direct Preference Optimization (Beta=0.5). This phase utilized custom-generated hallucination datasets to heavily penalize language drift and reinforce strict Burmese linguistic consistency.

### Dataset
- **MBPP Enriched:** 974-sample Mostly Basic Python Problems, augmented with extremely detailed, step-by-step Burmese explanations.
- **Hallucination Rejection DPO:** A curated dataset constructed to identify and reject mixed-language outputs.

## 📊 Benchmarks
Burmese-Coder-4B was evaluated using a two-track framework: **Functional Correctness (Pass@1)** and **Language-Aware Quality (LLM-as-a-Judge)**.

### Functional & Linguistic Performance
| Model | Pass@1 (%) | Rubric (DeepSeek) | Rubric (Gemini) |
| :--- | :---: | :---: | :---: |
| **Burmese-Coder-4B** | **62.0** | **3.456** | **3.779** |
| Gemma-3 4B (Base) | 62.0 | 2.939 | 3.203 |
| Qwen 2.5 3B | 45.0 | 1.220 | 2.526 |

### Visual Performance Comparison
![Benchmarks](benchmarks.png)

### Linguistic Stability (Mixed-Language Penalty)
*Lower is better. Measures resistance to script mixing and token drift.*
- **Burmese-Coder-4B**: **0.02** (Gemini) / **0.09** (DeepSeek)
- Gemma-3 4B: 0.69 (Gemini) / 0.72 (DeepSeek)
- Qwen 2.5 3B: 1.37 (Gemini) / 1.18 (DeepSeek)

> [!NOTE]
> **Key Finding:** Burmese-Coder-4B maintains the full functional power of the base model while drastically reducing mixed-language hallucinations and improving technical terminal accuracy in Burmese.

## 💬 Example Output

Here is a sample interaction showcasing the model's ability to seamlessly blend technical programming logic with professional Burmese explanations.

**User Prompt:**
> "Python မှာ Function တစ်ခု Error တက်သွားရင် သတ်မှတ်ထားတဲ့ အကြိမ်အရေအတွက်အတိုင်း ပြန်ကြိုးစားပေးမယ့် (Retry) Decorator တစ်ခုကို delay အချိန်နဲ့တကွ ရေးပြပါ။" 

**Burmese Coder Response:** *(The model generates both the executable code and the step-by-step explanation)*
```python
import time
from functools import wraps

def retry_on_failure(max_retries=3, delay=2):
    """
    Error တက်ခဲ့ပါက သတ်မှတ်ထားသော အကြိမ်အရေအတွက်အတိုင်း စောင့်ဆိုင်း၍ ပြန်ကြိုးစားမည့် Decorator
    """
    def decorator(func):
        @wraps(func)
        def wrapper(*args, **kwargs):
            for attempt in range(1, max_retries + 1):
                try:
                    return func(*args, **kwargs)
                except Exception as e:
                    print(f"[Error] Attempt {attempt} failed: {e}")
                    if attempt == max_retries:
                        raise e  # နောက်ဆုံးအကြိမ်တွင် Error ကို ပြန်လွှင့်မည်
                    time.sleep(delay)
        return wrapper
    return decorator

@retry_on_failure(max_retries=3, delay=2)
def unstable_api_call():
    # API ခေါ်ဆိုမှုတွင် Error ဖြစ်ပေါ်မှုကို စမ်းသပ်ရန်အတွက် ဖန်တီးထားသော လုပ်ဆောင်ချက် အတု
    raise ConnectionError("Server Timeout!")
```

**ရှင်းလင်းချက် (Explanation):**
```text
ဒီ code က အရည်အသွေးမြင့်တဲ့ Custom Decorator တစ်ခုကို `functools` ထဲက `wraps` နဲ့ တွဲဖက်တည်ဆောက်ထားတာ ဖြစ်ပါတယ်။ `retry_on_failure` ဆိုတဲ့ အပြင်ဆုံး function က `max_retries` နဲ့ `delay` parameter တွေကို လက်ခံပြီး အတွင်းပိုင်း logic ကို ထိန်းချုပ်ပေးပါတယ်။

`wrapper` အထဲမှာတော့ `try-except block` ကို အသုံးပြုပြီး Error တက်/မတက် စစ်ဆေးပါတယ်။ Error တက်ခဲ့ရင် `time.sleep(delay)` နဲ့ သတ်မှတ်ထားတဲ့ အချိန်စောင့်ပြီး နောက်တစ်ကြိမ် ပြန်ကြိုးစားပါတယ်။ အကယ်လို့ နောက်ဆုံးအကြိမ်အထိ Error ထပ်တက်နေသေးရင်တော့ မူလ Error ကိုပဲ `raise e` ဆိုပြီး ပြန်လွှင့်ပေးလိုက်ပါတယ်။
```

---

### Via llama.cpp or text-generation-webui
Simply download the `.gguf` file and load it using the standard `llama.cpp` pipeline. Choose the quantization level (e.g., Q4_K_M or Q8_0) that best fits your VRAM requirements.

## 📜 Citation
If you use Burmese Coder in your research or application, please cite the following paper:

```bibtex
@inproceedings{naing2026burmesecoder,
  title = {Burmese-Coder-4B: Fine-Tuning a Small Language Model for Burmese Coding with Language-Aware Evaluation},
  author = {Naing, Wai Yan Nyein},
  year = {2026},
  publisher = {GitHub Pages},
  url = {https://waiyannyeinnaing.github.io/assets/pdf/burmese_coder_4b.pdf},
  dataset = {https://huggingface.co/datasets/WYNN747/burmese-human-eval},
  dataset_mbpp = {https://huggingface.co/datasets/WYNN747/burmese-mbpp}
}
```

Find the full research paper here: [Burmese-Coder-4B Paper]
- https://www.waiyannyeinnaing.com/projects/burmese-coder-4b
- https://www.waiyannyeinnaing.com/whitepaper/burmese-coder-4b-paper.pdf

## ⚖️ License
This model is released under the **MIT License**.

## Related Work / Related Models
- https://huggingface.co/WYNN747/Burmese-GPT
- https://huggingface.co/WYNN747/burmese-coder-4b-SFT
- https://huggingface.co/WYNN747/burmese-coder-4b-mlx