--- language: - en license: mit tags: - onnx - causal-lm - grammar-correction - typo-correction - character-aware - rope - gqa - swiglu - int8 - offline-nlp pipeline_tag: text-generation inference: false ---

TypoFormer Logo

# TypoFormer (Stage 2 INT8) **TypoFormer** is a 100% offline, character-aware hybrid Transformer designed for ultra-low latency (<10ms on CPU) next-word autocomplete and non-autoregressive grammatical error correction (GEC). Companion Windows desktop app and training source code available on [GitHub](https://github.com/fahiiim/TyPoTaKer). ## Model Architecture - **Trunk**: 10 Transformer blocks (768 hidden dimension, 2048 FFN dimension) - **Attention**: Grouped Query Attention (12 Query heads, 4 Key-Value heads) + Rotary Position Embeddings (RoPE) - **Non-Linearity**: SwiGLU + Pre-RMSNorm - **Hybrid Input**: Gated fusion of 16,000 Byte-Level BPE embeddings with Multi-Scale Character 1D-Convolutions (kernel sizes 2, 3, 5, 8) - **Quantization**: Symmetric INT8 ONNX graph (130 MB footprint) ## Files in this Repository - `lm_stage2_int8.onnx`: Causal language model for next-word suggestion (~138 MB) - `gec_stage2_int8.onnx`: Non-autoregressive edit-tagger for grammar & typo correction (~130 MB) - `tokenizer.json`, `vocab.json`, `merges.txt`: 16k Byte-Level BPE tokenizer - `edit_maps.json`: High-frequency confusion dictionary for atomic replacements & appends - `infer.py`: Self-contained Python runner using ONNX Runtime ## Quickstart ```bash pip install onnxruntime tokenizers numpy git clone https://huggingface.co/fahiiim/TypoFormer cd TypoFormer python infer.py ``` ### Python Example ```python from infer import TypoFormer model = TypoFormer(".") # 1. Autocomplete (Causal LM) suggestions = model.autocomplete("Could you please review the configuration file before the ", top_k=3) print("Autocomplete suggestions:", suggestions) # 2. Grammar & Typo Fix (GEC) clean = model.correct_grammar("This is teh wrong way to write.") print("Fixed text:", clean) ``` ## License MIT