TeXlyre/grammar-t5-small-onnx
By TeXlyre · ↓ 2 · ♥ 0 · Updated 2025-09-26
What's in this repo
This page lists the files in TeXlyre/grammar-t5-small-onnx, including decoder_model.onnx, decoder_model_int8.onnx, decoder_model_merged.onnx and more.
- 12 ONNX models (.onnx files)
- 27 files, including 12 .onnx, 7 .json, 3 .py, 1 .md, 1 .txt, 1 .model
- Last updated 2025-09-26
ONNX files
| File | Size | Download |
|---|---|---|
| onnx/decoder_model.onnx | — | Download |
| onnx/decoder_model_int8.onnx | — | Download |
| onnx/decoder_model_merged.onnx | — | Download |
| onnx/decoder_model_merged_int8.onnx | — | Download |
| onnx/decoder_model_merged_quantized.onnx | — | Download |
| onnx/decoder_model_quantized.onnx | — | Download |
| onnx/decoder_with_past_model.onnx | — | Download |
| onnx/decoder_with_past_model_int8.onnx | — | Download |
| onnx/decoder_with_past_model_quantized.onnx | — | Download |
| onnx/encoder_model.onnx | — | Download |
Showing 10 of 12 .onnx files — see the full file list on the right.
How to use
These ONNX files can be loaded with ONNX Runtime. To inspect a model graph, upload the file to the Netron viewer. Download links point to the original files on Hugging Face.
README
Grammar Synthesis
https://huggingface.co/huytd189/grammar-t5-small converted to ONNX weights for compatibility with Transformers.js.
This repository contains the ONNX weights of the grammar-t5-small model trained on the Grammarly Coedit dataset.
Usage (Transformers Python)
Install PyTorch followed by the requirements:
pip install -r requirements.txt
Exporting ONNX
To modify the original model and re-export it using Optimum, the grammar-t5-small model must be cloned as a submodule.
NOTE: Make sure to install Git LFS before initializing submodules:
git lfs install
# git submodule add https://huggingface.co/huytd189/grammar-t5-small model
git submodule update --init --recursive
Next, run the export script to export the ONNX model:
python export_onnx.py
Inference
To run the inference on the original model:
python infer.py
Or to infer using the ONNX model:
python infer_onnx.py
Usage (Transformers.js)
InstallTransformers.js from NPM:
npm i @huggingface/transformers
Next, run the following example:grammar synthesis:
import { pipeline } from '@huggingface/transformers';
const generator = await pipeline('text2text-generation', 'TeXlyre/grammar-t5-small-onnx');
const inputTexts = [
"Rewrite and fix: 'I will drank two bottle'",
"Rewrite and fix: 'She go to the store'",
"Rewrite and fix: 'He is more taller than me'",
"Paraphrase to make it coherent: I've expierienced wet and reiny days. But I survive back then",
"Correct the grammar: 'She don't like appless.'"
];
for (const inputText of inputTexts) {
const output = await generator(inputText, {
max_new_tokens: 100,
num_beams: 4,
early_stopping: true
});
console.log(`Input: ${inputText}`);
console.log(`Output: ${output[0].generated_text}\n`);
}
Model info
Created: 2025-09-25
Updated: 2025-09-26
View on Hugging FaceFiles (27)
Related models
More from TeXlyre
No other models by this author.
More models
No task type declared.