TypoFormer / README.md
fahiiim's picture
Upload TypoFormer Stage 2 INT8 weights and tokenizers
e49d248 verified
|
Raw History Blame Contribute Delete
2.1 kB
metadata
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.

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

pip install onnxruntime tokenizers numpy
git clone https://huggingface.co/fahiiim/TypoFormer
cd TypoFormer
python infer.py

Python Example

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