Qwen2.5-1.5B-qlora-zhtw
A small chat model that answers in Traditional Chinese (Taiwan usage). It is Qwen/Qwen2.5-1.5B-Instruct fine-tuned with QLoRA on about 3.6k human-written Traditional Chinese Q&A pairs.
The main effect is vocabulary: the base model often uses Mainland China terms (視頻, 軟件, 硬件…). After fine-tuning, it mostly uses Taiwan terms (影片, 軟體, 硬體…). Knowledge and reasoning scores did not change in our small test.
Quick start
This repo holds the merged model (LoRA already merged into the base weights), so you can load it directly.
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
repo = "mikeforai/Qwen2.5-1.5B-qlora-zhtw"
tokenizer = AutoTokenizer.from_pretrained(repo)
model = AutoModelForCausalLM.from_pretrained(repo, torch_dtype=torch.float16, device_map="auto")
messages = [{"role": "user", "content": "電腦開機很慢,可能是什麼原因?"}]
prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
out = model.generate(**inputs, max_new_tokens=256, do_sample=True, temperature=0.7, top_p=0.9)
print(tokenizer.decode(out[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))
Using the LoRA adapter only
If you have the adapter files instead of the merged model:
from peft import PeftModel
base = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2.5-1.5B-Instruct", torch_dtype=torch.float16, device_map="auto")
model = PeftModel.from_pretrained(base, "<adapter-path-or-repo>")
Model details
| Base model | Qwen/Qwen2.5-1.5B-Instruct |
| Method | QLoRA (4-bit NF4 base + LoRA adapter), then merged to fp16 |
| Language | Traditional Chinese (zh-TW) |
| Trainable parameters | 18.5M of 1.56B (1.18%) |
| License | Apache 2.0 (same as the base model and the dataset) |
Training data
Heng666/Traditional_Chinese-aya_dataset (Apache 2.0): human-annotated Chinese Q&A from the Cohere Aya project, already converted to Traditional characters by the dataset author.
Cleaning steps:
- Strip leading and trailing whitespace.
- Drop answers shorter than 5 characters (many are one-word answers like "5月").
- Drop duplicate questions.
| Stage | Examples |
|---|---|
| Original | 4,909 |
| After cleaning | 3,804 |
| Train / validation split (95% / 5%) | 3,613 / 191 |
| After dropping samples truncated to zero answer tokens | 3,605 / 191 |
Each pair is formatted with the Qwen chat template (inputs → user, targets → assistant). Loss is computed only on the answer, not on the question.
Training setup
| Setting | Value |
|---|---|
| Hardware | 2 × Tesla T4 (Kaggle) |
| Training time | about 15 minutes (909 s) |
| Epochs / steps | 1 / 226 |
| Max sequence length | 512 |
| Batch size | 4 per device × 4 gradient accumulation |
| Learning rate | 2e-4, cosine schedule |
| Optimizer | paged_adamw_8bit |
| Precision | fp16 (T4 does not support bf16) |
| Quantization | 4-bit NF4, double quantization, fp16 compute |
| LoRA | r=16, alpha=32, dropout=0.05 |
| LoRA targets | q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj |
| Gradient checkpointing | on |
| Frameworks | transformers, peft, bitsandbytes, accelerate, datasets |
Final training loss (average): 1.754.
Evaluation
Base and fine-tuned models were compared with the same 4-bit model object, switching the adapter on and off, so the quantization is identical.
Validation loss
| Step | Eval loss | Perplexity |
|---|---|---|
| 50 | 1.6008 | 4.96 |
| 100 | 1.5396 | 4.66 |
| 150 | 1.5124 | 4.54 |
| 200 | 1.5047 | 4.50 |
| 226 | 1.5040 | 4.50 |
Taiwan vs. Mainland China wording
20 everyday questions (greedy decoding). We counted 16 Mainland-style terms (視頻, 軟件, 硬件, 質量, 網絡, 默認, 優化, 屏幕, 鼠標, 程序員, 數據庫, 服務器, 打印機, U盤, 博客, 短信) in the answers.
| Model | Mainland-style terms |
|---|---|
| Base (Qwen2.5-1.5B-Instruct) | 18 |
| This model | 1 |
This is a rough keyword count, not a full quality score.
Standard benchmarks
lm-evaluation-harness, 0-shot, only 50 questions per sub-task.
| Task | Metric | Base | This model | Std. error |
|---|---|---|---|---|
| TMMLU+ (Taiwan knowledge) | acc | 0.418 | 0.422 | 0.008 |
| ARC-Easy | acc | 0.720 | 0.760 | 0.061 |
| HellaSwag | acc_norm | 0.680 | 0.680 | 0.067 |
Behavior to expect
The Aya answers are short and often start with 答: or 答案:. The fine-tuned model picked up this style, so its answers are shorter and more terse than the base model.
Example (question: 請用三句話介紹台灣的夜市文化。):
答:台灣夜市以其豐富多樣的食物和活力四射的氛圍而聞名;夜晚的街邊小吃店如雨後春筍般繁多,讓你一飽口福;夜市是夜晚最亮麗的一道光,為城市增添了一份獨特的魅力。
If you want longer, more detailed answers, ask for them in the prompt (for example "請詳細說明") or use the original base model.
Limitations
- Small model (1.5B): it can make mistakes, invent facts, and struggle with math, code, and long reasoning.
- Small, general dataset: about 3.6k Q&A pairs, one epoch. It is not tuned for any specific domain.
- Short answers: see "Behavior to expect" above.
- Limited evaluation: 50 questions per benchmark, 20 hand-written prompts, no human preference study.
- Training length: max 512 tokens; longer conversations were not trained on.
- Language: built for Traditional Chinese. Other languages may be worse than the base model (not measured).
- The model inherits the biases and limits of the base model and the training data.
Acknowledgements
- Qwen team for the base model
- Heng666 for the Traditional Chinese Aya dataset, and Cohere For AI for the original Aya dataset
- Hugging Face
transformers,peft,bitsandbytes, and EleutherAIlm-evaluation-harness
Citation
@misc{qwen2.5,
title = {Qwen2.5 Technical Report},
author = {Qwen Team},
year = {2024},
eprint = {2412.15115},
archivePrefix = {arXiv}
}