trspell-mt5-small
mT5-small fine-tuned for Turkish spelling correction on NoisyWikiTr. It takes a sentence with spelling errors and generates the corrected sentence.
Released with Leveraging Large Language Models for Spelling Correction in Turkish (Ceren Güzel Turhan, PeerJ Computer Science 11:e2889, 2025).
- Paper: https://doi.org/10.7717/peerj-cs.2889
- Code: https://github.com/cgturhan/trspell
- Dataset: https://huggingface.co/datasets/cguzel/NoisyWikiTr
Usage
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
repo = "cguzel/trspell-mt5-small"
tokenizer = AutoTokenizer.from_pretrained(repo)
model = AutoModelForSeq2SeqLM.from_pretrained(repo)
text = "netekim kasım ve temmuz felaketleri bunun sadece acı iki örneğidir"
inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=256)
output = model.generate(**inputs, num_beams=5, max_length=256, early_stopping=True)
print(tokenizer.decode(output[0], skip_special_tokens=True))
Input should be normalised like the training data: lowercase with Turkish rules (I → ı, İ → i), no digits, punctuation or apostrophes. No task prefix is used.
Model details
- Base model:
google/mt5-small, multilingual T5 pre-trained on mC4 (101 languages, including Turkish) - Architecture: encoder-decoder, 8 encoder and 8 decoder layers, d_model 512, about 300M parameters (most of them in the 250k-token multilingual embedding)
- Tokenizer: multilingual SentencePiece vocabulary, which covers all Turkish letters (ı, ğ, ş, ç, ö, ü, İ)
- Task: sequence-to-sequence, noisy sentence → clean sentence
Training
- Data: NoisyWikiTr training split, 687k Turkish Wikipedia sentences with about 10% of tokens corrupted (deletion, insertion, transposition, substitution, vowel errors, common misspellings, word splits)
- Validation: NoisyWikiTr validation split (85k sentences)
Evaluation
Results on the NoisyWikiTr test set (uniform and realistic noise) are reported in Table 5 of the paper. In the paper, the Turkish model trspell-t5-efficient-small gives the best word correction on realistic noise.
Limitations
- Trained and evaluated on synthetic errors; results on real typos may differ.
- Corrects spelling only, not grammar.
- Long inputs are truncated at 256 tokens; split long texts into sentences.
Citation
@article{guzelturhan2025trspell,
title = {Leveraging large language models for spelling correction in Turkish},
author = {G{\"u}zel Turhan, Ceren},
journal = {PeerJ Computer Science},
volume = {11},
pages = {e2889},
year = {2025}
}