Samdei Type: open models that turn romanized Khmer into Khmer script

Community Article
Published November 18, 2026

Samdei Type converts Khmer typed in Latin letters, the way many Cambodians chat (knhom jong tov phsar), into Khmer script (ខ្ញុំចង់ទៅផ្សារ, "I want to go to the market"). Today we release two open models: Samdei Type Mini (7.1M parameters, small enough for a phone keyboard) and Samdei Type Base (18.2M). With them come all their training data, a new test set of 2,155 everyday messages, and a technical report.

On that test set, Base reaches a character error rate (CER) of 0.052 and Mini 0.058, lower than the best existing open model (0.066).

In the video below, Mini converts one message in two ways: as you type it on the keyboard, and when a friend sends it in Latin letters. Every conversion shown is a real output of the released model.

Samdei Type Mini in a chat. Part 1, typing: tos tov leng takeo hob bongkong boeng becomes តោះទៅលេងតាកែវ ហូបបង្កងបឹង key by key. Part 2, reading: a friend sends the same message in Latin letters, and one tap shows it in Khmer script.

The problem: one word, many spellings

Romanized Khmer has no standard spelling. knhom, khnhom, kyom and nh all mean ខ្ញុំ ("I"). People also drop vowels, glue or split words, and mix in English: ot mean wifi te is អត់មាន wifi ទេ.

A converter has to learn all of these habits from romanized–Khmer pairs, and such pairs are scarce, even though Khmer-script text is plentiful. There was also no public test set of everyday messages to measure progress.

The idea: separate what is written from how it is spelled

Each training pair joins a real Khmer sentence with a romanized spelling made by one of several small sources. Because the Khmer side is always real text, the target is correct by construction. Because the sources have different biases, the model does not learn just one source's habits. Here is one sentence, ខ្ញុំចង់ទៅផ្សារ, spelled by different sources (real outputs):

Romanized spelling Source
knhom jong tou bsa persona generator, careful typist
khnhom chong tov phsear spelling table mined from a public word list
kyom jong tow phsar persona generator, mixed habits
nh jg tv psa persona generator, lazy typist (abbreviated)

The sources are:

  • a rule-based generator that spells like four typing personas and adds noise such as dropped vowels, glued words and typos;
  • spelling tables mined from public lists of romanized Khmer words;
  • romanizations of real sentences written by an LLM (Gemma 4, run locally);
  • abbreviated copies (tov → tv) and stretched letters (tovvv) for casual chat.

A small character-level Transformer is pretrained on mostly generator-made pairs (12.8M for Base, 6.5M for Mini). Two short stages then bring in the other sources: chat-like pairs, then casual register. Training took about 3 hours for Mini and 6 hours for Base on one laptop GPU.

At decoding time, the beam-search candidates are reranked with a word language model. Base also uses a character language model and a reverse model that checks that the output explains all of the input.

What we release

Everything is in one Hugging Face collection. The inference code is at github.com/Samdei-Labs/samdei-type (Apache-2.0).

Repository What it is License
samdei-type-mini On-device model: 7 MiB as int8 ONNX, plus a 1.2 MiB word LM for reranking Apache-2.0
samdei-type-base Most accurate open model, with its reranking LMs and reverse model Apache-2.0
samdei-type-mini-pretrained, samdei-type-base-pretrained Pretrained checkpoints, to fine-tune your own converter Apache-2.0
samdei-type-bench Samdei Type Bench: 2,155 everyday messages and words with human-checked Khmer CC BY 4.0
samdei-type-pretraining-data The exact pretraining pairs of both models CC BY-SA 4.0
samdei-type-finetuning-data The exact pairs of the two adaptation stages CC BY-SA 4.0
samdei-type-resources LLM-written chat sentences, mined spelling tables and hand-written lexicons CC BY 4.0, CC0 or Apache-2.0, per file

The models load with the transformers library alone. Each data repository lists the exact mix of every training stage, so training can be repeated without regenerating the data.

How well it works

Both open models beat the best existing open model on Samdei Type Bench. The bench holds 2,155 everyday messages and words over designed scenes, mostly LLM drafts audited by native speakers. No Samdei Type model was trained, selected or tuned on it. Lower CER is better.

System Parameters CER Exact match
Samdei Type Prime (not released) 18.2M 0.027 61%
Samdei Type Base 18.2M 0.052 30%
Samdei Type Mini 7.1M 0.058 24%
Akkhara-mini, in 6-word pieces 17.8M 0.066 23%
AkaraAlpha 0.08M 0.281 2%
  • Prime is Base trained further on scenario-designed, LLM-drafted, human-audited data. Most bench items share that scenario design, so its lead is an upper bound.
  • Without reranking (beam search alone, as in the transformers example below), Base scores 0.062 and Mini 0.072.
  • Mini is fast: on one Apple M5 Pro CPU thread, as int8 ONNX, it takes about 5 ms per input, or 5.7 ms per keystroke with reranking.

Try it

With transformers alone (pip install transformers torch):

from transformers import AutoModelForSeq2SeqLM, AutoTokenizer

repo = "samdei/samdei-type-mini"
tok = AutoTokenizer.from_pretrained(repo)
model = AutoModelForSeq2SeqLM.from_pretrained(repo)
batch = tok(["knhom jong tov phsar"], return_tensors="pt")
print(tok.batch_decode(model.generate(**batch), skip_special_tokens=True))  # ['ខ្ញុំចង់ទៅផ្សារ']

The model works on short pieces. The model card shows how to cut a long message into pieces of at most eight words.

For the best quality, the samdei-type package adds the reranking, in Python or on the command line:

pip install "samdei-type[deploy]"
samdei-type "knhom jong tov phsar"

To adapt the model to another typing habit or domain, fine-tune a pretrained checkpoint with any transformers training loop. The pretrained model card has a complete example.

Limitations

  • Every romanized input seen in training is synthetic. Real typing appears only in the evaluation.
  • Homophones that need more context than the next word stay hard: ដើរ / ដែរ (der), ដឹក / ដែក / ដេក (dek).
  • Loanwords typed in English (check for ឆែក) stay in English.
  • Mini has not been timed on a phone yet.
  • The models do not convert Khmer script to Latin letters, and they are not meant for official romanization of names.

With this release, we are closing the project. We hope the benchmark, the data and the training approach help anyone researching or working on romanized Khmer, and on Khmer language technology more broadly. Everything is open: please use it, build on it and improve on it.

Links

Thanks to the native speakers who reviewed Samdei Type Bench.

If you use Samdei Type, please cite:

@misc{samdei-type-2026,
  title  = {Samdei Type: Separating What Is Written from How It Is Spelled for Romanized Khmer Transliteration},
  author = {Mengsay Loem},
  year   = {2026},
  note   = {Technical report},
  url    = {https://github.com/Samdei-Labs/samdei-type/blob/main/paper/samdei-type.pdf}
}

Community

The 5.7 ms figure with the word-LM reranker is a useful starting point for a keyboard. For an IME, the next number I'd watch is p95 keystroke-to-render on a midrange phone, particularly when an edit forces the decoder to revisit several words. Occasional stalls can matter even when the median is low, and corpus CER doesn't capture them.

Sign up or log in to comment