Text Generation
Transformers.js
ONNX
t5
text2text-generation
coedit
flan-t5
grammar
writing-assistant
webgpu
Instructions to use imrahamed/coedit-base-webgpu-onnx with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers.js
How to use imrahamed/coedit-base-webgpu-onnx with Transformers.js:
// npm i @huggingface/transformers import { pipeline } from '@huggingface/transformers'; // Allocate pipeline const pipe = await pipeline('text-generation', 'imrahamed/coedit-base-webgpu-onnx');
File size: 3,673 Bytes
8592576 bb88a28 8592576 6f3ad3d bb88a28 8592576 6f3ad3d 8592576 6f3ad3d 8592576 6f3ad3d 8592576 6f3ad3d 8592576 6f3ad3d 8592576 6f3ad3d 8592576 6f3ad3d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | ---
license: apache-2.0
library_name: transformers.js
pipeline_tag: text-generation
tags:
- coedit
- flan-t5
- text2text-generation
- grammar
- writing-assistant
- onnx
- webgpu
- transformers.js
datasets:
- grammarly/coedit
---
# Flint CoEdIT Base for WebGPU (ONNX)
Browser-ready ONNX export of the 250M-parameter CoEdIT Base checkpoint,
packaged for local sequence-to-sequence generation with Transformers.js and
ONNX Runtime WebGPU.
## Correct model lineage
This repository is an inference-format conversion, not a newly trained model
and not an export of `grammarly/coedit-large`.
| Role | Model or dataset |
| --- | --- |
| Foundation architecture | [`google/flan-t5-base`](https://huggingface.co/google/flan-t5-base) |
| Fine-tuned checkpoint converted here | [`jbochi/coedit-base`](https://huggingface.co/jbochi/coedit-base) |
| Fine-tuning dataset | [`grammarly/coedit`](https://huggingface.co/datasets/grammarly/coedit) |
| This ONNX export | [`imrahamed/coedit-base-webgpu-onnx`](https://huggingface.co/imrahamed/coedit-base-webgpu-onnx) |
Grammarly publishes the CoEdIT dataset and the official Large, XL, and XXL
checkpoints. It does not publish an official `grammarly/coedit-base`
checkpoint. The Base checkpoint converted here is the FLAN-T5 Base fine-tune
published by `jbochi`.
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-base-webgpu-onnx";
const tokenizer = await AutoTokenizer.from_pretrained(modelId);
const model = await AutoModelForSeq2SeqLM.from_pretrained(modelId, {
device: "webgpu",
dtype: "fp32",
});
const input = await tokenizer(
"Fix grammatical errors in this sentence: This are a test.",
);
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,
}),
);
```
Expected output: `This is a test.`
## 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
- Foundation architecture: FLAN-T5 Base
- Converted checkpoint: `jbochi/coedit-base`
- Fine-tuning dataset: `grammarly/coedit`
- Parameters: approximately 250M
- 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
This derivative export follows the converted checkpoint's Apache 2.0 license.
See the [`jbochi/coedit-base` model
card](https://huggingface.co/jbochi/coedit-base) for its reported training
details and metrics. CoEdIT paper and dataset attribution remains applicable.
|