TinyFix Turkish

A compact, purely neural 17.8M-parameter Turkish autocorrect model — zero dictionary files, zero regex rules.

It restores missing Turkish diacritics (cok → çok), fixes joined and split words (birş ey → bir şey, herşey → her şey, bölge de → bölgede, bende geliyorum → ben de geliyorum), handles Turkish agglutinative morphology (assimilation sınıfda → sınıfta, softening kitapı → kitabı, vowel drop/narrowing burunu → burnu, anlayorum → anlıyorum, apostrophe suffixes Turkiyede → Türkiye’de, spoken verbs yapıcam → yapacağım), corrects everyday misspellings (şöför → şoför, süpriz → sürpriz), and reconstructs heavy typing slips (merhba nslsn, siprşm hala glmdi krgo nrde? → merhaba nasılsın, siparişim hala gelmedi kargo nerede?).

Highlights

  • End-to-end neural: Asymmetric character-level Seq2Seq Transformer (6 encoder / 3 decoder layers, d_model=384, 6 heads, RoPE, RMSNorm, SwiGLU, tied 320-token UTF-8 byte-fallback + Turkish character vocabulary) with an encoder clean-gate (edit_head).
  • Compact int8 ONNX bundle: 19.28 MB total (encoder_int8.onnx 12.26 MB + decoder_step_int8.onnx 7.02 MB) with zero external lexicon or dictionary files.
  • Zero false breaks in cautious mode: 0.00 broken words per 10k on clean, clean-tricky, and all 8 Turkish morphology tracks (tau=0.25), and 2.35 per 10k on general clean in full mode (tau=0.00).
  • Browser & CPU ready: Runs directly in onnxruntime (Python) or onnxruntime-web (WASM/WebGPU) with precomputed cross-attention KV and explicit self-KV cache (~60 ms/sentence on CPU; ~5–15 ms when the clean-gate skips decoding; 1.37 ms/item batched on GPU).
  • Clean MIT license: No external dictionary or third-party runtime dependencies.

Quickstart (Python)

pip install numpy onnxruntime huggingface_hub
from huggingface_hub import snapshot_download
import sys

model_dir = snapshot_download("ekremcet/tinyfix-turkish")
sys.path.insert(0, model_dir)
from tinyfix_tr import TinyFixTR

fix = TinyFixTR(model_dir)                        # full mode (tau=0.00)
fix_safe = TinyFixTR(model_dir, mode="cautious")  # cautious mode (tau=0.25, 0.00 broke/10k clean)

print(fix("ben burada düzeltilen birş ey görmedim"))
# ben burada düzeltilen bir şey görmedim

print(fix("merhba nslsn, siprşm hala glmdi krgo nrde?"))
# merhaba nasılsın, siparişim hala gelmedi kargo nerede?

print(fix("bende geliyorum, hiçbir sorun yok."))
# ben de geliyorum, hiçbir sorun yok.

print(fix_safe("Kitap bende, yarın getiririm."))
# Kitap bende, yarın getiririm.

Benchmark Results

1. Sealed General Autocorrect (ekremcet/turkish-autocorrect-bench, 1,558 items)

Track / Metric Full (tau=0.00) Cautious (tau=0.25)
Mean F0.5 (error tracks) 89.33 87.21
clean broken / 10k 2.35 0.00
clean-tricky broken / 10k 0.00 0.00
no-turkish-letters F0.5 98.97 (99.2% rec / 98.9% prec) 98.97
call-center F0.5 96.07 (0.00 broke/10k) 96.07
misspellings F0.5 91.84 (100% prec) 84.03 (100% prec)
typing-slips F0.5 90.48 (92.7% prec) 90.23
joined-split F0.5 86.90 (97.0% prec) 83.33
reviews-real F0.5 71.73 (6.7 broke/10k) 70.61 (4.5 broke/10k)

2. Turkish Agglutinative Morphology Suite (100 items, 8 tracks)

Track Full (tau=0.00) Broken / 10k
Mean Morphology F0.5 89.46 0.00
apostrophe-suffix (Turkiyede → Türkiye’de, 2025te → 2025'te) 100.00 0.00
assimilation (sınıfda → sınıfta, gitdi → gitti) 95.59 (100% prec) 0.00
spoken-verbs (yapıcam → yapacağım, bilmiyom → bilmiyorum) 91.84 (100% prec) 0.00
softening (kitapı → kitabı, ağaçı → ağacı) 89.55 0.00
clitic-contrast (bende geliyorum vs Kitap bende) 85.94 0.00
vowel-drop-narrow (burunu → burnu, anlayorum → anlıyorum) 83.33 (100% prec) 0.00
suffix-harmony-split (evlar → evler, yap abilirim → yapabilirim) 80.00 0.00
clean-morph-traps (must stay untouched) 100% exact 0.00

ONNX Interface (Browser / Custom Runtimes)

The model is split into two opset-17 int8 ONNX graphs with exact KV caching:

  1. encoder_int8.onnx
    • Input: src_ids (int64[1, S]) — encoded chunk with trailing EOS_ID=2 (max_src_tokens=360).
    • Outputs: edit_prob (float32[1]), src_mask (bool[1, 1, 1, S]), ck0, cv0, ck1, cv1, ck2, cv2 (float32[1, 6, S, 64]).
    • If edit_prob[0] < tau, return the input chunk unchanged without running the decoder.
  2. decoder_step_int8.onnx
    • Inputs: cur_id (int64[1, 1], starts at BOS_ID=1), src_mask, self-KV sk0, sv0, sk1, sv1, sk2, sv2 (float32[1, 6, T_past, 64], starts at T_past=0), and cross-KV ck0, cv0, ck1, cv1, ck2, cv2.
    • Outputs: logits (float32[1, 320]) and updated nsk0, nsv0, nsk1, nsv1, nsk2, nsv2 (float32[1, 6, T_past+1, 64]).
    • Greedy argmax until EOS_ID=2 or len(src_ids) + 24 steps.

Training Data & Limits

  • Trained on 3.59M clean Turkish sentences sampled from FineWeb-2 (tur_Latn, ODC-By 1.0) with dynamic multi-error synthetic corruption covering diacritics, keyboard slips, vowel drops, joined/split words, de/da/ki/mi, canonical misspellings, and Turkish agglutinative morphology (assimilation, softening, vowel drop/narrowing, harmony, apostrophe suffixes, spoken contractions). No private or customer data was used.
  • Designed for spelling, diacritic, morphological, and word-boundary correction — not full grammatical rewriting or stylistic paraphrasing.
Downloads last month
23
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Dataset used to train ekremcet/tinyfix-turkish