Update model card with detailed documentation
Browse files
README.md
CHANGED
|
@@ -6,61 +6,148 @@ tags:
|
|
| 6 |
- llm
|
| 7 |
- code-generation
|
| 8 |
- fine-tuned
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
---
|
| 10 |
|
| 11 |
# mm-llm-coder-lite-v1
|
| 12 |
|
| 13 |
-
Myanmar LLM
|
| 14 |
|
| 15 |
-
##
|
| 16 |
|
| 17 |
-
This
|
|
|
|
|
|
|
| 18 |
|
| 19 |
- **Base Model**: microsoft/phi-2
|
|
|
|
|
|
|
| 20 |
- **Language**: Burmese (Myanmar)
|
| 21 |
-
- **Training Data**: amkyawdev/myanmar-llm-data
|
| 22 |
-
- **License**: MIT
|
| 23 |
|
| 24 |
-
## Training Details
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
-
|
| 27 |
-
-
|
| 28 |
-
|
| 29 |
-
-
|
| 30 |
-
|
|
|
|
| 31 |
|
| 32 |
-
## Dataset
|
|
|
|
|
|
|
|
|
|
| 33 |
|
| 34 |
-
|
| 35 |
-
- Coding (90%)
|
| 36 |
-
- Translation (1%)
|
| 37 |
-
- General (1%)
|
| 38 |
-
- Greeting (1%)
|
| 39 |
|
| 40 |
-
##
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
|
| 42 |
```python
|
| 43 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 44 |
|
|
|
|
| 45 |
model_name = "amkyawdev/mm-llm-coder-lite-v1"
|
| 46 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 47 |
model = AutoModelForCausalLM.from_pretrained(model_name)
|
| 48 |
|
| 49 |
# Generate response
|
| 50 |
-
input_text = "
|
|
|
|
| 51 |
inputs = tokenizer(input_text, return_tensors="pt")
|
| 52 |
outputs = model.generate(**inputs, max_new_tokens=100)
|
| 53 |
-
|
|
|
|
| 54 |
```
|
| 55 |
|
| 56 |
-
##
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
|
| 58 |
```
|
| 59 |
torch>=2.0.0
|
| 60 |
transformers>=4.35.0
|
| 61 |
peft>=0.7.0
|
|
|
|
|
|
|
|
|
|
| 62 |
```
|
| 63 |
|
| 64 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
|
| 66 |
-
|
|
|
|
| 6 |
- llm
|
| 7 |
- code-generation
|
| 8 |
- fine-tuned
|
| 9 |
+
- lora
|
| 10 |
+
- phi-2
|
| 11 |
+
datasets:
|
| 12 |
+
- amkyawdev/myanmar-llm-data
|
| 13 |
---
|
| 14 |
|
| 15 |
# mm-llm-coder-lite-v1
|
| 16 |
|
| 17 |
+
Myanmar Lightweight LLM for Code Generation and Conversation
|
| 18 |
|
| 19 |
+
## ๐ Overview
|
| 20 |
|
| 21 |
+
This is a fine-tuned lightweight LLM model for Myanmar (Burmese) language understanding, code generation, and conversational tasks. The model is based on [microsoft/phi-2](https://huggingface.co/microsoft/phi-2) and fine-tuned using LoRA technique.
|
| 22 |
+
|
| 23 |
+
## ๐๏ธ Architecture
|
| 24 |
|
| 25 |
- **Base Model**: microsoft/phi-2
|
| 26 |
+
- **Fine-tuning Method**: LoRA (Low-Rank Adaptation)
|
| 27 |
+
- **Training Framework**: Hugging Face Transformers + PEFT + TRL
|
| 28 |
- **Language**: Burmese (Myanmar)
|
|
|
|
|
|
|
| 29 |
|
| 30 |
+
## ๐ Training Details
|
| 31 |
+
|
| 32 |
+
| Parameter | Value |
|
| 33 |
+
|-----------|-------|
|
| 34 |
+
| Base Model | microsoft/phi-2 |
|
| 35 |
+
| Training Epochs | 3 |
|
| 36 |
+
| Learning Rate | 2e-4 |
|
| 37 |
+
| LoRA Rank (r) | 16 |
|
| 38 |
+
| LoRA Alpha | 32 |
|
| 39 |
+
| LoRA Dropout | 0.05 |
|
| 40 |
+
| Max Length | 512 |
|
| 41 |
+
| Batch Size | 4 |
|
| 42 |
+
| Gradient Accumulation | 4 |
|
| 43 |
+
|
| 44 |
+
## ๐ Dataset
|
| 45 |
+
|
| 46 |
+
Trained on [amkyawdev/myanmar-llm-data](https://huggingface.co/datasets/amkyawdev/myanmar-llm-data):
|
| 47 |
|
| 48 |
+
| Tag | Description |
|
| 49 |
+
|-----|-------------|
|
| 50 |
+
| coding | Programming conversations (90%) |
|
| 51 |
+
| translation | English-Myanmar translation (1%) |
|
| 52 |
+
| general | General knowledge Q&A (1%) |
|
| 53 |
+
| greeting | Burmese greetings (1%) |
|
| 54 |
|
| 55 |
+
### Dataset Statistics
|
| 56 |
+
- Train: ~20,327 samples
|
| 57 |
+
- Test: ~17,155 samples
|
| 58 |
+
- Validation: ~17,071 samples
|
| 59 |
|
| 60 |
+
## ๐ Quick Start
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
|
| 62 |
+
### Installation
|
| 63 |
+
|
| 64 |
+
```bash
|
| 65 |
+
pip install -r requirements.txt
|
| 66 |
+
```
|
| 67 |
+
|
| 68 |
+
### Fine-tuning
|
| 69 |
+
|
| 70 |
+
```bash
|
| 71 |
+
python finetune_mm_llm.py
|
| 72 |
+
```
|
| 73 |
+
|
| 74 |
+
### Inference
|
| 75 |
|
| 76 |
```python
|
| 77 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 78 |
|
| 79 |
+
# Load model
|
| 80 |
model_name = "amkyawdev/mm-llm-coder-lite-v1"
|
| 81 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 82 |
model = AutoModelForCausalLM.from_pretrained(model_name)
|
| 83 |
|
| 84 |
# Generate response
|
| 85 |
+
input_text = "System: แแแบแแแบ แแผแแบแแฌแ
แฌแแปแฝแแบแธแแปแแบแแฑแฌ AI แกแแฐแกแแฎแแฑแธแแฐแแผแ
แบแแแบแ\n\nUser: แแแบแนแแแฌแแซแ"
|
| 86 |
+
|
| 87 |
inputs = tokenizer(input_text, return_tensors="pt")
|
| 88 |
outputs = model.generate(**inputs, max_new_tokens=100)
|
| 89 |
+
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 90 |
+
print(response)
|
| 91 |
```
|
| 92 |
|
| 93 |
+
### Using with Transformers Pipeline
|
| 94 |
+
|
| 95 |
+
```python
|
| 96 |
+
from transformers import pipeline
|
| 97 |
+
|
| 98 |
+
pipe = pipeline(
|
| 99 |
+
"text-generation",
|
| 100 |
+
model="amkyawdev/mm-llm-coder-lite-v1",
|
| 101 |
+
tokenizer="amkyawdev/mm-llm-coder-lite-v1"
|
| 102 |
+
)
|
| 103 |
+
|
| 104 |
+
result = pipe("User: แแญแฏแแบแธแ แแฑแแฑแฌแแบแธแแฌแธแ")
|
| 105 |
+
print(result[0]['generated_text'])
|
| 106 |
+
```
|
| 107 |
+
|
| 108 |
+
## ๐ Requirements
|
| 109 |
|
| 110 |
```
|
| 111 |
torch>=2.0.0
|
| 112 |
transformers>=4.35.0
|
| 113 |
peft>=0.7.0
|
| 114 |
+
trl>=0.7.0
|
| 115 |
+
accelerate>=0.25.0
|
| 116 |
+
datasets>=2.14.0
|
| 117 |
```
|
| 118 |
|
| 119 |
+
## ๐ง Configuration
|
| 120 |
+
|
| 121 |
+
Edit `Config` class in `finetune_mm_llm.py` to customize:
|
| 122 |
+
|
| 123 |
+
```python
|
| 124 |
+
class Config:
|
| 125 |
+
MODEL_NAME = "microsoft/phi-2" # Change base model
|
| 126 |
+
OUTPUT_DIR = "./mm-llm-coder-lite-v1"
|
| 127 |
+
TRAIN_PATH = "/workspace/train.jsonl"
|
| 128 |
+
# ... more settings
|
| 129 |
+
```
|
| 130 |
+
|
| 131 |
+
## ๐ Output
|
| 132 |
+
|
| 133 |
+
After training, the model will be saved to `./mm-llm-coder-lite-v1/` with:
|
| 134 |
+
- `adapter_config.json` - LoRA config
|
| 135 |
+
- `adapter_model.safetensors` - LoRA weights
|
| 136 |
+
- `tokenizer.json` - Tokenizer
|
| 137 |
+
- `tokenizer_config.json` - Tokenizer config
|
| 138 |
+
- `training_config.json` - Training config
|
| 139 |
+
|
| 140 |
+
## ๐ท๏ธ Tags
|
| 141 |
+
|
| 142 |
+
- `burmese` - Myanmar language
|
| 143 |
+
- `llm` - Large Language Model
|
| 144 |
+
- `code-generation` - Code generation
|
| 145 |
+
- `fine-tuned` - Fine-tuned model
|
| 146 |
+
|
| 147 |
+
## ๐ License
|
| 148 |
+
|
| 149 |
+
MIT License
|
| 150 |
+
|
| 151 |
+
## ๐ค Author
|
| 152 |
|
| 153 |
+
[amkyawdev](https://huggingface.co/amkyawdev)
|