初始化项目,由ModelHub XC社区提供模型

Model: amkyawdev/amk-coder-v2
Source: Original Platform
This commit is contained in:
ModelHub XC
2026-06-25 22:09:17 +08:00
commit 66ee2d10f1
9 changed files with 545 additions and 0 deletions

36
.gitattributes vendored Normal file
View File

@@ -0,0 +1,36 @@
*.7z filter=lfs diff=lfs merge=lfs -text
*.arrow filter=lfs diff=lfs merge=lfs -text
*.bin filter=lfs diff=lfs merge=lfs -text
*.bz2 filter=lfs diff=lfs merge=lfs -text
*.ckpt filter=lfs diff=lfs merge=lfs -text
*.ftz filter=lfs diff=lfs merge=lfs -text
*.gz filter=lfs diff=lfs merge=lfs -text
*.h5 filter=lfs diff=lfs merge=lfs -text
*.joblib filter=lfs diff=lfs merge=lfs -text
*.lfs.* filter=lfs diff=lfs merge=lfs -text
*.mlmodel filter=lfs diff=lfs merge=lfs -text
*.model filter=lfs diff=lfs merge=lfs -text
*.msgpack filter=lfs diff=lfs merge=lfs -text
*.npy filter=lfs diff=lfs merge=lfs -text
*.npz filter=lfs diff=lfs merge=lfs -text
*.onnx filter=lfs diff=lfs merge=lfs -text
*.ot filter=lfs diff=lfs merge=lfs -text
*.parquet filter=lfs diff=lfs merge=lfs -text
*.pb filter=lfs diff=lfs merge=lfs -text
*.pickle filter=lfs diff=lfs merge=lfs -text
*.pkl filter=lfs diff=lfs merge=lfs -text
*.pt filter=lfs diff=lfs merge=lfs -text
*.pth filter=lfs diff=lfs merge=lfs -text
*.rar filter=lfs diff=lfs merge=lfs -text
*.safetensors filter=lfs diff=lfs merge=lfs -text
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
*.tar.* filter=lfs diff=lfs merge=lfs -text
*.tar filter=lfs diff=lfs merge=lfs -text
*.tflite filter=lfs diff=lfs merge=lfs -text
*.tgz filter=lfs diff=lfs merge=lfs -text
*.wasm filter=lfs diff=lfs merge=lfs -text
*.xz filter=lfs diff=lfs merge=lfs -text
*.zip filter=lfs diff=lfs merge=lfs -text
*.zst filter=lfs diff=lfs merge=lfs -text
*tfevents* filter=lfs diff=lfs merge=lfs -text
tokenizer.json filter=lfs diff=lfs merge=lfs -text

84
LICENSE Normal file
View File

@@ -0,0 +1,84 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
2. Grant of Copyright License.
Subject to the terms and conditions of this License, Licensor hereby
grants You a worldwide, royalty-free, non-sublicensable, non-exclusive,
perpetual license to exercise the Licensed Material in developing,
making, using, offering for sale, selling, importing, and otherwise
transferring the Licensed Material.
3. Grant of Patent License.
Licensor hereby grants You a worldwide, royalty-free, non-sublicensable,
non-exclusive, perpetual license to exercise the Patent Rights in the
Licensed Material to make, have made, use, offer to sell, sell,
import, and otherwise transfer the Licensed Material.
4. Redistribution.
You may reproduce and distribute copies of the Licensed Material in any
medium, with or without modifications, provided that You meet the
following conditions:
(a) You must give any other recipients of the Licensed Material a copy
of this License; and
(b) You must cause any modified files to carry prominent notices stating
that You changed the files; and
(c) You must retain, in the Source form of the Licensed Material,
all copyright, patent, trademark, and attribution notices.
5. Disclaimer of Warranty.
THE LICENSED MATERIAL IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND.
6. Limitation of Liability.
IN NO EVENT SHALL LICENSOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY ARISING FROM THE USE OF THE LICENSED MATERIAL.
END OF TERMS AND CONDITIONS
Copyright 2024 amkyawdev
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

336
README.md Normal file
View File

@@ -0,0 +1,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*

15
chat_template.jinja Normal file
View File

@@ -0,0 +1,15 @@
{%- if messages[0]['role'] == 'system' %}
{{- '<|im_start|>system\n' + messages[0]['content'] + '<|im_end|>\n' }}
{%- else %}
{{- '<|im_start|>system\nYou are amk-coder-v2, a helpful Myanmar coding assistant. Respond in the same language as the user (Myanmar or English). Provide clean, well-commented code. Explain code when helpful.<|im_end|>\n' }}
{%- endif %}
{%- for message in messages %}
{%- if message.role == 'user' %}
{{- '<|im_start|>user\n' + message.content + '<|im_end|>\n' }}
{%- elif message.role == 'assistant' %}
{{- '<|im_start|>assistant\n' + message.content + '<|im_end|>\n' }}
{%- endif %}
{%- endfor %}
{%- if add_generation_prompt %}
{{- '<|im_start|>assistant\n' }}
{%- endif %}

27
config.json Normal file
View File

@@ -0,0 +1,27 @@
{
"architectures": [
"Qwen2ForCausalLM"
],
"attention_dropout": 0.0,
"bos_token_id": 151643,
"dtype": "float16",
"eos_token_id": 151643,
"hidden_act": "silu",
"hidden_size": 1536,
"initializer_range": 0.02,
"intermediate_size": 8960,
"max_position_embeddings": 32768,
"model_type": "qwen2",
"num_attention_heads": 12,
"num_hidden_layers": 28,
"num_key_value_heads": 2,
"pad_token_id": 151643,
"rms_norm_eps": 1e-06,
"rope_scaling": null,
"rope_theta": 1000000.0,
"sliding_window": null,
"tie_word_embeddings": true,
"transformers_version": "4.45.0",
"use_cache": true,
"vocab_size": 151936
}

10
generation_config.json Normal file
View File

@@ -0,0 +1,10 @@
{
"bos_token_id": 151643,
"eos_token_id": 151643,
"pad_token_id": 151643,
"max_new_tokens": 512,
"do_sample": true,
"temperature": 0.2,
"top_p": 0.95,
"repetition_penalty": 1.1
}

3
model.safetensors Normal file
View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:b42426e78ab55d24853232b904efbd559f7e649c8c784887d1ca961669d2b41e
size 3087467144

3
tokenizer.json Normal file
View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:9e2b7649a086fbb9771cd78ec5b7ffa7069e16a82424a382950fedfa1e057861
size 11421991

31
tokenizer_config.json Normal file
View File

@@ -0,0 +1,31 @@
{
"add_bos_token": false,
"add_prefix_space": false,
"backend": "tokenizers",
"bos_token": null,
"clean_up_tokenization_spaces": false,
"eos_token": "<|endoftext|>",
"errors": "replace",
"extra_special_tokens": [
"<|im_start|>",
"<|im_end|>",
"<|object_ref_start|>",
"<|object_ref_end|>",
"<|box_start|>",
"<|box_end|>",
"<|quad_start|>",
"<|quad_end|>",
"<|vision_start|>",
"<|vision_end|>",
"<|vision_pad|>",
"<|image_pad|>",
"<|video_pad|>"
],
"is_local": false,
"model_max_length": 32768,
"pad_token": "<|endoftext|>",
"split_special_tokens": false,
"tokenizer_class": "Qwen2Tokenizer",
"unk_token": null,
"chat_template": "{%- if messages[0]['role'] == 'system' %}\n {{- '<|im_start|>system\\n' + messages[0]['content'] + '<|im_end|>\\n' }}\n{%- else %}\n {{- '<|im_start|>system\\nYou are amk-coder-v2, a helpful Myanmar coding assistant. Respond in the same language as the user (Myanmar or English). Provide clean, well-commented code. Explain code when helpful.<|im_end|>\\n' }}\n{%- endif %}\n{%- for message in messages %}\n {%- if message.role == 'user' %}\n {{- '<|im_start|>user\\n' + message.content + '<|im_end|>\\n' }}\n {%- elif message.role == 'assistant' %}\n {{- '<|im_start|>assistant\\n' + message.content + '<|im_end|>\\n' }}\n {%- endif %}\n{%- endfor %}\n{%- if add_generation_prompt %}\n {{- '<|im_start|>assistant\\n' }}\n{%- endif %}\n"
}