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:
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:
1git lfs install
2# git submodule add https://huggingface.co/huytd189/grammar-t5-small model
3git submodule update --init --recursive
To run the inference on the
original model:
1import { pipeline } from '@huggingface/transformers';
2
3const generator = await pipeline('text2text-generation', 'TeXlyre/grammar-t5-small-onnx');
4
5const inputTexts = [
6 "Rewrite and fix: 'I will drank two bottle'",
7 "Rewrite and fix: 'She go to the store'",
8 "Rewrite and fix: 'He is more taller than me'",
9 "Paraphrase to make it coherent: I've expierienced wet and reiny days. But I survive back then",
10 "Correct the grammar: 'She don't like appless.'"
11];
12
13for (const inputText of inputTexts) {
14 const output = await generator(inputText, {
15 max_new_tokens: 100,
16 num_beams: 4,
17 early_stopping: true
18 });
19
20 console.log(`Input: ${inputText}`);
21 console.log(`Output: ${output[0].generated_text}\n`);
22}