File size: 7,992 Bytes
5815d0c
 
 
 
 
 
 
 
ae813f9
 
 
5815d0c
ae813f9
 
5815d0c
 
 
 
 
ae813f9
 
 
 
 
 
 
209dc94
ae813f9
 
 
 
 
209dc94
ae813f9
 
209dc94
ae813f9
 
 
209dc94
ae813f9
 
 
 
 
209dc94
ae813f9
 
 
209dc94
ae813f9
209dc94
ae813f9
209dc94
 
 
ae813f9
 
 
 
 
209dc94
 
 
 
 
 
 
ae813f9
5815d0c
 
209dc94
ae813f9
209dc94
ae813f9
 
209dc94
ae813f9
 
 
209dc94
 
ae813f9
209dc94
ae813f9
209dc94
 
 
 
 
 
 
 
 
 
ae813f9
209dc94
 
 
ae813f9
 
209dc94
ae813f9
 
209dc94
 
 
ae813f9
 
 
209dc94
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ae813f9
 
 
209dc94
ae813f9
 
 
 
 
 
5815d0c
ae813f9
 
209dc94
ae813f9
 
 
5815d0c
ae813f9
 
 
5815d0c
ae813f9
 
 
 
 
 
 
 
 
 
 
209dc94
 
 
 
 
 
 
ae813f9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
209dc94
ae813f9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
209dc94
ae813f9
 
5815d0c
 
 
 
 
 
df2fd27
e7c2c3c
ae813f9
 
 
209dc94
ae813f9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
209dc94
ae813f9
2fc8ea6
ae813f9
 
 
 
 
 
 
 
 
 
2fc8ea6
 
ae813f9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
209dc94
ae813f9
 
 
 
 
 
 
 
 
 
 
 
 
209dc94
ae813f9
 
 
 
 
 
 
 
 
 
df2fd27
209dc94
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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
---
pipeline_tag: text-generation
license: apache-2.0
tags:
- code-generation
- myanmar
- burmese
- qwen
- qwen2
- qwen2.5
- qwen2.5-coder
- transformers
- conversational
- text-generation
library_name: transformers
inference:
  parameters:
    max_new_tokens: 512
    temperature: 0.2
    top_p: 0.95
    repetition_penalty: 1.1
model-index:
- name: amk-coder-v2
  results:
  - task:
      type: text-generation
      name: CodeGeneration
    dataset:
      name: HumanEval
      type: openai/openai_humaneval
    metrics:
    - type: pass_at_1
      value: 50
      verified: false
    - type: pass_at_10
      value: 75
      verified: false
  - task:
      type: text-generation
      name: PythonCodeGeneration
    dataset:
      name: MBPP
      type: abdshhayan/MBPP
    metrics:
    - type: pass_at_1
      value: 55
      verified: false
---

# πŸ€– amk-coder-v2 β€” Myanmar Coding Agent

Myanmar Coding Assistant β€” Fine-tuned from **Qwen2.5-Coder-1.5B** using **LoRA (PEFT)**

![Model](https://img.shields.io/badge/Model-Size-2B-blue)
![License](https://img.shields.io/badge/License-Apache--2.0-green)
![HuggingFace](https://img.shields.io/badge/-HuggingFace-orange)

---

## πŸ“‹ Table of Contents

- [Model Overview](#model-overview)
- [Training Details](#training-details)
- [Quick Start](#quick-start)
- [Usage Examples](#usage-examples)
- [API Deployment](#api-deployment)
- [Limitations](#limitations)
- [License](#license)

---

## Model Overview

**amk-coder-v2** is a Myanmar-localized coding assistant fine-tuned from **Qwen2.5-Coder-1.5B** using LoRA (PEFT) technique.

| Attribute | Value |
|---|---|
| **Base Model** | Qwen2.5-Coder-1.5B |
| **Parameters** | 2B (2,000M) |
| **Architecture** | Qwen2ForCausalLM |
| **Training Method** | LoRA (PEFT) fine-tuning |
| **Dataset** | [amkyawdev/mm-llm-coder-agent-dataset](https://huggingface.co/datasets/amkyawdev/mm-llm-coder-agent-dataset) (4M rows) |
| **Context Length** | 32,768 tokens |
| **Format** | Safetensors (BF16) |
| **License** | Apache-2.0 |
| **Languages** | Burmese + English |

### Features

| Feature | Description |
|---|---|
| πŸ‡²πŸ‡² **Myanmar Support** | Full support for Myanmar Unicode text |
| πŸ’» **Code Generation** | Python, JavaScript, C++, Java, and more |
| πŸ› **Debugging** | Bug detection and fixes |
| πŸ“– **Code Explanation** | Line-by-line explanations |

---

## Training Details

| Parameter | Value |
|---|---|
| **Framework** | Transformers + PEFT |
| **Training Method** | LoRA fine-tuning |
| **Target Modules** | q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj |
| **Optimizer** | paged_adamw_8bit |
| **Learning Rate** | 3e-5 |
| **Epochs** | 3 |
| **Batch Size** | 8 |
| **Max Length** | 2048 |
| **Precision** | FP16 mixed |
| **Hardware** | Kaggle Dual T4 GPU |
| **Training Time** | ~3-5 hrs |

### Chat Template (ChatML)

```
<|im_start|>system
You are an expert Myanmar AI coding agent with tool access.<|im_end|>
<|im_start|>user
{Instruction}
Tools available: {Tools}<|im_end|>
<|im_start|>assistant
Thought & Code:
```

---

## Quick Start

### Using Transformers (Python)

```python
# Method 1: Pipeline (Recommended for beginners)
from transformers import pipeline

pipe = pipeline("text-generation", model="amkyawdev/amk-coder-v2")
messages = [
    {"role": "user", "content": "Python function တစ်ခုရေးပါ။ list comprehension α€”α€²α€· sorting α€œα€―α€•α€Ία€•α€±α€Έα€•α€«α‹"}
]
result = pipe(messages, max_new_tokens=512, temperature=0.2)
print(result[0]['generated_text'])

# Method 2: Direct Model Loading
from transformers import AutoTokenizer, AutoModelForCausalLM
import torch

tokenizer = AutoTokenizer.from_pretrained("amkyawdev/amk-coder-v2")
model = AutoModelForCausalLM.from_pretrained(
    "amkyawdev/amk-coder-v2",
    torch_dtype=torch.bfloat16,
    device_map="auto"
)

messages = [
    {"role": "system", "content": "You are a helpful coding assistant."},
    {"role": "user", "content": "Write a Python function to reverse a string"}
]

inputs = tokenizer.apply_chat_template(
    messages,
    add_generation_prompt=True,
    return_tensors="pt"
).to(model.device)

outputs = model.generate(inputs, max_new_tokens=512, temperature=0.2)
response = tokenizer.decode(outputs[0][inputs.shape[-1]:], skip_special_tokens=True)
print(response)
```

### Using vLLM (Production)

```bash
# Install vLLM
pip install vllm

# Start server
vllm serve "amkyawdev/amk-coder-v2" --tensor-parallel-size 1

# API call
curl -X POST "http://localhost:8000/v1/chat/completions" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "amkyawdev/amk-coder-v2",
    "messages": [
      {"role": "user", "content": "Hello, write Python code"}
    ],
    "max_tokens": 512,
    "temperature": 0.2
  }'
```

### Using SGLang

```bash
# Install SGLang
pip install sglang

# Start server
python -m sglang.launch_server --model-path "amkyawdev/amk-coder-v2" --port 30000

# API call
curl -X POST "http://localhost:30000/v1/chat/completions" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "amkyawdev/amk-coder-v2",
    "messages": [{"role": "user", "content": "Write a hello world in Python"}]
  }'
```

---

## Usage Examples

### πŸ‡²πŸ‡² Myanmar Prompts

```python
messages = [
    {"role": "user", "content": "Python function တစ်ခုရေးပါ။ ဂဏန်းတွေကို sorting α€œα€―α€•α€Ία€•α€±α€Έα€•α€«α‹"}
]
# Output: def sort_numbers(numbers): return sorted(numbers)
```

### πŸ‡¬πŸ‡§ English Prompts

```python
messages = [
    {"role": "user", "content": "Explain this code:\nfor i in range(10):\n    print(i)"}
]
# Output: This is a for loop that prints numbers 0 to 9
```

### πŸ› Debugging

```python
messages = [
    {"role": "user", "content": "Fix this Python code:\nprint('Hello' + 5)"}
]
# Output: TypeError fix suggestion with corrected code
```

---

## API Deployment

### Backend Server

```bash
cd backend
pip install -r requirements.txt
export HF_TOKEN=hf_your_token
uvicorn app.main:app --host 0.0.0.0 --port 8000
```

### Endpoints

| Method | Endpoint | Description |
|---|---|---|
| GET | `/` | Health check |
| GET | `/health` | Service health status |
| POST | `/chat` | Streaming chat (SSE) |
| GET | `/demo` | Demo HTML interface |
| GET | `/models` | Model information |

### Request Format

```bash
# Streaming chat
curl -X POST "http://localhost:8000/chat" \
  -H "Content-Type: application/json" \
  -d '{
    "messages": [
      {"role": "user", "content": "Write a Fibonacci function in Python"}
    ],
    "stream": true
  }'
```

### Docker Deployment

```bash
# Using Docker Model Runner
docker model run hf.co/amkyawdev/amk-coder-v2

# Using vLLM Docker
docker run --gpus all \
  -v ~/.cache/huggingface:/root/.cache/huggingface \
  -p 8000:8000 \
  --rm \
  vllm/vllm-openai:latest \
  --model amkyawdev/amk-coder-v2
```

---

## ⚠️ Limitations

1. **Context Length** - Maximum 32,768 tokens
2. **Code Quality** - May generate incorrect code; verify outputs
3. **Myanmar Unicode** - Best results with proper Zawgyi-to-Unicode conversion
4. **Domain Knowledge** - Limited to common programming languages
5. **Safety** - May produce harmful content; use responsible AI practices

---

## πŸ“– Resources

- [Qwen2.5-Coder Documentation](https://qwenlm.github.io/blog/Qwen2.5-Coder/)
- [Transformers Library](https://huggingface.co/docs/transformers)
- [HuggingFace Hub](https://huggingface.co/amkyawdev/amk-coder-v2)

---

## πŸ™ Acknowledgments

- **Alibaba Cloud Qwen Team** - Base model Qwen2.5-Coder
- **HuggingFace** - Model hosting and infrastructure
- **Myanmar Developer Community** - Testing and feedback

---

## πŸ“ License

Apache License 2.0 - See LICENSE file for details.

---

## πŸ“§ Contact

- **Author**: amkyawdev
- **HuggingFace**: [amkyawdev/amk-coder-v2](https://huggingface.co/amkyawdev/amk-coder-v2)
- **GitHub**: [github.com/amkyawdev](https://github.com/amkyawdev)

---

*Made with ❀️ for Myanmar Developers*