--- license: apache-2.0 language: - km library_name: transformers pipeline_tag: translation tags: - transliteration - romanization - romanized-khmer - khmer - character-level - onnx - int8 - safetensors - keyboard - on-device base_model: samdei/samdei-type-mini-pretrained base_model_relation: finetune datasets: - samdei/samdei-type-pretraining-data - samdei/samdei-type-finetuning-data metrics: - cer - exact_match model-index: - name: Samdei Type Mini results: - task: type: translation name: Romanized Khmer to Khmer script dataset: type: samdei/samdei-type-bench name: Samdei Type Bench split: test metrics: - type: cer value: 0.049 name: CER (beam 5, word-LM rerank, 8-word pieces) - type: exact_match value: 0.306 name: Exact match --- # Samdei Type Mini Samdei Type Mini converts romanized Khmer, as people type it in chat, into Khmer script. It is a 7.2M-parameter character-level encoder-decoder, small enough for a phone keyboard: 7 MiB as int8 ONNX. **Version v1 (2026-11-24).** Samdei Type Bench CER 0.058 → 0.049 (0.053 → 0.049 with a comma counted as a space in both). The first release is at revision [`v0.1`](https://huggingface.co/samdei/samdei-type-mini/tree/v0.1). | Input | Output | |---|---| | `knhom jong tov phsar` | ខ្ញុំចង់ទៅផ្សារ | | `ot mean wifi te` | អត់មាន wifi ទេ | Release article: [Samdei Type: open models that turn romanized Khmer into Khmer script](https://huggingface.co/blog/mengsay/samdei-type), with a demo of this model in a chat. ## Quick start With transformers alone (`pip install transformers torch`): ```python import re from transformers import AutoModelForSeq2SeqLM, AutoTokenizer repo = "samdei/samdei-type-mini" tok = AutoTokenizer.from_pretrained(repo) model = AutoModelForSeq2SeqLM.from_pretrained(repo) def pieces(text: str, max_words: int = 8) -> list[str]: """At most max_words words per piece, with a break after punctuation, as in the paper.""" out, cur = [], [] for w in text.split(): cur.append(w) if len(cur) == max_words or w[-1] in ",.;:?!។": out.append(" ".join(cur)) cur = [] if cur: out.append(" ".join(cur)) return out or [text] def convert(text: str) -> str: batch = tok(pieces(text), padding=True, truncation=True, return_tensors="pt") out = model.generate(**batch) # beam search, k = 5 (generation_config.json) out = " ".join(tok.batch_decode(out, skip_special_tokens=True)) return " ".join(re.sub(r"(?