Text Generation
Transformers.js
ONNX
t5
text2text-generation
coedit
grammar
writing-assistant
webgpu
Instructions to use imrahamed/coedit-large-webgpu-onnx with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers.js
How to use imrahamed/coedit-large-webgpu-onnx with Transformers.js:
// npm i @huggingface/transformers import { pipeline } from '@huggingface/transformers'; // Allocate pipeline const pipe = await pipeline('text-generation', 'imrahamed/coedit-large-webgpu-onnx');
| license: cc-by-nc-4.0 | |
| library_name: transformers.js | |
| pipeline_tag: text-generation | |
| tags: | |
| - coedit | |
| - grammar | |
| - writing-assistant | |
| - onnx | |
| - webgpu | |
| - transformers.js | |
| base_model: grammarly/coedit-large | |
| # CoEdIT Large for WebGPU (ONNX) | |
| Browser-ready ONNX export of [`grammarly/coedit-large`](https://huggingface.co/grammarly/coedit-large), packaged for local seq2seq generation with Transformers.js and ONNX Runtime WebGPU. | |
| This repository contains only the two graphs required for cached browser generation: | |
| - `onnx/encoder_model.onnx` | |
| - `onnx/decoder_model_merged.onnx` | |
| Tokenizer, model configuration, and generation configuration are included at the repository root. The redundant uncached decoder exports are intentionally omitted. | |
| ## Usage with Transformers.js | |
| ```js | |
| import { | |
| AutoModelForSeq2SeqLM, | |
| AutoTokenizer, | |
| } from "@huggingface/transformers"; | |
| const modelId = "imrahamed/coedit-large-webgpu-onnx"; | |
| const tokenizer = await AutoTokenizer.from_pretrained(modelId); | |
| const model = await AutoModelForSeq2SeqLM.from_pretrained(modelId, { | |
| device: "webgpu", | |
| dtype: "fp32", | |
| }); | |
| const input = await tokenizer( | |
| "Paraphrase the sentence: The application performs all inference locally.", | |
| ); | |
| const output = await model.generate({ | |
| inputs: input.input_ids, | |
| attention_mask: input.attention_mask, | |
| max_new_tokens: 64, | |
| }); | |
| console.log(tokenizer.decode(output.tolist()[0], { | |
| skip_special_tokens: true, | |
| })); | |
| ``` | |
| ## CoEdIT task prompts | |
| | Feature | Prompt | | |
| |---|---| | |
| | Grammar | `Fix grammatical errors in this sentence: {text}` | | |
| | Formal | `Make the sentence formal: {text}` | | |
| | Casual | `Change the style to casual: {text}` | | |
| | Simplify | `Make the sentence simpler: {text}` | | |
| | Rewrite | `Paraphrase the sentence: {text}` | | |
| ## Export details | |
| - Architecture: FLAN-T5 Large / CoEdIT | |
| - Format: ONNX, FP32 | |
| - Opset: 18 | |
| - Export task: `text2text-generation-with-past` | |
| - Optimization: Optimum ONNX Runtime `O2` | |
| - Intended execution provider: ONNX Runtime WebGPU | |
| - CPU/WASM fallback should be provided by the consuming application. | |
| The export was validated against the source model. Small floating-point differences from ONNX graph optimization may occur. | |
| ## License and attribution | |
| **Noncommercial use only.** This derivative export follows the upstream Creative Commons Attribution-NonCommercial 4.0 license. See the [source model card](https://huggingface.co/grammarly/coedit-large) for training details, limitations, and attribution. | |