--- license: apache-2.0 language: - km library_name: transformers pipeline_tag: translation tags: - transliteration - romanization - romanized-khmer - khmer - character-level - pytorch - onnx - int8 - safetensors base_model: samdei/samdei-type-base-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 Base 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.040 name: CER (beam 5, char LM + word LM + channel rerank, 8-word pieces) - type: exact_match value: 0.408 name: Exact match --- # Samdei Type Base Samdei Type Base converts romanized Khmer, as people type it in chat, into Khmer script. It is an 18.2M-parameter character-level encoder-decoder, the most accurate open Samdei Type model, for desktop and server use. For a phone, use [Samdei Type Mini](https://huggingface.co/samdei/samdei-type-mini). **Version v1 (2026-11-24).** Samdei Type Bench CER 0.052 → 0.040 (0.047 → 0.040 with a comma counted as a space in both). The first release is at revision [`v0.1`](https://huggingface.co/samdei/samdei-type-base/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). ## Quick start With transformers alone (`pip install transformers torch`): ```python import re from transformers import AutoModelForSeq2SeqLM, AutoTokenizer repo = "samdei/samdei-type-base" 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"(?