Quality assurance · Production

Grammarly applies adversarial GAN framework to grammatical error correction for more contextually appropriate rewrites

The problem

Neural machine translation-based GEC models optimized for n-gram or edit-based metrics can produce grammatically correct text that is semantically inconsistent with the original input, meaning high n-gram precision does not guarantee high-quality corrections.

First attempt

A conventional single-sentence real-versus-fake discriminator struggled to differentiate between a ground-truth correction and a generated sentence that either omitted intended corrections or altered the semantics of the source.

Workflow diagram · grounded in source
1
Erroneous sentence input
trigger
“A GEC system takes a potentially erroneous sentence as input and must transform it into its corrected version”
2
Generator produces correction
ai_action
“the generator is a sequence-to-sequence (seq2seq) model, which is trained to "translate" a grammatically incorrect sentence to its grammatically correct rewrite”
3
Sentence-pair discriminator evaluation
validation
“we proposed the discriminator as a sentence-pair classification model, which is trained to evaluate the probability that the generated sentence is the most appropriate grammatically correct rewrite of a given input sentence”
4
Policy gradient feedback to generator
feedback_loop
“the discriminator fine-tuned the generator using a policy gradient, which rewarded high-quality generated text when conditioned on the source”
5
Contextually appropriate correction output
output
“generate not only a grammatical correction but also a more contextually appropriate suggestion for a given sentence”
Reported outcome

Adversarially trained models (RNN-Adv and Transformer-Adv) using the proposed GAN framework consistently achieved better results on standard GEC evaluation datasets, with the sentence-pair discriminator leading to much better performance compared with the conventional single-sentence discriminator.

Reported metrics
GEC performance on standard evaluation datasetsconsistently achieved better results
Performance vs conventional single-sentence discriminatormuch better performance
Reported stack
generative adversarial networks (GANs)NMTRNNtransformerGLEUpolicy gradient
Source
https://www.grammarly.com/blog/engineering/adversarial-grammatical-error-correction
Read source ↗

Frequently asked questions

What did this team achieve with this AI workflow?

Adversarially trained models (RNN-Adv and Transformer-Adv) using the proposed GAN framework consistently achieved better results on standard GEC evaluation datasets, with the sentence-pair discriminator leading to muc…

What tools did this team use?

generative adversarial networks (GANs), NMT, RNN, transformer, GLEU, policy gradient.

What results were reported?

GEC performance on standard evaluation datasets: consistently achieved better results; Performance vs conventional single-sentence discriminator: much better performance (source-reported, not independently verified).

What failed first in this deployment?

A conventional single-sentence real-versus-fake discriminator struggled to differentiate between a ground-truth correction and a generated sentence that either omitted intended corrections or altered the semantics of…

How is this quality assurance AI workflow structured?

Erroneous sentence input → Generator produces correction → Sentence-pair discriminator evaluation → Policy gradient feedback to generator → Contextually appropriate correction output.