CoolFace
Modelpublic

TonyRaju/gec-t5-small-coedit-onnx-int8

sourceHugging Faceapache-2.0updated 6mo agoView on Hugging Face
0likes50downloads
Model Card

Unbabel/gec-t5_small — ONNX INT8 Quantized

This is an ONNX INT8 dynamically quantized version of Unbabel/gec-t5_small for grammatical error correction in English.

This is a derivative work. All credit for the original model goes to Unbabel. This repository only provides a quantized ONNX conversion for easier deployment. We do not claim ownership of the model architecture or weights.

Original Model

Original RepositoryUnbabel/gec-t5_small
Original AuthorUnbabel
ArchitectureT5-small (encoder-decoder)
Parameters60.5M
Training DatacLang-8 + CoNLL
LicenseApache 2.0 (inherited from original)

What’s in this repo?

  • —encoder_model.onnx — Encoder graph (INT8 quantized)
  • —decoder_model.onnx — Decoder graph (INT8 quantized)
  • —decoder_with_past_model.onnx — Decoder with KV-cache (INT8 quantized)
  • —config.json, generation_config.json — Model configuration
  • —tokenizer.json, tokenizer_config.json, special_tokens_map.json — Tokenizer files

Quantization Details

StepDetail
ExportPyTorch → ONNX FP32 via HuggingFace Optimum (ORTModelForSeq2SeqLM)
Quantizationonnxruntime.quantization.quantize_dynamic with QuantType.QInt8
ValidationVerified ONNX FP32 output matches PyTorch FP32 exactly (0 delta) before quantizing

Benchmark Results — This Model

Benchmarked on a 50-sentence English grammar correction test set (2-thread CPU, Google Colab).

Quality

FormatBLEUchrF++Exact MatchΔ BLEUΔ chrF++
PyTorch FP32 (baseline)77.4286.8460%——
ONNX INT8 (this repo)77.6086.6960%+0.18-0.15

Speed & Size

MetricPyTorch FP32ONNX INT8 (this repo)
P50 Latency226 ms117 ms
P95 Latency282 ms203 ms
Disk Size231 MB152 MB
Throughput—53.42 sentences/sec

Quantization Stability

MetricValue
Sentences with changed output (INT8 vs FP32)1/50 sentences changed
Deployment Scorecard VerdictGO

Recommended model. Best quality-to-size ratio. Rock-solid INT8 stability with only 1 sentence regression. Based on the paper 'A Simple Recipe for Multilingual Grammatical Error Correction'.


Cross-Model Comparison (7 Models Benchmarked)

This model was benchmarked alongside 6 other grammar correction models. All models were evaluated on the same 50-sentence test set under identical conditions.

PyTorch FP32 Baseline (all models)

ModelParamsBLEUchrF++P50 (ms)Size (MB)Exact Match
prithivida222.9M76.8886.4060285058%
coedit-small ←60.5M77.4286.8422623160%
vennify-t5-base222.9M78.5787.8753985058%
aventiq-t5-small60.5M34.4345.8821323116%
visheratin-mini31.2M66.8481.7713311946%
visheratin-tiny15.6M66.0882.69855948%
pszemraj-small77.0M57.1177.1336329428%

ONNX INT8 Quantized (all models)

ModelParamsBLEU (FP32)BLEU (INT8)chrF++ (INT8)P50 (ms)Disk (MB)Exact MatchScorecard
prithivida222.9M76.8874.4484.7922242654%NO-GO
coedit-small ← this model60.5M77.4277.6086.6911715260%GO
vennify-t5-base222.9M78.5777.2486.7422442656%GO
aventiq-t5-small60.5M34.4340.6651.9512015222%GO*
visheratin-mini31.2M66.8466.6582.67789346%GO
visheratin-tiny15.6M66.0864.5182.28605544%GO
pszemraj-small77.0M57.113.1518.721381530%NO-GO

Statistical Significance (Bootstrap, 1000 resamples)

Key cross-model comparisons (INT8 variants):

Model AModel BchrF++ AchrF++ Bp-valueSignificant?
coedit-smallvennify-t5-base86.6986.741.000No (identical)
coedit-smallvisheratin-mini86.6982.670.038Yes
coedit-smallvisheratin-tiny86.6982.280.010Yes
coedit-smallprithivida86.6984.790.324No
visheratin-minivisheratin-tiny82.6782.280.824No (identical)
prithividavennify-t5-base84.7986.740.324No

Recommendation

Use CaseRecommended ModelWhy
Best overall (desktop)coedit-small INT8 (152 MB)Highest INT8 quality (chrF++ 86.69), 117ms latency, only 1 regression
Smallest (mobile/edge)visheratin-tiny INT8 (55 MB)60ms latency, 55 MB disk, acceptable quality (chrF++ 82.28)
Highest baseline qualityvennify-t5-base INT8 (426 MB)chrF++ 86.74, but 3x larger than coedit-small for no significant quality gain

Usage

python
from optimum.onnxruntime import ORTModelForSeq2SeqLM
from transformers import AutoTokenizer

model_id = "YOUR_USERNAME/gec-t5-small-coedit-onnx-int8"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = ORTModelForSeq2SeqLM.from_pretrained(model_id)

text = "gec: She go to school yesterday"
inputs = tokenizer([text], return_tensors="pt", max_length=128, truncation=True)
outputs = model.generate(**inputs, max_new_tokens=128, num_beams=1, repetition_penalty=1.3)
corrected = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(corrected)

Input prefix: gec:

Acknowledgments

All credit for the original model goes to Unbabel. This repository only provides an ONNX INT8 quantized conversion to make the model easier to deploy in production environments (mobile, edge, browser).

Quantization and benchmarking performed as part of the Smart Desktop Keyboard Grammar Engine project.

Citation

If you use this model, please cite the original authors:

@misc{coedit_small_onnx_int8,
  title = {Unbabel/gec-t5_small — ONNX INT8 Quantized},
  note = {Quantized version of Unbabel/gec-t5_small},
  url = {https://huggingface.co/Unbabel/gec-t5_small},
}