Downloads · 30 days
77
8% of all-time downloads
davor/ayutthayaalpha-2.0-early-beta
ayutthayaalpha-2.0-early-beta is a other model from davor. Use it for the other task on the model card, and read the license before you ship it in a product. It is set up for transformers. The card lists the license as mit.
AyutthayaAlpha 2.0 is a Thai–Latin script transliteration Transformer for personal and organization names.
Downloads · 30 days
77
8% of all-time downloads
All-time downloads
1K
Public
Parameters
73.5M
294 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors294 MB · 99%
From the Hugging Face model README
AyutthayaAlpha 2.0 is a Thai–Latin script transliteration Transformer for personal and organization names.
Transliteration — converting text from one writing system to another while preserving how it sounds and respecting cultural conventions — is a core challenge in multilingual NLP. Unlike translation, which focuses on meaning, transliteration aims to maintain pronunciation as well as historical and cultural preferences (Knight & Graehl, 1998; Rosca & Breuel, 2016; Merhav & Ash, 2018; Prabhakar & Pal, 2018).
Thai name romanization is particularly difficult: Thai orthography under-specifies pronunciation, tones are usually dropped in Latin script, and multiple romanization standards and idiosyncratic spellings coexist in real data (Aroonmanakun, 2004; Leung, 2007; Suchato, 2012). The same Thai name can appear under many Latin spellings, depending on domain, period, and personal preference.
AyutthayaAlpha 2.0 treats transliteration as a preference-aware ranking problem over multiple plausible variants. It builds on the original AyutthayaAlpha system (Lauc, 2024) and combines large-scale data curation, a Thai Transliteration Distance metric, and quality-weighted objectives to produce ranked lists of transliterations optimized for both orthographic plausibility and phonetic proximity.
<latn>: Thai → Latin transliteration<thai>: Latin → Thai back-transliteration<latn> prefix)<thai> prefix)For full details, see the accompanying AyutthayaAlpha 2.0 paper (Lauc, Rutherford, & Wongwarawipatr, 2025, in preparation).
Very important: you must prepend a special token that indicates the direction.
Thai → Latin (romanization)
<latn> followed by a Thai name"<latn>สมชาย""Somchai"Latin → Thai (back-transliteration)
<thai> followed by a Latin-script name"<thai>somchai""สมชาย"Maximum total sequence length used in training was 128 subword tokens (source + target); typical names are much shorter.
from transformers import AutoTokenizer, T5ForConditionalGeneration
model_id = "davor/ayutthayaalpha-2.0-early-beta"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = T5ForConditionalGeneration.from_pretrained(model_id)
def translit_thai_to_latin(name_thai: str) -> str:
text = "<latn>" + name_thai
inputs = tokenizer(text, return_tensors="pt")
inputs.pop("token_type_ids", None) # some tokenizers add this key
output = model.generate(
input_ids=inputs["input_ids"],
attention_mask=inputs["attention_mask"],
max_length=32,
min_length=2,
num_beams=5,
do_sample=False,
)
return tokenizer.decode(output[0], skip_special_tokens=True)
def translit_latin_to_thai(name_latin: str) -> str:
text = "<thai>" + name_latin
inputs = tokenizer(text, return_tensors="pt")
inputs.pop("token_type_ids", None)
output = model.generate(
input_ids=inputs["input_ids"],
attention_mask=inputs["attention_mask"],
max_length=32,
min_length=2,
num_beams=5,
do_sample=False,
)
return tokenizer.decode(output[0], skip_special_tokens=True)
print(translit_thai_to_latin("สมชาย"))
print(translit_latin_to_thai("khlai khampraphan"))
Since AyutthayaAlpha 2.0 is trained with multiple variants and a ranking objective, it is natural to ask for several candidates:
def ranked_transliterations_thai_to_latin(name_thai: str, k: int = 5):
text = "<latn>" + name_thai
inputs = tokenizer(text, return_tensors="pt")
inputs.pop("token_type_ids", None)
outputs = model.generate(
input_ids=inputs["input_ids"],
attention_mask=inputs["attention_mask"],
max_length=32,
num_beams=k,
num_return_sequences=k,
do_sample=False,
)
return [tokenizer.decode(o, skip_special_tokens=True) for o in outputs]
print(ranked_transliterations_thai_to_latin("ทิพามณี", k=5))
Training data comes from a large aggregation of Thai–Latin name pairs:
Each Thai name is associated with multiple candidate Latin spellings. A supervised quality scoring model (LightGBM; Ke et al., 2017) assigns each pair a continuous quality score in [0, 1] using:
These scores enter the loss as per-example weights in a quality-weighted soft-minimum cross-entropy objective, so that the model:
Use human review for high-stakes, irreversible decisions.
If you use AyutthayaAlpha 2.0 Early Beta in research, please cite the accompanying paper (update once the preprint is public). A placeholder citation:
Lauc, D., Rutherford, A., & Wongwarawipatr, W. (2025). AyutthayaAlpha 2.0: A Thai–Latin Script Transliteration Transformer. Manuscript in preparation.
You may also cite the Transformers library (Wolf et al., 2020) and SentencePiece (Kudo & Richardson, 2018).