You need to agree to share your Hugging Face information to access this model

This repository is publicly accessible, but you have to accept the conditions to access its files and content.

Log in or Sign Up to review the conditions and access this model content.

Hy-MT3-1.8B with an extended Khmer tokenizer

Tencent Hy-MT3-1.8B, fine-tuned for Khmer, with 4,096 Khmer pieces added to the tokenizer. The purpose is speed: the stock tokenizer spends about 1.5 tokens on every Khmer character, so Khmer output is slow. With the new pieces the model writes Khmer 3 to 5 times faster, and translation quality on the tests below is at or above the stock model.

Internal name of this version: pilot 6 (hy18-kt6). Trained 27 November 2026.

Files

File What
model.safetensors, config.json merged weights, bf16, transformers format (3.4 GB)
tokenizer.json and the other tokenizer files stock Hy-MT3-1.8B tokenizer plus 4,096 Khmer pieces
hy18-kt6-Q8_0.gguf for llama.cpp, 8-bit quantization (1.92 GB)
hy18-kt6-Q4_K_M.gguf for llama.cpp, 4-bit quantization (1.14 GB)

The unquantized GGUF (hy18-kt6-bf16.gguf, 3.60 GB) is not stored here, to save space. It appears in the tables below as a reference and can be rebuilt from the transformers weights (see "Use").

Results

Greedy decoding and the same prompt for every model. chrF for Khmer output uses word_order=0 (Khmer has no spaces between words).

Test Stock Hy-MT3-1.8B Same data, stock tokenizer (control) This model
NTREX-128 English→Khmer, 100 rows, chrF against the human reference 51.7 52.5 53.7
200 held-out dataset pairs, English→Khmer, chrF 54.1 60.5 63.4
200 held-out dataset pairs, Khmer→English, chrF++ 63.4 65.0 64.1
200 held-out dataset pairs, Khmer→English, BLEU 35.5 40.5 42.9
Output tokens for the 200 Khmer translations 46,725 47,349 8,229
Broken characters (U+FFFD) in the outputs 0 0 0
450 sentences into 15 other languages: output in the wrong script 2 0 0

For reference on the same NTREX rows: Google Translate 55.2, stock Hy-MT3-7B (Q8) 51.5, stock Hy-MT3-30B-A3B (Q4_K_M) 51.1. The GGUF file of this model scores the same 53.7 as the transformers weights.

Speed with transformers (greedy, batch 16, RTX 3090): stock 106 Khmer characters per second, this model 563 (5.3×).

GGUF files under llama.cpp on the RTX 3090: the 100 NTREX sentences English→Khmer, greedy, -c 32768 -np 8, all layers on the GPU. GPU memory is the nvidia-smi reading with the server loaded at those settings.

File NTREX chrF Khmer chars/s, 1 request Khmer chars/s, 8 parallel Tokens/s, 1 request 100 sentences, 1 request GPU memory
Stock Hy-MT3-1.8B Q8_0 52.5 130 358 225 92.6 s 4.2 GB
Stock Hy-MT3-1.8B Q4_K_M not scored 148 344 257 80.6 s 3.7 GB
hy18-kt6-bf16.gguf 53.7 437 1,293 150 24.7 s 5.9 GB
hy18-kt6-Q8_0.gguf 53.5 579 1,435 198 18.6 s 4.2 GB
hy18-kt6-Q4_K_M.gguf 54.0 703 1,392 240 15.4 s 3.5 GB

Quantization costs no measurable quality: the three files are within 0.5 chrF, which is noise on 100 rows. This model produces fewer tokens per second than the stock model (the output layer is larger), but each token carries about 3.3 times more Khmer text, so it finishes the same sentences 4.5 to 5 times sooner.

Tokens per Khmer character on the NTREX reference text: stock 1.52, this tokenizer 0.31.

Limits

  • The NTREX gain is partly a home advantage. 200,000 news pairs from the same source as the NTREX test were in the training data. The 100 test sentences were excluded. The control run did not have these pairs, so the table does not show that this model beats a stock-tokenizer fine-tune on the same data.
  • Other languages were not scored against references. On 450 held-out sentences in 15 languages no output was in the wrong script. But the outputs differ more from the stock model's outputs than the control's do (chrF against the stock output: 60.3 from English and 49.5 from Khmer; control 82.0 and 71.7). Test before using this model for languages other than Khmer, English, French and Chinese.
  • French and Chinese pairs were in training, but only English↔Khmer has a test score.
  • Test sets are small: 100 NTREX rows and 200 dataset pairs.
  • No zero-width spaces (U+200B) were in the training data. Strip them from Khmer input before translating.

Use

Prompt. The chat template adds the special tokens.

Translate the following text into Khmer. Note that you should only output the translated result without any additional explanation:

<source text>

llama.cpp (tested with build 10675, commit 90c26fcd4):

llama-server -m hy18-kt6-Q8_0.gguf -ngl 99 -c 32768 -np 8 --jinja

transformers: load with AutoModelForCausalLM and the tokenizer files of this repo. Tencent's suggested sampling for the 1.8B is temperature 0.7, top_p 0.6, top_k 20, repetition penalty 1.05; all scores above are greedy.

Converting the transformers weights to GGUF again needs a patched convert_hf_to_gguf.py: llama.cpp identifies the pre-tokenizer by a fingerprint of how a test string tokenizes, and the new Khmer pieces change that fingerprint. The pre-tokenizer itself is unchanged, so the check is answered with hunyuan-dense.

What was done to the model

1. Tokenizer

  • 4,096 new pieces, ids 120818–124913. Vocabulary 120,818 → 124,914.
  • Method: BPE training continued from the stock tokenizer. The stock tokenizer is run over Khmer text, a normal BPE trainer learns further merges on its output, and those merges are appended after the stock merges. Stock merges keep their rank, so they always fire first.
  • A merge is kept only if its result contains Khmer bytes. Text in every other language tokenizes exactly as before (checked: 100 of 100 English sentences give identical ids).
  • No piece is longer than 6 Khmer characters (18 bytes). 6,000 merges were learned and the first 4,096 within that limit were kept.
  • Corpus for the pieces: 600,000 Khmer lines of an English–Khmer dataset plus the Khmer side of the 150,674 filtered training pairs; 3,984,082 Khmer word units.

2. New embedding rows

Input embedding and output head are one tied matrix in this model. Each new row starts as the mean of the rows of the base tokens the piece is built from, rescaled to the mean norm of those rows. Without the rescale the new rows had norm 0.42 against 0.84 for stock rows, which lowered their output logits.

3. Training

Stage 1 Stage 2
Trained the 4,096 new embedding rows only LoRA on every linear layer + the whole embedding matrix
Steps 600 8,000
Learning rate 1e-4 LoRA 2e-4, embeddings 1e-4
Time on the RTX 3090 382 s 7,395 s
  • LoRA: r 64, alpha 128, dropout 0.05, on q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj. Merged into the weights after training. Rank, alpha and dropout follow Tencent's published recipe (hy_dense_1_8b_lora_sft.yaml); Tencent's recipe adapts the attention layers only.
  • Optimizer AdamW, weight decay 0, gradient clipping 1.0. Warmup over the first 10% of steps, then cosine decay to 10% of the peak rate.
  • Batches of up to 2,500 tokens, examples grouped by length. bf16 autocast over fp32 weights, gradient checkpointing on. Seed 0.
  • Final training loss 0.751 (4.479 at the start of stage 2).

4. Training data

Loss is computed on the translation only. Share is the sampling weight of each kind.

Kind Pairs Share
English→Khmer, Khmer written by people (dataset) 67,388 17.9%
French→Khmer, Khmer written by people 22,861 5.7%
Chinese→Khmer, Khmer written by people 21,792 5.7%
Khmer→English, English written by people 24,269 5.7%
Khmer→French, French written by people 14,364 2.9%
Khmer→English, machine English (dataset) 67,388 3.6%
Khmer→French, Google French 22,861 2.1%
Khmer→Chinese, Google Chinese 21,792 2.1%
English→spoken Khmer, Khmer written by people 5,000 3.6%
Spoken Khmer→English, stock model output 5,000 1.4%
Replay: English→100 other languages, stock model output 20,893 9.3%
Replay reversed: other language→English 20,893 2.1%
Replay: Khmer→100 other languages, stock model output 10,258 7.1%
Replay reversed: other language→Khmer 10,258 2.1%
English→Khmer news, Google Khmer 200,000 28.6%
  • The first eight kinds passed a LaBSE similarity filter with cutoff 0.72 (150,674 of 160,000 sampled pairs kept). On this data the cutoff removes 5.3% of correct pairs and all mismatched pairs. The news pairs were not filtered.
  • Replay pairs are translations by the stock model itself. They keep the other languages from drifting: in an earlier version without Lao replay, Lao translations came out in Khmer script.
  • Prompt wording per example: Tencent's English prompt 60%, a close variant of it 25%, Tencent's Chinese prompt 15%.
  • Sources: a private English–Khmer set of 9.7 M pairs, and the private set DGC-AI/khmer-en-fr-zh-translations. The evaluation rows were never in training.

5. Hardware and time

GPU 1× NVIDIA GeForce RTX 3090, 24 GB
GPU memory during training 24.2 GB peak as reported by nvidia-smi (the whole card; measured on a short rerun of the same settings)
Machine Intel Core i9-13900K, 192 GB RAM, Windows Server 2022
Training time of this model 2 hours 10 minutes (7,777 s)
Speed 0.92 s per step
All experiments that led here (6 pilots + 1 control) about 10.5 GPU-hours on the same card
Software PyTorch 2.11.0+cu128, transformers 5.18.0, peft 0.22.0, tokenizers 0.23.2

System RAM use during training was not measured.

6. How the recipe was found

NTREX English→Khmer chrF is the out-of-domain check; the stock model scores 51.7.

Version Change NTREX 200 pairs en→km Khmer chars/s
Stock 51.7 54.1 106
Pilot 1 4,096 pieces, dataset pairs only, LoRA + embeddings 47.3 57.4 592
Pilot 2 + replay in 31 languages 46.9 55.9 584
Pilot 3 + replay in 100 languages, LaBSE-filtered four-language data, Tencent's LoRA settings 42.8 53.9 468
Control pilot 3 data and LoRA, stock tokenizer 52.5 60.5 99
Pilot 4 pieces capped at 6 characters, rescaled new rows, embedding LR 1e-4, LoRA on all linear layers 48.1 61.0 532
Pilot 5 pieces relearned without government-service boilerplate text, 6,000 steps 48.9 62.0 584
Pilot 6 (this model) + 200,000 news pairs, 8,000 steps 53.7 63.4 563

What the series showed:

  • The data alone helps (control). The quality loss in pilots 1–3 came from the tokenizer extension.
  • Pilots 1–3 also produced broken characters (1–5 per 100 NTREX outputs). Rescaled rows and a higher embedding learning rate removed them.
  • The last gap was a domain gap: every Khmer target before pilot 6 was government text, so the new pieces had never been trained on news Khmer.

License

Apache-2.0, as the base model tencent/Hy-MT3-1.8B.

Downloads last month
-
Safetensors
Model size
2B params
Tensor type
BF16
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for DGC-AI/Hy-MT3-1.8B-khmer-tokext

Quantized
(32)
this model