Downloads · 30 days
29
12% of all-time downloads
TeXlyre/grammar-t5-small-onnx
grammar-t5-small-onnx is a machine learning model from TeXlyre. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as mit.
https://huggingface.co/huytd189/grammar-t5-small converted to ONNX weights for compatibility with Transformers.js.
Downloads · 30 days
29
12% of all-time downloads
All-time downloads
252
Public
Repo size
1.8 GB
Likes
0
Public
Click a slice to open those files.
.onnx631 MB · 99%
From the Hugging Face model README
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.
Install PyTorch followed by the requirements:
pip install -r requirements.txt
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
To run the inference on the original model:
python infer.py
Or to infer using the ONNX model:
python infer_onnx.py
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`);
}