File size: 10,503 Bytes
49cbdd2
 
 
 
 
 
 
 
472c41f
 
 
 
 
 
 
49cbdd2
 
472c41f
49cbdd2
472c41f
49cbdd2
472c41f
49cbdd2
472c41f
49cbdd2
472c41f
 
 
 
49cbdd2
472c41f
49cbdd2
472c41f
49cbdd2
472c41f
49cbdd2
472c41f
49cbdd2
472c41f
 
 
 
 
 
49cbdd2
472c41f
 
 
 
 
 
 
49cbdd2
472c41f
49cbdd2
472c41f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49cbdd2
472c41f
49cbdd2
472c41f
49cbdd2
472c41f
49cbdd2
472c41f
 
 
 
 
 
 
 
 
49cbdd2
472c41f
49cbdd2
472c41f
 
 
 
 
 
49cbdd2
472c41f
 
 
49cbdd2
472c41f
49cbdd2
472c41f
49cbdd2
472c41f
49cbdd2
472c41f
 
 
 
 
 
 
 
 
 
 
49cbdd2
472c41f
49cbdd2
472c41f
 
 
 
 
 
49cbdd2
472c41f
 
 
49cbdd2
472c41f
49cbdd2
472c41f
49cbdd2
472c41f
49cbdd2
472c41f
 
 
 
 
 
 
49cbdd2
472c41f
49cbdd2
472c41f
49cbdd2
472c41f
 
 
 
 
 
49cbdd2
472c41f
 
 
 
 
49cbdd2
472c41f
 
 
 
 
49cbdd2
472c41f
49cbdd2
472c41f
49cbdd2
472c41f
 
 
 
 
49cbdd2
472c41f
 
 
 
49cbdd2
472c41f
 
 
 
 
49cbdd2
472c41f
49cbdd2
472c41f
49cbdd2
472c41f
 
49cbdd2
472c41f
 
49cbdd2
472c41f
 
 
 
49cbdd2
472c41f
 
 
 
49cbdd2
472c41f
 
 
49cbdd2
472c41f
 
49cbdd2
472c41f
49cbdd2
472c41f
49cbdd2
472c41f
49cbdd2
472c41f
 
 
 
49cbdd2
472c41f
 
 
 
 
 
49cbdd2
472c41f
 
 
 
49cbdd2
472c41f
49cbdd2
472c41f
 
 
49cbdd2
472c41f
 
 
 
 
 
49cbdd2
472c41f
 
 
 
 
 
49cbdd2
472c41f
49cbdd2
472c41f
49cbdd2
472c41f
49cbdd2
472c41f
 
 
 
 
 
49cbdd2
472c41f
49cbdd2
472c41f
49cbdd2
472c41f
 
 
 
49cbdd2
472c41f
 
 
 
49cbdd2
472c41f
49cbdd2
472c41f
49cbdd2
472c41f
49cbdd2
472c41f
49cbdd2
472c41f
49cbdd2
472c41f
49cbdd2
472c41f
49cbdd2
472c41f
49cbdd2
472c41f
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
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
---
base_model: Qwen/Qwen2.5-Coder-1.5B-Instruct
library_name: peft
pipeline_tag: text-generation
tags:
- base_model:adapter:Qwen/Qwen2.5-Coder-1.5B-Instruct
- lora
- transformers
- myanmar
- burmese
- llm
- qwen
- text-generation
- instruction-tuning
license: apache-2.0
---

<div align="center">

# πŸ‡²πŸ‡² Myanmar-Ghost-Instruct-LoRA

**Myanmar Language Instruction-Tuned LLM based on Qwen2.5-Coder-1.5B-Instruct**

*A lightweight LoRA adapter for Myanmar language text generation and instruction following*

[![Model Size](https://img.shields.io/badge/Size-74MB-blue)](https://huggingface.co/amkyawdev/Myanmar-Ghost-Instruct-LoRA)
[![Base Model](https://img.shields.io/badge/Base-Qwen2.5--Coder--1.5B--Instruct-green)](https://huggingface.co/Qwen/Qwen2.5-Coder-1.5B-Instruct)
[![PEFT](https://img.shields.io/badge/PEFT-0.19.1-orange)](https://github.com/huggingface/peft)
[![License](https://img.shields.io/badge/License-Apache--2.0-yellow)](LICENSE)

</div>

---

## πŸ“Œ Model Overview

Myanmar-Ghost-Instruct-LoRA is a **LoRA (Low-Rank Adaptation)** adapter trained on **[Qwen/Qwen2.5-Coder-1.5B-Instruct](https://huggingface.co/Qwen/Qwen2.5-Coder-1.5B-Instruct)** to enhance Myanmar (Burmese) language understanding and generation capabilities.

### Key Features
- 🐍 **Lightweight**: Only ~74MB (LoRA adapter)
- πŸ‡²πŸ‡² **Myanmar-First**: Optimized for Burmese text generation
- πŸ’» **Code Capable**: Base model retains code generation abilities
- ⚑ **Fast Inference**: Low-rank adaptation for efficient deployment
- πŸ”§ **Easy Integration**: Compatible with PEFT and Transformers libraries

### Model Tree
```
Qwen/Qwen2.5-1.5B
└── Qwen/Qwen2.5-Coder-1.5B
    └── Qwen/Qwen2.5-Coder-1.5B-Instruct
        └── amkyawdev/Myanmar-Ghost-Instruct-LoRA βœ… (this model)
```

---

## πŸš€ Quick Start

### Using PEFT (Recommended)

```python
from peft import PeftModel
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch

# Load base model and tokenizer
base_model = AutoModelForCausalLM.from_pretrained(
    "Qwen/Qwen2.5-Coder-1.5B-Instruct",
    device_map="auto",
    torch_dtype=torch.float16,
    trust_remote_code=True
)

tokenizer = AutoTokenizer.from_pretrained(
    "Qwen/Qwen2.5-Coder-1.5B-Instruct",
    trust_remote_code=True
)

# Load LoRA adapter
model = PeftModel.from_pretrained(
    base_model, 
    "amkyawdev/Myanmar-Ghost-Instruct-LoRA"
)

# Generate text
messages = [
    {"role": "user", "content": "မြန်မာစာတစ်ပိုဒ် ရေးပါ။"}
]
text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer([text], return_tensors="pt").to(model.device)

outputs = model.generate(
    **inputs,
    max_new_tokens=512,
    temperature=0.7,
    top_p=0.9
)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
```

### Using Transformers Pipeline

```python
from transformers import pipeline

pipe = pipeline(
    "text-generation",
    model="amkyawdev/Myanmar-Ghost-Instruct-LoRA",
    model_kwargs={"device_map": "auto", "torch_dtype": "float16"}
)

messages = [
    {"role": "user", "content": "မြန်မာစာတစ်ပိုဒ် ရေးပါ။"}
]
output = pipe(messages, max_new_tokens=512, temperature=0.7)
print(output[0]["generated_text"])
```

### Using vLLM

```bash
# Install vLLM
pip install vllm

# Start server
vllm serve "amkyawdev/Myanmar-Ghost-Instruct-LoRA" --dtype float16

# API call
curl -X POST "http://localhost:8000/v1/chat/completions" \
  -H "Content-Type: application/json" \
  --data '{
    "model": "amkyawdev/Myanmar-Ghost-Instruct-LoRA",
    "messages": [{"role": "user", "content": "မြန်မာစာတစ်ပိုဒ် ရေးပါ။"}]
  }'
```

---

## πŸ“Š Technical Specifications

### LoRA Configuration

| Parameter | Value |
|-----------|-------|
| **PEFT Type** | LORA |
| **Rank (r)** | 16 |
| **Alpha** | 32 |
| **Dropout** | 0.05 |
| **Target Modules** | q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj |
| **Bias** | none |
| **Task Type** | CAUSAL_LM |

### Tokenizer

| Property | Value |
|----------|-------|
| **Tokenizer Class** | Qwen2Tokenizer |
| **Model Max Length** | 32,768 tokens |
| **Special Tokens** | `<|im_start|>`, `<|im_end|>` |
| **Padding Token** | `<|im_end|>` |

### Adapter File Size
- **adapter_model.safetensors**: ~74 MB
- **Total model size (with base)**: ~3-4 GB

---

## πŸ‹οΈ Training Details

### Training Hyperparameters

| Parameter | Value |
|-----------|-------|
| **Total Steps** | 200 |
| **Save Steps** | 100 |
| **Batch Size** | 1 |
| **Max Steps per Epoch** | 12,500 (estimated) |
| **Training Epochs** | 1 |
| **Max Learning Rate** | 2e-4 (warmup) |
| **Final Learning Rate** | ~5.2e-8 |
| **Training Framework** | PEFT 0.19.1 |
| **Base Model** | Qwen2.5-Coder-1.5B-Instruct |

### Training Progress

| Step | Loss | Learning Rate | Grad Norm |
|------|------|---------------|-----------|
| 1 | 12.01 | 0.0 | 6.93 |
| 50 | ~2.5 | ~1e-4 | ~3.0 |
| 100 | ~1.5 | ~5e-5 | ~2.5 |
| 200 (final) | 1.91 | 5.2e-8 | 2.66 |

### Available Checkpoints
- `checkpoint-100/` - Model at step 100
- `checkpoint-200/` - Final model at step 200

---

## πŸ“š Training Data

This model was trained on Myanmar language instruction datasets including:

- **Myanmar V3 Clean Dataset** ([amkyawdev/myanmar-v3-clean](https://huggingface.co/datasets/amkyawdev/myanmar-v3-clean))
  - ~878K samples
  - Cleaned and quality-filtered Myanmar text
  
- **AMK Coder V3 Dataset V2** ([amkyawdev/amk-coder-v3-dataset-v2](https://huggingface.co/datasets/amkyawdev/amk-coder-v3-dataset-v2))
  - ~1.01M samples
  - Code and natural language instruction pairs

---

## 🎯 Intended Uses

### Direct Use Cases
- βœ… Myanmar language text generation
- βœ… Burmese language conversation
- βœ… Translation assistance (Myanmar ↔ other languages)
- βœ… Text summarization in Burmese
- βœ… Code generation assistance (preserved from base model)

### Downstream Use Cases
- πŸ”§ Fine-tuning for specific Myanmar NLP tasks
- πŸ”§ Domain-specific applications (healthcare, legal, education)
- πŸ”§ Chatbot development for Burmese speakers
- πŸ”§ Research on low-resource language LLMs

### Out-of-Scope Uses
- ⚠️ Medical or legal advice without human verification
- ⚠️ High-stakes decision-making systems
- ⚠️ Production systems without thorough evaluation
- ⚠️ Generating harmful or misleading content

---

## ⚠️ Bias, Risks, and Limitations

### Technical Limitations
1. **Model Size**: 1.5B parameters may limit performance on complex tasks
2. **Training Steps**: Limited training (200 steps) may affect instruction-following quality
3. **Token Limit**: 32,768 context window
4. **Resource Requirements**: GPU recommended for inference

### Sociotechnical Considerations
1. **Language Coverage**: Optimized primarily for Burmese; may vary for regional dialects
2. **Cultural Bias**: Training data may reflect specific cultural perspectives
3. **Safety**: As with any LLM, outputs should be verified before critical use

### Recommendations
- Evaluate on your specific use case before production deployment
- Implement appropriate content filtering
- Provide human oversight for sensitive applications
- Consider fine-tuning for domain-specific tasks

---

## πŸ“ˆ Evaluation

### Evaluation Status
⚠️ **Formal benchmark evaluation pending.** The model has not been systematically evaluated on standard NLP benchmarks yet.

### Recommended Evaluation Tasks
If you evaluate this model, consider the following benchmarks:

1. **Myanmar NLP Tasks**
   - Myanmar text classification
   - Sentiment analysis (Burmese)
   - Named entity recognition

2. **General Language Tasks**
   - MMLU (Multilingual Massive Multitask)
   - Hellaswag
   - TruthfulQA

3. **Code Generation** (inherited from base model)
   - HumanEval
   - MBPP

### User Feedback
We welcome community feedback! Please share your evaluation results and use cases in the [Discussions](https://huggingface.co/amkyawdev/Myanmar-Ghost-Instruct-LoRA/discussions) tab.

---

## πŸ”§ Merge and Deploy

### Merge LoRA with Base Model

```python
from peft import PeftModel
from transformers import AutoModelForCausalLM
import torch

base_model = AutoModelForCausalLM.from_pretrained(
    "Qwen/Qwen2.5-Coder-1.5B-Instruct",
    device_map="cpu",
    torch_dtype=torch.float32,
)
model = PeftModel.from_pretrained(base_model, "amkyawdev/Myanmar-Ghost-Instruct-LoRA")

# Merge adapter weights
merged_model = model.merge_and_unload()
merged_model.save_pretrained("merged-model")
```

### Quantization for Deployment

```python
# 4-bit quantization with GGUF
from transformers import AutoModelForCausalLM, BitsAndBytesConfig

quantization_config = BitsAndBytesConfig(
    load_in_4bit=True,
    bnb_4bit_use_double_quant=True,
    bnb_4bit_quant_type="nf4",
    bnb_4bit_compute_dtype=torch.float16
)

model = AutoModelForCausalLM.from_pretrained(
    "amkyawdev/Myanmar-Ghost-Instruct-LoRA",
    quantization_config=quantization_config,
    device_map="auto"
)
```

---

## 🌐 Related Models

Explore more models from the author:

| Model | Description |
|-------|-------------|
| [Myanmar-Ghost-Instruct-GGUF](https://huggingface.co/amkyawdev/Myanmar-Ghost-Instruct-GGUF) | GGUF format for local inference |
| [myanmar-ai-v3](https://huggingface.co/amkyawdev/myanmar-ai-v3) | Full model version |
| [qwen2.5-myanmar-ai-adapter](https://huggingface.co/amkyawdev/qwen2.5-myanmar-ai-adapter) | Alternative adapter |
| [amk-coder-v2](https://huggingface.co/amkyawdev/amk-coder-v2) | Coding-focused model |

---

## πŸ“ž Contact & Support

- **Author**: [Aung Myo Kyaw (amkyawdev)](https://huggingface.co/amkyawdev)
- **Website**: [amkyaw-ai.vercel.app](https://amkyaw-ai.vercel.app)
- **GitHub**: [github.com/AmkyawDev](https://github.com/AmkyawDev)
- **Demo**: [Myanmar AI V3 Demo](https://huggingface.co/spaces/amkyawdev/myanmar-ai-v3-demo)

### Framework Versions
- **PEFT**: 0.19.1
- **Transformers**: Compatible with latest version
- **PyTorch**: Recommended 2.0+

---

## πŸ“„ License

This adapter is released under the **Apache 2.0 License**.

The base model [Qwen/Qwen2.5-Coder-1.5B-Instruct](https://huggingface.co/Qwen/Qwen2.5-Coder-1.5B-Instruct) is licensed by Alibaba Cloud and subject to its terms.

---

<div align="center">

**Made with ❀️ for the Myanmar AI community**

*This model card was created to improve transparency and reproducibility.*

</div>