Abstract
Grammatical Error Correction (GEC) is a critical component of modern writing assistants, yet the high latency of standard Transformer models often hinders real-time user experiences. This paper introduces Shallow Aggressive Decoding (SAD), a framework designed to accelerate GEC by up to 10x without compromising accuracy. By exploiting the inherent similarity between input and output sequences in GEC tasks, SAD employs parallel token prediction and an optimized deep-encoder/shallow-decoder architecture to deliver nearly instantaneous feedback.
Introduction
Modern writing assistants rely on GEC to provide high-quality corrections. While the Transformer architecture has set new benchmarks for accuracy, its autoregressive decoding process—generating text one token at a time—creates a significant bottleneck for "online" or real-time applications. In a typical user workflow, a model should ideally validate a sentence the moment it is completed. To bridge the gap between high-quality "Transformer-big" models and the need for low-latency performance, we propose the Shallow Aggressive Decoding (SAD) framework.
The Shallow Aggressive Decoding Framework
The SAD framework introduces two primary innovations: a novel decoding strategy and an architectural shift toward imbalanced Transformer layers.
1. Aggressive Decoding and Suffix Matching
Unlike machine translation, where the source and target languages differ significantly, GEC is a "low-edit" task; the output is often over 90% identical to the input. SAD exploits this by "aggressively" predicting the entire output sequence in parallel, assuming it will match the input.
- Verification: The model checks these parallel predictions against its own internal logic. If the prediction matches the input, the process continues at high speed.
- Bifurcation: When a prediction deviates from the input (indicating a necessary correction), the model hits a "bifurcation" point. It then reverts to standard one-by-one decoding to accurately fix the error.
- Suffix Match: Once the error is corrected, the model attempts to "jump" back into parallel aggressive decoding by identifying a unique matching suffix in the remaining original text. This allows the model to skip sequential processing for the rest of a long, correct sentence.
2. Shallow Decoder Architecture
In standard Transformers, encoders and decoders typically share the same depth (e.g., 6 layers each). However, while encoders can process data in parallel, decoders are constrained by sequential bottlenecks. Our research indicates that for GEC, the "understanding" phase (encoder) is more computationally intensive than the "generation" phase (decoder). By utilizing a deep encoder (9-12 layers) and a shallow decoder (2-3 layers), we significantly reduce the computational cost per decoding step while maintaining or even improving overall accuracy.
Experimental Results
The SAD approach was evaluated across several standard English and Chinese GEC benchmarks, including CoNLL-2014 and BEA-19.
- Efficiency: On the CoNLL-14 benchmark, the SAD 9+3 architecture achieved a 10.5x speedup over the standard Transformer-big baseline. These gains were consistent across both GPU and CPU environments.
- Accuracy: The model achieved state-of-the-art results for a single model, reaching 66.4 $F_{0.5}$ on CoNLL-14 and 72.9 $F_{0.5}$ on BEA-19. Crucially, because aggressive decoding eventually verifies its predictions against the model's own greedy output, there is zero quality loss compared to standard decoding.
- Cross-Lingual Versatility: The method proved language-independent, achieving a 12x speedup on the Chinese NLPCC-18 task with performance comparable to the baseline.
Conclusion
Shallow Aggressive Decoding effectively redefines the efficiency frontier for Grammatical Error Correction. By recognizing that GEC is fundamentally different from general translation, SAD leverages input-output similarity and architectural imbalances to provide a high-speed, high-accuracy solution. Future work may extend this framework to other low-edit text-to-text tasks, such as text simplification and style transfer.
Summary updated