| --- |
| license: mit |
| language: [km] |
| base_model: [Qwen/Qwen2.5-0.5B] |
| pipeline_tag: text-generation |
| tags: [khmer, qwen2, instruct, low-resource-language] |
| --- |
| |
| # KhmerLLM_instruct_e3 |
|
|
| ## Model Description |
|
|
| **KhmerLLM_instruct_e3** is a Khmer-language instruction-tuned model built on top of **Qwen/Qwen2.5-0.5B** (base, non-instruct). It was produced in two stages: |
|
|
| 1. **Continual pretraining**: The Qwen2.5-0.5B base model was further pretrained on ~5GB of Khmer text to adapt it to the Khmer language. The base Qwen2.5-0.5B model struggles to produce coherent Khmer word segmentation and grammar; after continual pretraining, the model generates significantly more coherent and fluent Khmer text. |
| 2. **Instruction fine-tuning**: The continually-pretrained model was then fine-tuned on ~50,000 Khmer instruction/response pairs, giving it the ability to follow instructions and behave as a conversational/instruct-style model. |
|
|
| **Known limitations**: Despite the fluency improvements, the model **hallucinates frequently** โ likely due to the limited scale of both the pretraining corpus (~5GB) and instruction dataset (~50k pairs) relative to what's needed for a low-resource language like Khmer. Factual claims from this model should not be trusted without verification. |
|
|
| - **Developed by:** AnotherPotatoCoder |
| - **Model type:** Causal decoder-only language model (Qwen2 architecture) |
| - **Language(s):** Khmer (km) |
| - **License:** MIT |
| - **Finetuned from model:** [Qwen/Qwen2.5-0.5B](https://huggingface.co/Qwen/Qwen2.5-0.5B) (base, not instruct) |
|
|
| ## Uses |
|
|
| ### Direct Use |
|
|
| - Khmer text generation and completion |
| - Simple Khmer instruction-following / conversational assistant tasks |
| - Research and experimentation on low-resource language adaptation |
|
|
| ### Out-of-Scope Use |
|
|
| - **Factual / knowledge-intensive tasks** โ the model hallucinates frequently and should not be used where factual accuracy matters (e.g., medical, legal, financial advice). |
| - Production or safety-critical deployments without further evaluation and fine-tuning. |
| - Tasks requiring strong reasoning or long-context understanding; the model is only 0.5B parameters and has limited capacity. |
|
|
| ## Bias, Risks, and Limitations |
|
|
| - **Hallucination**: The model frequently generates plausible-sounding but factually incorrect or fabricated content, likely due to limited training data scale (~5GB pretraining, ~50k instruction pairs). |
| - **Data provenance**: Training data was a mix of public and self-collected/scraped Khmer text and instruction pairs; it has not been rigorously audited for bias, toxicity, or duplication. |
| - **Small model size (0.5B params)**: Limits reasoning ability and knowledge capacity compared to larger models. |
| - **Language coverage**: Optimized for Khmer; performance on other languages is not guaranteed and may be degraded relative to the original Qwen2.5-0.5B base. |
|
|
| ### Recommendations |
|
|
| Users should independently verify any factual claims generated by this model, especially for anything used outside casual/experimental contexts. This model is best suited for research, prototyping, and further fine-tuning rather than direct deployment. |
|
|
| ## How to Get Started with the Model |
|
|
| ```python |
| import torch |
| from transformers import AutoModelForCausalLM, AutoTokenizer |
| |
| repo_id = "AnotherPotatoCoder/KhmerLLM_instruct_e3" |
| |
| tokenizer = AutoTokenizer.from_pretrained(repo_id) |
| model = AutoModelForCausalLM.from_pretrained( |
| repo_id, |
| dtype=torch.float16, |
| device_map="auto", |
| ) |
| model.eval() |
| |
| prompt = "แแฝแแแแธ! แแพแขแแแแแแแแแขแแแธ?" |
| |
| messages = [ |
| {"role": "system", "content": "แขแแแแแบแแถแแแแฝแแแถแแแแแแขแแแแถแแแ"}, |
| {"role": "user", "content": prompt} |
| ] |
| |
| input_text = tokenizer.apply_chat_template( |
| messages, tokenize=False, add_generation_prompt=True |
| ) |
| |
| inputs = tokenizer(input_text, return_tensors="pt").to(model.device) |
| |
| with torch.no_grad(): |
| outputs = model.generate( |
| **inputs, |
| max_new_tokens=200, |
| do_sample=True, |
| temperature=1.0, |
| top_k=100, |
| top_p=0.8, |
| no_repeat_ngram_size=3, |
| pad_token_id=tokenizer.eos_token_id, |
| ) |
| |
| print(tokenizer.decode(outputs[0], skip_special_tokens=True)) |
| ``` |
|
|
| ## Training Details |
|
|
| ### Training Data |
|
|
| A mix of publicly available Khmer text/datasets and self-collected/scraped Khmer text: |
|
|
| - **Continual pretraining corpus:** ~5GB of Khmer text |
| - **Instruction fine-tuning dataset:** ~50,000 Khmer instruction/response pairs |
|
|
| Exact dataset sources are not fully itemized here; update this section with specific dataset names/links if you'd like full reproducibility and attribution. |
|
|
| ### Training Procedure |
|
|
| Two-stage training: |
|
|
| 1. **Continual pretraining** on ~5GB Khmer text corpus, starting from `Qwen/Qwen2.5-0.5B` (base). |
| 2. **Instruction fine-tuning** on ~50,000 Khmer instruction pairs, starting from the continually-pretrained checkpoint (stage 1 output). |
|
|
| #### Training Hyperparameters |
|
|
| - **Training regime:** fp16/mixed precision (weights stored in fp16 on the Hub) |
| - **Epochs (instruct stage):** 3 |
| - **Base architecture:** Qwen2 (0.5B parameters) |
|
|
| ### Speeds, Sizes, Times |
|
|
| - **Continual pretraining:** ~4 hours, 3 epochs, on a single NVIDIA A100 (rented via vast.ai) |
| - **Instruction fine-tuning:** performed on the continually-pretrained checkpoint (see above) |
|
|
| ## Evaluation |
|
|
| No formal benchmark evaluation has been conducted yet. Comparative examples against the base `Qwen/Qwen2.5-0.5B-Instruct` model are provided below to illustrate qualitative differences in Khmer fluency and coherence. |
|
|
| ### Qualitative Comparison: KhmerLLM_instruct_e3 vs. Qwen2.5-0.5B-Instruct |
|
|
| | Prompt (Khmer) | KhmerLLM_instruct_e3 Output | Qwen2.5-0.5B-Instruct Output | |
| | ------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | |
| | แแฝแแแแธ! แแพแขแแแแแแแแแขแแแธ? | แแฝแแแแธ! แแแแปแแแแแแ แแถแแแแทแแทแ ๐ | แแแแ แถแแแแ! เบซแแแแแแนแแ
แทแแแแแธแแแ
แแแแแแแพแแแถแแแแนแแแแแแแแแฝแ: 1. ่ฑ่ช (English) 2. ๆณฐ่ฏญ (Thai) 3. ้ฉฌๅฐผๆ่ฏ (Magana Language) 4. ็ฏไฟ่ฑ่ฏญ (Eco English) 5. ๆผข่ช (Chinese) แแ แแแแปแแแถแ | |
| | แแผแแแแแถแแแแแแปแแขแแแธแแแแแแแแแแแปแแถ | แแแแแแแแแแแปแแถแแบแแถแแแแแแแแแแ
แแแถแแแแถแแแแแ
แขแถแแแธแขแถแแแแแแแแแแแถแแขแถแแปแแถแแแทแ แฃแ แแแแถแแ แแแแแแแแแแแปแแถแแแแทแแแ
แแแแปแแแแแแแขแถแแแธแขแถแแแแแแ (แขแแธแassistant) แแทแแขแถแแแธแแถแแฆแแถแ (แแผแแถ) แ แพแแแถแแถแแนแแแธแแแแแแแแแถแ (แขแถแแแธ) แแแแแฝแแแถแแแแแแแแ
แแแฝแ แกแ แแบแ แแแแแปแแถ แกแถแ แแผแแถ แแ แแแแแถแ แ
แทแ แแทแแแแ ... | แแถแแพแแแถแแฝแแแทแ
แแผแ
แแฒแแแแแแแแแแ: - "แแนแแแแแกแถแแ" (แแแแปแแแธแ แแผแ) - "แแแแพแแแ" (แแผแแแแแผแแทแ) - แแแแถแแแแแแแปแแแแแแผแ (แแ แผแแ | |
| | แแพแแถแแแถแแธแแแแแแแแแแถแแถแแแแแแแแขแแแธ? | แแแแแแถแแธแแแแแแแแแแแถแแธแแแบแแแถแแธแแ | แแแแแแแแแแแแผแแแถแแแถแแแแแแแถแแแแแ
แแแแแแแแ: 1.แแแแแถแแแแทแ
แแ
แแแแแ แแแแถแแ: - ้ซๅบฆ๏ผ Heights - ๅฎๅ
จ๏ผ Safety 2.แแแปแแแถแแแแแปแแแแแถแแแแนแแปแ ( | |
| | แแพแขแแแแขแถแ
แแฝแแแแแปแแแแแแแขแแธแแแแแถแแแ? | แแแแปแแแถแแแถแแแแฝแแแถแ AI แแแแปแแแทแแแถแแแแแแแแถแแแแแแแขแแธแแแแแแ แแแแแแถแแแถแแแแแ แแแแปแแขแถแ
แแแแถแแแแแทแแแฝแแ
แแแฝแแแแแแถแแแแถแแแแแแแขแแธแแแแแแแแแแแแแแแแทแแแแแถแแ 1. แแแแแถแแขแแธแแแแแแแ ... | แขแแแผแแถแแแแแแแ
แแแแแพแแแแธแแถแแแถแแทแแแแถแแแถแแฝแแแแแแแแแแกแพแแแพแแแแแแแแแนแแแแแ แแแแแ
แแแ. แ แพแแแแแแแแขแแแแแแปแแแแแแแถแแแ | |
| | แแผแแแแแแแขแแธแแแแแปแแ
แแแถแแแแแแแถแแแถแแแถแแแฝแแแแแ | แแแแแถแแแแ แแถแแแแแแถแแแถแแแแ แแแถแ แแทแแแแ แแแถแแแ
แแแแแแแแแแแแถแ แแถแแธแแแแ [แขแแแแแแฝแ] แแแแปแแแแแแนแแแถแขแแธแแแแแแแแแแพแแขแแแแแถแแแแขแ แแแแปแแแแแปแแแแแแแแพแแแแธแแปแแแแแแแแแถแแแฝแแแแแแแธแแถแแแถแแแแแแแแปแแแถแแแแแพแแถแแแธแแแแแถแ แแแปแแ ... | แแแ แแแแถแ
แแแนแแแแแแแแแแแแแแแถแแแถแแ, แขแแแแถแแแถแแแแฟแ (Radar) แแถแแแแแแแแ "SAR Radar" แแแแถแ้จ่ฝแทแแแแแแแแแแ
แถแแแ แแ (Orbital Command and Service Radar) แแ
แแแแผแแแถแ | |
| | แแผแแแแแแแแฟแแแแแธแแฝแแขแแแธแแปแแถแแแแแถแแแแแแแถแแแแแพแแแแแแแแแแแ | แแถแแแแแแฝแแแ
แแแแปแแแผแแทแแผแ
แแฝแแแแแทแแแ
แ
แแแแแแแแแแแธแ แแถแแแแแแแแแแปแแแแแถแแแแแแแ Jack แ Jack แแถแแ
แทแแแแแแแแปแแ แแทแแ
แแแแนแแ
แแแแพแ แ แพแแแถแแแแแแแแ
แแแถแแแแแแพแแแแแแแแปแแแธแแ แแแแแถแ แแทแแแแแแแพแแแแแแแแแ แแแแแแฝแ แแถแแแแถแแแแแแแแฝแแแพแแแแแธแ
แถแแแแแแแแแถแแแแถแแแแแแ ... | "แแทแแแแถแแแผ" | |
| | แแผแแแแแแแแถแแแแแแแธแแฝแแขแแแธแแแผแแแแแแถ | แแแแ
แแแแแขแถแแทแแแแแแแขแแแแ
แแแแ
แแแแ
แแแแพแฑแแแแแแแแแแแแขแแแแแพแแแแแแนแแ แผแแ แแนแแ แผแแแผแ
แแถแขแแแแขแถแ
แแแแแผแแขแถแแแแแแแแถแ แแทแแแถแแแถแแแแแถแ แแทแแแแแแแแแแถแแแแ
แแแแปแแ
แทแแแแแแแแขแแแแ แแถแแแแแปแแแแแ
แถแแแแ
แแแแปแแแแแแขแถแแทแแแ ... | แแถแแแแแพแแแแแแแแแแแแถแแฏแแถแแกแพแแกแถแแแแแปแแแ แแแแแผแแแแแ
แแแแแถแแแถแแแแถแแแแแแ. แแทแแแแแผndonแแแแถแแแแแแแแแแถแ 1. แแแแแถแแแแแแแแแถแ | |
| | แแพแแทแแแถแแแแปแแแถแแแแแแแแแ แฅ แ แพแแฒแแแแทแแแแแแแแท แข แแถแแแแแแแถแแแแฝแ แแแแปแแแ
แแแแแแปแแแแถแ? | แแแแแทแแแพแขแแแแแถแแแแแ pears แ
แแแฝแ 5 แ แพแแแทแแแแแแแแขแแแแแถแแ
แแแฝแแแธแ แขแแแแแนแแแถแแแแแแแแแแแแบแแธแแแปแแ
แแแฝแ 10 แ แ
แแแฝแแแแแแแ passistant แแนแแแถแแ
แแแฝแแแแปแแแแแแแแแแแแ | แแแแแธแแถแแแนแแแแแ
แถแแแแแถแแแแแผแแแแแปแแแแขแแแธแแถแแแแนแ: 1. ่จๅก (Sakura) - เนเธเธเธตเนเธเธธเนเธ, แแแแผแแแถแแแถแแแแแแแแ แแแแพแแแถแแถแ
แ แแถแแแแแแป | |
| | แแพแแแแปแแแฝแแแแแพแแผแ
แแแแแ
แแพแแแแธแแแแแถแแถแขแแแแแแแแฑแแแแถแแแฟแ? | แแแแแบแแถแแแแแนแแแแแแแแแแขแถแ
แแฝแแขแแแแแแแแถแแถแขแถแแแแทแแแถแแแแถแแแฟแแ 1. แ
แถแแแแแแพแแแแแผแแ แแถแแถแแฟแแแแแถแแแแแแปแแแถแแแแแแถแแถแแแแธแฑแแแแถแแแถแแแแถแแแแแขแถแ
แแแแพแแ
แแถแแ ... | แแทแแแแทแแธแแถแแแ แแผแแแปแแแแแแถแแแแแ 2019, แแฏแแ
แแถแแแแแถแแแแแแแแแแััแแแแนแแแแแแแแถแแถแแถแแแแผแแแปแ. แแถแแแถแแแทแแทแแแแแถแ
แแแแแถแ | |
| | แแผแแแแแแแแแแแถแแแแแ
แแถแแถแแถแขแแแแแแแแ 'แแแแปแแแแแแถแแแแแแแแแแแแแปแแถ' | "แแแแปแแแแแแถแแแแแแแปแแถ" | แแแแถแแแแทแแแแถแแพแ, "แแแแนไบคแแแแถแแแแธ" (Kongfu) แ แพแแแถแแแแแแแแถแแแแแแทแ
แแแแปแแแแถแแขแแแธแแแแปแแ แแผแแแแถแแแทแแแแแแ 1. แขแแแแแถแแแฏแ | |
|
|
| > **Takeaway:** `KhmerLLM_instruct_e3` produces dramatically more fluent, grammatical, and topically-relevant Khmer text than the unmodified `Qwen2.5-0.5B-Instruct`, which struggles to produce coherent Khmer at all. However, the examples above also illustrate this model's core weakness โ **hallucination**: e.g. the math prompt ("5 apples, give 2 to friends") is answered incorrectly ("10" instead of the correct "3"), the translation prompt echoes the Khmer phrase back instead of translating it to English, and longer factual answers (e.g. about Cambodia) drift into inaccurate claims partway through. Treat outputs as fluent but _unreliable_. |
| > |
| > Note: `KhmerLLM_instruct_e3` was fine-tuned from a continually-pretrained Khmer version of `Qwen2.5-0.5B` (base), while the comparison model here, `Qwen2.5-0.5B-Instruct`, is Qwen's own official instruct model with no Khmer-specific adaptation. This comparison is meant to demonstrate the effect of Khmer-specific continual pretraining + fine-tuning, not a general capability benchmark. |
|
|
| ## Hardware Used |
|
|
| - **Hardware Type:** NVIDIA A100 (rented via vast.ai) for continual pretraining; NVIDIA P100 (Kaggle) for instruction fine-tuning |
| - **Hours used:** ~4 hours (continual pretraining, A100) + ~3 hours (instruction fine-tuning on ~50,000 pairs, P100) |
| - **Cloud Provider:** vast.ai (continual pretraining), Kaggle (instruction fine-tuning) |
|
|
| ## Technical Specifications |
|
|
| ### Model Architecture and Objective |
|
|
| Causal (autoregressive) decoder-only transformer, Qwen2 architecture, 0.5B parameters. Trained with a standard next-token prediction objective during continual pretraining, and instruction-tuned (supervised fine-tuning on instruction/response pairs) in the second stage. |
|
|
| ### Compute Infrastructure |
|
|
| - **Hardware:** NVIDIA A100 GPU (vast.ai rental) |
| - **Software:** ๐ค Transformers, PyTorch |
|
|
| ## Model Card Authors |
|
|
| AnotherPotatoCoder |
|
|
| ## Model Card Contact |
|
|
| Open an issue or discussion on this model's Hugging Face repository. |
|
|