Translation
Transformers
ONNX
Safetensors
Khmer
blenderbot
text2text-generation
transliteration
romanization
romanized-khmer
khmer
character-level
int8
keyboard
on-device
Eval Results (legacy)
Instructions to use samdei/samdei-type-mini with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use samdei/samdei-type-mini with Transformers:
# Use a pipeline as a high-level helper # Warning: Pipeline type "translation" is no longer supported in transformers v5. # You must load the model directly (see below) or downgrade to v4.x with: # pip install "transformers<5.0.0" from transformers import pipeline pipe = pipeline("translation", model="samdei/samdei-type-mini")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForSeq2SeqLM tokenizer = AutoTokenizer.from_pretrained("samdei/samdei-type-mini") model = AutoModelForSeq2SeqLM.from_pretrained("samdei/samdei-type-mini", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Initial private draft of the Samdei Type release
Browse files- LICENSE +202 -0
- NOTICE +20 -0
- README.md +244 -0
- lm/wordfull_nowiki_p25.json.gz +3 -0
- onnx/decoder_step.int8.onnx +3 -0
- onnx/encoder_kv.int8.onnx +3 -0
- onnx/vocab.json +1 -0
- rerank.json +13 -0
LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
Apache License
|
| 3 |
+
Version 2.0, January 2004
|
| 4 |
+
http://www.apache.org/licenses/
|
| 5 |
+
|
| 6 |
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
| 7 |
+
|
| 8 |
+
1. Definitions.
|
| 9 |
+
|
| 10 |
+
"License" shall mean the terms and conditions for use, reproduction,
|
| 11 |
+
and distribution as defined by Sections 1 through 9 of this document.
|
| 12 |
+
|
| 13 |
+
"Licensor" shall mean the copyright owner or entity authorized by
|
| 14 |
+
the copyright owner that is granting the License.
|
| 15 |
+
|
| 16 |
+
"Legal Entity" shall mean the union of the acting entity and all
|
| 17 |
+
other entities that control, are controlled by, or are under common
|
| 18 |
+
control with that entity. For the purposes of this definition,
|
| 19 |
+
"control" means (i) the power, direct or indirect, to cause the
|
| 20 |
+
direction or management of such entity, whether by contract or
|
| 21 |
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
| 22 |
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
| 23 |
+
|
| 24 |
+
"You" (or "Your") shall mean an individual or Legal Entity
|
| 25 |
+
exercising permissions granted by this License.
|
| 26 |
+
|
| 27 |
+
"Source" form shall mean the preferred form for making modifications,
|
| 28 |
+
including but not limited to software source code, documentation
|
| 29 |
+
source, and configuration files.
|
| 30 |
+
|
| 31 |
+
"Object" form shall mean any form resulting from mechanical
|
| 32 |
+
transformation or translation of a Source form, including but
|
| 33 |
+
not limited to compiled object code, generated documentation,
|
| 34 |
+
and conversions to other media types.
|
| 35 |
+
|
| 36 |
+
"Work" shall mean the work of authorship, whether in Source or
|
| 37 |
+
Object form, made available under the License, as indicated by a
|
| 38 |
+
copyright notice that is included in or attached to the work
|
| 39 |
+
(an example is provided in the Appendix below).
|
| 40 |
+
|
| 41 |
+
"Derivative Works" shall mean any work, whether in Source or Object
|
| 42 |
+
form, that is based on (or derived from) the Work and for which the
|
| 43 |
+
editorial revisions, annotations, elaborations, or other modifications
|
| 44 |
+
represent, as a whole, an original work of authorship. For the purposes
|
| 45 |
+
of this License, Derivative Works shall not include works that remain
|
| 46 |
+
separable from, or merely link (or bind by name) to the interfaces of,
|
| 47 |
+
the Work and Derivative Works thereof.
|
| 48 |
+
|
| 49 |
+
"Contribution" shall mean any work of authorship, including
|
| 50 |
+
the original version of the Work and any modifications or additions
|
| 51 |
+
to that Work or Derivative Works thereof, that is intentionally
|
| 52 |
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
| 53 |
+
or by an individual or Legal Entity authorized to submit on behalf of
|
| 54 |
+
the copyright owner. For the purposes of this definition, "submitted"
|
| 55 |
+
means any form of electronic, verbal, or written communication sent
|
| 56 |
+
to the Licensor or its representatives, including but not limited to
|
| 57 |
+
communication on electronic mailing lists, source code control systems,
|
| 58 |
+
and issue tracking systems that are managed by, or on behalf of, the
|
| 59 |
+
Licensor for the purpose of discussing and improving the Work, but
|
| 60 |
+
excluding communication that is conspicuously marked or otherwise
|
| 61 |
+
designated in writing by the copyright owner as "Not a Contribution."
|
| 62 |
+
|
| 63 |
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
| 64 |
+
on behalf of whom a Contribution has been received by Licensor and
|
| 65 |
+
subsequently incorporated within the Work.
|
| 66 |
+
|
| 67 |
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
| 68 |
+
this License, each Contributor hereby grants to You a perpetual,
|
| 69 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
| 70 |
+
copyright license to reproduce, prepare Derivative Works of,
|
| 71 |
+
publicly display, publicly perform, sublicense, and distribute the
|
| 72 |
+
Work and such Derivative Works in Source or Object form.
|
| 73 |
+
|
| 74 |
+
3. Grant of Patent License. Subject to the terms and conditions of
|
| 75 |
+
this License, each Contributor hereby grants to You a perpetual,
|
| 76 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
| 77 |
+
(except as stated in this section) patent license to make, have made,
|
| 78 |
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
| 79 |
+
where such license applies only to those patent claims licensable
|
| 80 |
+
by such Contributor that are necessarily infringed by their
|
| 81 |
+
Contribution(s) alone or by combination of their Contribution(s)
|
| 82 |
+
with the Work to which such Contribution(s) was submitted. If You
|
| 83 |
+
institute patent litigation against any entity (including a
|
| 84 |
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
| 85 |
+
or a Contribution incorporated within the Work constitutes direct
|
| 86 |
+
or contributory patent infringement, then any patent licenses
|
| 87 |
+
granted to You under this License for that Work shall terminate
|
| 88 |
+
as of the date such litigation is filed.
|
| 89 |
+
|
| 90 |
+
4. Redistribution. You may reproduce and distribute copies of the
|
| 91 |
+
Work or Derivative Works thereof in any medium, with or without
|
| 92 |
+
modifications, and in Source or Object form, provided that You
|
| 93 |
+
meet the following conditions:
|
| 94 |
+
|
| 95 |
+
(a) You must give any other recipients of the Work or
|
| 96 |
+
Derivative Works a copy of this License; and
|
| 97 |
+
|
| 98 |
+
(b) You must cause any modified files to carry prominent notices
|
| 99 |
+
stating that You changed the files; and
|
| 100 |
+
|
| 101 |
+
(c) You must retain, in the Source form of any Derivative Works
|
| 102 |
+
that You distribute, all copyright, patent, trademark, and
|
| 103 |
+
attribution notices from the Source form of the Work,
|
| 104 |
+
excluding those notices that do not pertain to any part of
|
| 105 |
+
the Derivative Works; and
|
| 106 |
+
|
| 107 |
+
(d) If the Work includes a "NOTICE" text file as part of its
|
| 108 |
+
distribution, then any Derivative Works that You distribute must
|
| 109 |
+
include a readable copy of the attribution notices contained
|
| 110 |
+
within such NOTICE file, excluding those notices that do not
|
| 111 |
+
pertain to any part of the Derivative Works, in at least one
|
| 112 |
+
of the following places: within a NOTICE text file distributed
|
| 113 |
+
as part of the Derivative Works; within the Source form or
|
| 114 |
+
documentation, if provided along with the Derivative Works; or,
|
| 115 |
+
within a display generated by the Derivative Works, if and
|
| 116 |
+
wherever such third-party notices normally appear. The contents
|
| 117 |
+
of the NOTICE file are for informational purposes only and
|
| 118 |
+
do not modify the License. You may add Your own attribution
|
| 119 |
+
notices within Derivative Works that You distribute, alongside
|
| 120 |
+
or as an addendum to the NOTICE text from the Work, provided
|
| 121 |
+
that such additional attribution notices cannot be construed
|
| 122 |
+
as modifying the License.
|
| 123 |
+
|
| 124 |
+
You may add Your own copyright statement to Your modifications and
|
| 125 |
+
may provide additional or different license terms and conditions
|
| 126 |
+
for use, reproduction, or distribution of Your modifications, or
|
| 127 |
+
for any such Derivative Works as a whole, provided Your use,
|
| 128 |
+
reproduction, and distribution of the Work otherwise complies with
|
| 129 |
+
the conditions stated in this License.
|
| 130 |
+
|
| 131 |
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
| 132 |
+
any Contribution intentionally submitted for inclusion in the Work
|
| 133 |
+
by You to the Licensor shall be under the terms and conditions of
|
| 134 |
+
this License, without any additional terms or conditions.
|
| 135 |
+
Notwithstanding the above, nothing herein shall supersede or modify
|
| 136 |
+
the terms of any separate license agreement you may have executed
|
| 137 |
+
with Licensor regarding such Contributions.
|
| 138 |
+
|
| 139 |
+
6. Trademarks. This License does not grant permission to use the trade
|
| 140 |
+
names, trademarks, service marks, or product names of the Licensor,
|
| 141 |
+
except as required for reasonable and customary use in describing the
|
| 142 |
+
origin of the Work and reproducing the content of the NOTICE file.
|
| 143 |
+
|
| 144 |
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
| 145 |
+
agreed to in writing, Licensor provides the Work (and each
|
| 146 |
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
| 147 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
| 148 |
+
implied, including, without limitation, any warranties or conditions
|
| 149 |
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
| 150 |
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
| 151 |
+
appropriateness of using or redistributing the Work and assume any
|
| 152 |
+
risks associated with Your exercise of permissions under this License.
|
| 153 |
+
|
| 154 |
+
8. Limitation of Liability. In no event and under no legal theory,
|
| 155 |
+
whether in tort (including negligence), contract, or otherwise,
|
| 156 |
+
unless required by applicable law (such as deliberate and grossly
|
| 157 |
+
negligent acts) or agreed to in writing, shall any Contributor be
|
| 158 |
+
liable to You for damages, including any direct, indirect, special,
|
| 159 |
+
incidental, or consequential damages of any character arising as a
|
| 160 |
+
result of this License or out of the use or inability to use the
|
| 161 |
+
Work (including but not limited to damages for loss of goodwill,
|
| 162 |
+
work stoppage, computer failure or malfunction, or any and all
|
| 163 |
+
other commercial damages or losses), even if such Contributor
|
| 164 |
+
has been advised of the possibility of such damages.
|
| 165 |
+
|
| 166 |
+
9. Accepting Warranty or Additional Liability. While redistributing
|
| 167 |
+
the Work or Derivative Works thereof, You may choose to offer,
|
| 168 |
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
| 169 |
+
or other liability obligations and/or rights consistent with this
|
| 170 |
+
License. However, in accepting such obligations, You may act only
|
| 171 |
+
on Your own behalf and on Your sole responsibility, not on behalf
|
| 172 |
+
of any other Contributor, and only if You agree to indemnify,
|
| 173 |
+
defend, and hold each Contributor harmless for any liability
|
| 174 |
+
incurred by, or claims asserted against, such Contributor by reason
|
| 175 |
+
of your accepting any such warranty or additional liability.
|
| 176 |
+
|
| 177 |
+
END OF TERMS AND CONDITIONS
|
| 178 |
+
|
| 179 |
+
APPENDIX: How to apply the Apache License to your work.
|
| 180 |
+
|
| 181 |
+
To apply the Apache License to your work, attach the following
|
| 182 |
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
| 183 |
+
replaced with your own identifying information. (Don't include
|
| 184 |
+
the brackets!) The text should be enclosed in the appropriate
|
| 185 |
+
comment syntax for the file format. We also recommend that a
|
| 186 |
+
file or class name and description of purpose be included on the
|
| 187 |
+
same "printed page" as the copyright notice for easier
|
| 188 |
+
identification within third-party archives.
|
| 189 |
+
|
| 190 |
+
Copyright [yyyy] [name of copyright owner]
|
| 191 |
+
|
| 192 |
+
Licensed under the Apache License, Version 2.0 (the "License");
|
| 193 |
+
you may not use this file except in compliance with the License.
|
| 194 |
+
You may obtain a copy of the License at
|
| 195 |
+
|
| 196 |
+
http://www.apache.org/licenses/LICENSE-2.0
|
| 197 |
+
|
| 198 |
+
Unless required by applicable law or agreed to in writing, software
|
| 199 |
+
distributed under the License is distributed on an "AS IS" BASIS,
|
| 200 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 201 |
+
See the License for the specific language governing permissions and
|
| 202 |
+
limitations under the License.
|
NOTICE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Samdei Type Mini
|
| 2 |
+
Copyright 2026 The Samdei Type Authors
|
| 3 |
+
|
| 4 |
+
Licensed under the Apache License, Version 2.0 (see LICENSE). This covers every file in this
|
| 5 |
+
repository: the ONNX graphs, onnx/vocab.json, rerank.json and the word language model.
|
| 6 |
+
|
| 7 |
+
Word language model (lm/wordfull_nowiki_p25.json.gz)
|
| 8 |
+
Word unigram and bigram counts of Khmer text, built without Wikipedia, from:
|
| 9 |
+
- HPLT v2 (HPLT/HPLT2.0_cleaned, khm_Khmr): CC0 packaging; the Common Crawl Terms of Use
|
| 10 |
+
apply to the text.
|
| 11 |
+
- FineWeb-2 (HuggingFaceFW/fineweb-2, khm_Khmr): ODC-By 1.0; the Common Crawl Terms of Use
|
| 12 |
+
apply to the text.
|
| 13 |
+
- Asian Language Treebank (ALT), Khmer side: CC BY 4.0.
|
| 14 |
+
- Samdei Type chat sentences (samdei/samdei-type-resources): CC BY 4.0.
|
| 15 |
+
|
| 16 |
+
Training data
|
| 17 |
+
The model was trained on samdei/samdei-type-pretraining-data and
|
| 18 |
+
samdei/samdei-type-finetuning-data (CC BY-SA 4.0); their cards list every source. Part of the
|
| 19 |
+
fine-tuning pairs were spelled with a table derived from the Chhunneng romanized Khmer
|
| 20 |
+
dataset, MIT License, Copyright (c) 2025 Chrea Chanchhunneng.
|
README.md
ADDED
|
@@ -0,0 +1,244 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
language:
|
| 4 |
+
- km
|
| 5 |
+
library_name: onnx
|
| 6 |
+
pipeline_tag: text2text-generation
|
| 7 |
+
tags:
|
| 8 |
+
- transliteration
|
| 9 |
+
- romanization
|
| 10 |
+
- romanized-khmer
|
| 11 |
+
- khmer
|
| 12 |
+
- character-level
|
| 13 |
+
- onnx
|
| 14 |
+
- int8
|
| 15 |
+
- keyboard
|
| 16 |
+
- on-device
|
| 17 |
+
base_model: samdei/samdei-type-pretrained
|
| 18 |
+
base_model_relation: finetune
|
| 19 |
+
datasets:
|
| 20 |
+
- samdei/samdei-type-pretraining-data
|
| 21 |
+
- samdei/samdei-type-finetuning-data
|
| 22 |
+
metrics:
|
| 23 |
+
- cer
|
| 24 |
+
- exact_match
|
| 25 |
+
model-index:
|
| 26 |
+
- name: Samdei Type Mini
|
| 27 |
+
results:
|
| 28 |
+
- task:
|
| 29 |
+
type: text2text-generation
|
| 30 |
+
name: Romanized Khmer to Khmer script
|
| 31 |
+
dataset:
|
| 32 |
+
type: samdei/samdei-type-bench
|
| 33 |
+
name: Samdei Type Bench
|
| 34 |
+
split: test
|
| 35 |
+
metrics:
|
| 36 |
+
- type: cer
|
| 37 |
+
value: 0.058
|
| 38 |
+
name: CER (beam 5, word-LM rerank, 8-word pieces)
|
| 39 |
+
- type: exact_match
|
| 40 |
+
value: 0.239
|
| 41 |
+
name: Exact match
|
| 42 |
+
---
|
| 43 |
+
|
| 44 |
+
# Samdei Type Mini
|
| 45 |
+
|
| 46 |
+
Samdei Type Mini converts romanized Khmer, as people type it in chat, into Khmer script:
|
| 47 |
+
|
| 48 |
+
| Input | Output |
|
| 49 |
+
|---|---|
|
| 50 |
+
| `knhom jong tov phsar` | ខ្ញុំចង់ទៅផ្សារ |
|
| 51 |
+
| `ot mean wifi te` | អត់មាន wifi ទេ |
|
| 52 |
+
|
| 53 |
+
It is a 7.1M-parameter character-level Transformer encoder-decoder. It ships as int8 ONNX (7.0 MiB), with a 1.2 MiB word bigram LM that reranks its candidates. Mini is meant for on-device use, such as a phone keyboard that offers Khmer-script candidates as the user types.
|
| 54 |
+
|
| 55 |
+
Samdei (សំដី, "what you say") is our team, and Samdei Type is the converter. The family has three models:
|
| 56 |
+
|
| 57 |
+
| Model | Parameters | Released as | Samdei Type Bench CER / exact |
|
| 58 |
+
|---|---|---|---|
|
| 59 |
+
| **Samdei Type Mini** (this repo) | 7.1M | int8 ONNX + pruned word LM | 0.058 / 24% |
|
| 60 |
+
| Samdei Type Base | 18.2M | PyTorch + int8 ONNX + LMs + channel model: [`samdei/samdei-type-base`](https://huggingface.co/samdei/samdei-type-base) | 0.052 / 30% |
|
| 61 |
+
| Samdei Type Prime | 18.2M | not released | 0.027 / 61% |
|
| 62 |
+
|
| 63 |
+
Samdei Type Prime is Base trained further on scenario-designed, LLM-drafted, human-audited data. It is not released.
|
| 64 |
+
|
| 65 |
+
The pretrained (stage-1) checkpoints of both sizes, for fine-tuning your own converter, are in [`samdei/samdei-type-pretrained`](https://huggingface.co/samdei/samdei-type-pretrained).
|
| 66 |
+
|
| 67 |
+
Paper: *Samdei Type: Separating What Is Written from How It Is Spelled for Romanized Khmer Transliteration* (`<paper-url>`). Code: `<code-repo-url>`.
|
| 68 |
+
|
| 69 |
+
## Files
|
| 70 |
+
|
| 71 |
+
```
|
| 72 |
+
onnx/encoder_kv.int8.onnx 5.0 MiB input characters -> cross-attention K/V of every decoder layer
|
| 73 |
+
onnx/decoder_step.int8.onnx 2.0 MiB one decoder step with a self-attention KV cache
|
| 74 |
+
onnx/vocab.json vocabularies and graph shapes (layers, heads, head_dim, bos, eos, max_src_len)
|
| 75 |
+
lm/wordfull_nowiki_p25.json.gz 1.2 MiB word bigram LM over khmercut words, pruned to bigram count >= 25 (gzipped JSON)
|
| 76 |
+
rerank.json decoding and rerank settings used for every number below
|
| 77 |
+
```
|
| 78 |
+
|
| 79 |
+
## Intended use
|
| 80 |
+
|
| 81 |
+
- **Inside a keyboard:** turn what a user types in Latin letters into a list of Khmer-script candidates on every keystroke, offline.
|
| 82 |
+
- **Reading:** show someone else's romanized message in Khmer script.
|
| 83 |
+
- **Mixed text:** English words, numbers and brand names are copied through unchanged.
|
| 84 |
+
|
| 85 |
+
**Out of scope:**
|
| 86 |
+
- the reverse direction (Khmer → Latin);
|
| 87 |
+
- official romanization standards, such as names in documents;
|
| 88 |
+
- any setting where the user cannot see and correct the output. The model makes mistakes on homophones and rare words (see Limitations).
|
| 89 |
+
|
| 90 |
+
## How to use
|
| 91 |
+
|
| 92 |
+
Install the `rkhmer` package from the code repository:
|
| 93 |
+
|
| 94 |
+
```bash
|
| 95 |
+
pip install "rkhmer[deploy] @ git+<code-repo-url>"
|
| 96 |
+
```
|
| 97 |
+
|
| 98 |
+
```python
|
| 99 |
+
from huggingface_hub import snapshot_download
|
| 100 |
+
from rkhmer.evaluation import chunk_source
|
| 101 |
+
from rkhmer.onnx_infer import OnnxConverter
|
| 102 |
+
from rkhmer.rerank import Reranker, load_weights
|
| 103 |
+
|
| 104 |
+
d = snapshot_download("samdei/samdei-type-mini", allow_patterns=["onnx/*", "lm/*", "rerank.json"])
|
| 105 |
+
conv = OnnxConverter(f"{d}/onnx") # int8 graphs + vocab.json, numpy + onnxruntime only
|
| 106 |
+
rr = Reranker(load_weights(f"{d}/rerank.json"), wordlm=f"{d}/lm/wordfull_nowiki_p25.json.gz")
|
| 107 |
+
|
| 108 |
+
def convert(text: str) -> str:
|
| 109 |
+
out = []
|
| 110 |
+
for piece in chunk_source(text, 8): # at most 8 words per piece, break after punctuation
|
| 111 |
+
hyps = conv.beam(piece, k=5) # [(khmer, logprob), ...], best first
|
| 112 |
+
out.append(rr.rerank(piece, hyps)[0][0])
|
| 113 |
+
return " ".join(out)
|
| 114 |
+
|
| 115 |
+
print(convert("knhom jong tov phsar")) # ខ្ញុំចង់ទៅផ្សារ
|
| 116 |
+
```
|
| 117 |
+
|
| 118 |
+
**Decoding, as in the paper.**
|
| 119 |
+
- Beam search with k = 5.
|
| 120 |
+
- The input is cut into pieces of at most eight words, with a break after any punctuation mark. Each piece is decoded and reranked on its own, and the outputs are joined with a space.
|
| 121 |
+
- Each hypothesis y for input x is scored as `log P(y|x) + 0.3 · log P_word(y) − 1.0 · #OOV(y)`. The weights were tuned on a closed development set, and `rerank.json` holds them.
|
| 122 |
+
- Inputs are truncated to 249 characters.
|
| 123 |
+
|
| 124 |
+
**On a phone.**
|
| 125 |
+
- The two graphs are all a runtime needs.
|
| 126 |
+
- `encoder_kv` runs once per input.
|
| 127 |
+
- `decoder_step` maps the newest token, its position, the past self-attention K/V and the cross-attention K/V to the logits and the new K/V. It has a dynamic batch axis, so all beams run in one call.
|
| 128 |
+
- `rkhmer/onnx_infer.py` is a reference implementation in plain numpy (no torch) to port from.
|
| 129 |
+
- The cached decoder reproduces full re-decoding exactly. Int8 quantization does not change CER on Dev-Sentences with beam 5 and no LMs (0.010 in fp32 and in int8).
|
| 130 |
+
|
| 131 |
+
## Model
|
| 132 |
+
|
| 133 |
+
| | Samdei Type Mini |
|
| 134 |
+
|---|---|
|
| 135 |
+
| Architecture | pre-LN Transformer encoder-decoder, GELU, learned positions up to 256, untied output projection |
|
| 136 |
+
| d_model / heads | 256 / 4 |
|
| 137 |
+
| Encoder / decoder layers | 6 / 2 (deep encoder, shallow decoder) |
|
| 138 |
+
| FFN width | 1024 |
|
| 139 |
+
| Parameters | 7,149,540 |
|
| 140 |
+
| Vocabulary | 215 input symbols (Latin letters, digits, punctuation, space), 228 output symbols (Khmer code points, space, copied characters), including special tokens |
|
| 141 |
+
| int8 ONNX | 7.0 MiB as released (7.6 MiB in the paper, with the exporter's debug metadata) |
|
| 142 |
+
|
| 143 |
+
## Training
|
| 144 |
+
|
| 145 |
+
Mini was trained in three stages. Each stage started from the best checkpoint of the stage before and replayed its data.
|
| 146 |
+
|
| 147 |
+
| | Stage 1: pretraining | Stage 2: fine-tuning | Stage 3: adaptation |
|
| 148 |
+
|---|---|---|---|
|
| 149 |
+
| New data | rule-based persona generator applied to 1.41M web sentences and the 2.4k LLM-written chat sentences (6.50M pairs), + Gemma 4 romanizations of real sentences (5.7k ×3) | chat-heavy generator sample 630k; Gemma 4 romanizations 18.3k ×4; pairs spelled with the table mined from the Chhunneng word list 290k; chat-like abbreviated copies 140k + 16k ×2 | casual-register pairs 427k (spoken-register web sentences, stretched letters) |
|
| 150 |
+
| Replayed | – | – | the stage-2 mix |
|
| 151 |
+
| Total pairs | 6.5M | 1.16M | 1.59M |
|
| 152 |
+
| Steps (best checkpoint) | 40k (35k) | 6k (4k) | 3k (2.5k) |
|
| 153 |
+
| Peak lr, warmup | 1e-3, 2k | 2e-4, 300 | 1e-4, 100 |
|
| 154 |
+
| Wall clock | 2.2 h | about 31–36 min | about 10–12 min |
|
| 155 |
+
|
| 156 |
+
**Shared settings:**
|
| 157 |
+
- AdamW (β 0.9 / 0.98, weight decay 0.01), cosine decay to 5% of the peak, label smoothing 0.1;
|
| 158 |
+
- about 12k tokens per batch, bf16 autocast;
|
| 159 |
+
- one laptop GPU (Apple M5 Pro).
|
| 160 |
+
|
| 161 |
+
**Checkpoint selection:**
|
| 162 |
+
- Stages 1–2: the lowest mean greedy CER on Dev-Sentences and Akkhara-Preview. Akkhara-Preview is the 110-row public preview of Akkhara-Sing-Khmer; it was used for this selection only and never trained on.
|
| 163 |
+
- Stage 3: the lowest greedy CER on the first 400 messages of a closed development set.
|
| 164 |
+
|
| 165 |
+
**Data.** The exact training files are published:
|
| 166 |
+
- **Stage 1:** [`samdei/samdei-type-pretraining-data`](https://huggingface.co/datasets/samdei/samdei-type-pretraining-data), configs `generator_v2` and `llm_romanized`. The pretrained checkpoint is `mini/` in [`samdei/samdei-type-pretrained`](https://huggingface.co/samdei/samdei-type-pretrained).
|
| 167 |
+
- **Stages 2–3:** [`samdei/samdei-type-finetuning-data`](https://huggingface.co/datasets/samdei/samdei-type-finetuning-data). Mini uses `mined_tables_chh`.
|
| 168 |
+
|
| 169 |
+
Each repo's `recipes.json` gives the exact mix.
|
| 170 |
+
- **Khmer targets.** Always real text, except 2,483 chat sentences written by Gemma 4. The text comes from HPLT v2, FineWeb-2, Khmer Wikipedia and ALT.
|
| 171 |
+
- **Romanized inputs.** These come from:
|
| 172 |
+
- the persona generator, which uses Google's Khmer pronunciation lexicon;
|
| 173 |
+
- a spelling table mined from the Chhunneng word list;
|
| 174 |
+
- Gemma 4 romanizations of real sentences;
|
| 175 |
+
- chat-like abbreviations.
|
| 176 |
+
- **Not used:** no evaluation set, and no data of other romanization systems (in particular, no Akkhara-Sing-Khmer data).
|
| 177 |
+
|
| 178 |
+
## Evaluation
|
| 179 |
+
|
| 180 |
+
**Samdei Type Bench** ([`samdei/samdei-type-bench`](https://huggingface.co/datasets/samdei/samdei-type-bench)) has 2,155 everyday messages and words with human-checked Khmer. 192 of them were typed blind by native speakers. Inputs have a median of 81 characters.
|
| 181 |
+
|
| 182 |
+
- **Metric.** Character error rate (CER) after normalization (`khnormal`, spaces removed, lowercase, coeng-DA merged with coeng-TA, ឲ merged with ឱ) and exact match, on each item's main input and main target.
|
| 183 |
+
- **Same code for every system:** `rkhmer.evaluation.score`.
|
| 184 |
+
|
| 185 |
+
| System | Parameters | int8 size | CER | Exact |
|
| 186 |
+
|---|---|---|---|---|
|
| 187 |
+
| **Samdei Type Mini** | 7.1M | 7.6 MiB | 0.058 | 24% |
|
| 188 |
+
| Samdei Type Base | 18.2M | 18.2 MiB | **0.052** | **30%** |
|
| 189 |
+
| Samdei Type Prime (not released) | 18.2M | 18.2 MiB | 0.027 | 61% |
|
| 190 |
+
| Akkhara-mini, whole input | 17.8M | 17.6 MiB | 0.159 | 27% |
|
| 191 |
+
| Akkhara-mini, 6-word pieces | 17.8M | 17.6 MiB | 0.066 | 23% |
|
| 192 |
+
| AkaraAlpha, word by word | 0.08M | – | 0.281 | 2% |
|
| 193 |
+
|
| 194 |
+
- **Prime is partly in-domain.** Its training data shares the scenario design of most Samdei Type Bench items, so its lead is an upper bound.
|
| 195 |
+
- **Reranking.** Beam 5 alone gives 0.072 / 17%; the pruned word LM brings it to 0.058 / 24%.
|
| 196 |
+
- **Decode long messages in pieces.** Mini was trained on short pieces (inputs of at most 132 characters, median 26). With beam 5 and no LMs, whole-input CER is 0.218 overall and 0.558 on inputs over 132 characters, against 0.072 and 0.076 in pieces.
|
| 197 |
+
- **Reference sets** (CER / exact): Dev-Sentences 0.005 / 95%, Chat-Words 0.081 / 84%, Dict-Words 0.282 / 34%, Casual-Synth 0.055 / 62%.
|
| 198 |
+
- **Speed.** One M5 Pro CPU thread, int8 ONNX, without reranking:
|
| 199 |
+
- greedy: 2.2 ms p50 / 4.2 ms p95 per input;
|
| 200 |
+
- beam 5: 4.9 / 10.0 ms.
|
| 201 |
+
- Per keystroke in the live demo, with the word-LM rerank: 5.7 ms p50 / 17.2 ms p95.
|
| 202 |
+
- Not yet measured on a phone.
|
| 203 |
+
|
| 204 |
+
## Limitations
|
| 205 |
+
|
| 206 |
+
- **Synthetic training inputs.** Every romanized input Mini has seen comes from rules, mined tables or an LLM; real typing appears only in the evaluation.
|
| 207 |
+
- **Homophones that need more context than a word bigram gives**, for example:
|
| 208 |
+
- ដើរ / ដែរ (`der`);
|
| 209 |
+
- ដឹក / ដែក / ដេក (`dek`);
|
| 210 |
+
- អាទិត្យ / អតីត (`atit`);
|
| 211 |
+
- the polite particle បាទ against បាត់ ("lost") at the end of a message.
|
| 212 |
+
- **Spoken-register words that share a spelling with a written word:** `nung` is ហ្នឹង in chat and និង ("and") in prose.
|
| 213 |
+
- **Loanwords typed in English** (`check` for ឆែក) are copied through as English.
|
| 214 |
+
- **Punctuation.** Mini copies a Latin comma where Khmer uses a space, and never adds a final ។ that the input lacks.
|
| 215 |
+
- **Heavy abbreviation and dictionary words.** Mini is weaker on input abbreviated more heavily than its training data and on rare dictionary words without context, many of them Pali-Sanskrit (Dict-Words CER 0.282).
|
| 216 |
+
- **Web text.** The Khmer side comes mostly from web text and carries its topics and biases.
|
| 217 |
+
|
| 218 |
+
## License and attribution
|
| 219 |
+
|
| 220 |
+
- **Everything in this repo** (ONNX graphs, vocabulary, rerank settings, word LM): Apache-2.0. The full text is in `LICENSE`. `NOTICE` holds the attributions, and redistributions must keep it.
|
| 221 |
+
- **`lm/wordfull_nowiki_p25.json.gz`:** word n-gram counts built without Wikipedia, from:
|
| 222 |
+
- HPLT v2 (CC0 packaging; Common Crawl terms apply to the text);
|
| 223 |
+
- FineWeb-2 (ODC-By 1.0);
|
| 224 |
+
- ALT (CC BY 4.0);
|
| 225 |
+
- our LLM-written chat sentences (CC BY 4.0; written with Gemma 4, Apache-2.0).
|
| 226 |
+
- **Training data:** CC BY-SA 4.0; see the dataset cards. Its sources are:
|
| 227 |
+
- HPLT v2, FineWeb-2, Khmer Wikipedia (CC BY-SA) and ALT;
|
| 228 |
+
- Google's Khmer pronunciation lexicon (CC BY 4.0);
|
| 229 |
+
- the Chhunneng romanized Khmer dataset (MIT, © 2025 Chrea Chanchhunneng);
|
| 230 |
+
- Gemma 4 output (Apache-2.0).
|
| 231 |
+
- **Tools:** `khmercut` (Apache-2.0) and SIL `khnormal` (MIT).
|
| 232 |
+
|
| 233 |
+
## Citation
|
| 234 |
+
|
| 235 |
+
```bibtex
|
| 236 |
+
@misc{samdei-type-2026,
|
| 237 |
+
title = {Samdei Type: Separating What Is Written from How It Is Spelled for Romanized Khmer Transliteration},
|
| 238 |
+
author = {<authors>},
|
| 239 |
+
year = {2026},
|
| 240 |
+
url = {<paper-url>}
|
| 241 |
+
}
|
| 242 |
+
```
|
| 243 |
+
|
| 244 |
+
Contact: `<contact>`
|
lm/wordfull_nowiki_p25.json.gz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:6acd33fa23ef4b0c77318d53823212a46cdc87eb21d786603421453886ef4051
|
| 3 |
+
size 1213177
|
onnx/decoder_step.int8.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:2808c03ce9482819a367e0ce933be11e8215634e3c016d9ef10c020f462a3d58
|
| 3 |
+
size 2093997
|
onnx/encoder_kv.int8.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d4c8c57b7a10bd05dd4d1292114adb44a311e3521754e181d9065f5be6f65eb3
|
| 3 |
+
size 5269088
|
onnx/vocab.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"src_vocab": [" ", "!", "\"", "#", "$", "%", "&", "'", "(", ")", "*", "+", ",", "-", ".", "/", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", ":", ";", "<", "=", ">", "?", "@", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "[", "]", "^", "_", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "|", "~", "¡", "«", "®", "°", "·", "»", "×", "á", "ç", "è", "é", "í", "ǔ", "ɓ", "ə", "ก", "ท", "น", "ภ", "ย", "ร", "ษ", "า", "ิ", "เ", "ไ", "๒", "๕", "ລ", "ວ", "ສ", "າ", "ក", "ខ", "គ", "ឃ", "ង", "ច", "ឆ", "ជ", "ឈ", "ញ", "ដ", "ឋ", "ឌ", "ណ", "ត", "ថ", "ទ", "ធ", "ន", "ប", "ផ", "ព", "ភ", "ម", "យ", "រ", "ល", "វ", "ស", "ហ", "ឡ", "អ", "ឧ", "ឫ", "ឬ", "ឯ", "ឲ", "ា", "ិ", "ី", "ឹ", "ឺ", "ុ", "ូ", "ួ", "ើ", "ឿ", "ៀ", "េ", "ែ", "ៃ", "ោ", "ៅ", "ំ", "ះ", "ៈ", "៉", "៊", "់", "៌", "៍", "៏", "័", "្", "។", "៕", "៖", "ៗ", "៘", "៛", "‑", "–", "—", "‘", "’", "“", "”", "•", "…", "‹", "›", "→", "−", "●", "�", "😀", "😛", "🙂"], "tgt_vocab": [" ", "!", "\"", "#", "$", "%", "&", "'", "(", ")", "*", "+", ",", "-", ".", "/", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", ":", ";", "<", "=", ">", "?", "@", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "[", "]", "^", "_", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "|", "~", "¡", "«", "®", "°", "·", "»", "×", "à", "á", "ç", "è", "é", "í", "ǔ", "ก", "ท", "น", "ภ", "ย", "ร", "ษ", "า", "ิ", "เ", "ไ", "๒", "๕", "ລ", "ວ", "ສ", "າ", "ក", "ខ", "គ", "ឃ", "ង", "ច", "ឆ", "ជ", "ឈ", "ញ", "ដ", "ឋ", "ឌ", "ឍ", "ណ", "ត", "ថ", "ទ", "ធ", "ន", "ប", "ផ", "ព", "ភ", "ម", "យ", "រ", "ល", "វ", "ឝ", "ឞ", "ស", "ហ", "ឡ", "អ", "ឥ", "ឦ", "ឧ", "ឩ", "ឪ", "ឫ", "ឬ", "ឭ", "ឮ", "ឯ", "ឰ", "ឱ", "ឲ", "ឳ", "ា", "ិ", "ី", "ឹ", "ឺ", "ុ", "ូ", "ួ", "ើ", "ឿ", "ៀ", "េ", "ែ", "ៃ", "ោ", "ៅ", "ំ", "ះ", "ៈ", "៉", "៊", "់", "៌", "៍", "៎", "៏", "័", "៑", "្", "។", "៕", "៖", "ៗ", "៘", "៛", "‑", "–", "—", "‘", "’", "“", "”", "•", "…", "‹", "›", "→", "−", "●", "�", "😀", "😛", "🙂"], "layers": 2, "heads": 4, "head_dim": 64, "bos": 1, "eos": 2, "max_src_len": 249}
|
rerank.json
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"model": "Samdei Type Mini",
|
| 3 |
+
"beam": 5,
|
| 4 |
+
"chunk_max_words": 8,
|
| 5 |
+
"chunk_rule": "rkhmer.evaluation.chunk_source: at most 8 words per piece, break after any punctuation mark; pieces are decoded and reranked on their own and joined with a space",
|
| 6 |
+
"rerank_weights": {"char": 0.0, "word": 0.3, "oov": 1.0, "channel": 0.0},
|
| 7 |
+
"score": "log P(y|x) + char*log P_char(y) + word*log P_word(y) - oov*#OOV(y) + channel*log P_ch(x|y)",
|
| 8 |
+
"char_lm": null,
|
| 9 |
+
"word_lm": "lm/wordfull_nowiki_p25.json.gz",
|
| 10 |
+
"channel_model": null,
|
| 11 |
+
"max_input_chars": 249,
|
| 12 |
+
"weights_tuned_on": "closed development set, whole input, 2-fold cross-validated grid search; applied unchanged to 8-word pieces"
|
| 13 |
+
}
|