Bidirectional Transformer Reranker for Grammatical Error Correction

Ying Zhang, Hidetaka Kamigaito, Manabu Okumura

Abstract

Modern Grammatical Error Correction (GEC) systems predominantly utilize sequence-to-sequence (seq2seq) architectures that decode text in a unidirectional, left-to-right manner. This approach often suffers from prediction bias, as the model lacks access to future context during the generation of early tokens. This paper introduces the Bidirectional Transformer Reranker (BTR), a model designed to re-evaluate candidate sentences by leveraging bidirectional context. By employing a BERT-style decoder, Pseudo-Log-Likelihood (PLL) scoring, and unlikelihood training with negative sampling, BTR achieves state-of-the-art performance on standard GEC benchmarks, including CoNLL-14, BEA-2019, and JFLEG.

Introduction

Grammatical Error Correction (GEC) has seen significant advancement through the application of neural machine translation techniques, specifically Transformer-based seq2seq models. However, a persistent limitation of these models is their reliance on unidirectional decoding. When a model generates a token, it is conditioned only on the preceding tokens, ignoring the structural and semantic constraints imposed by the subsequent parts of the sentence. While right-to-left (R2L) reranking has been explored to mitigate this, such models still only capture half of the available context at any given time.

To address this, we present the Bidirectional Transformer Reranker (BTR). Rather than generating text, BTR serves as a discriminative component that scores a set of candidate hypotheses generated by a primary seq2seq model. By considering the entire sentence simultaneously, BTR provides a more holistic evaluation of grammatical correctness and fluency.

Methodology

Architecture: The BERT-style Decoder

The BTR utilizes an encoder-decoder Transformer architecture but modifies the decoder to function bidirectionally. Unlike standard decoders that use causal masking to prevent the model from "looking ahead," the BTR employs a fully-visible mask. This allows every token in the target sequence to attend to every other token, effectively turning the decoder into a bidirectional processor similar to BERT.

Scoring with Pseudo-Log-Likelihood (PLL)

Because the BTR is bidirectional, standard cross-entropy loss—which assumes a conditional chain rule—is inapplicable. Instead, the model is trained and evaluated using Pseudo-Log-Likelihood (PLL). For a given candidate sentence, the PLL is calculated by masking one token at a time and summing the log-probabilities of each original token given the surrounding bidirectional context. This metric provides a robust proxy for the likelihood of a sentence under a bidirectional distribution.

Negative Sampling and Unlikelihood Training

To sharpen the model’s ability to distinguish between subtle grammatical nuances, the authors implemented negative sampling. During training, the model is presented with both the "gold" (correct) sentence and several "negative" candidates (incorrect or partially corrected sentences). The training objective is two-fold: maximize the likelihood of the gold sentence and minimize the likelihood of the negative candidates using an unlikelihood loss. This approach forces the model to assign significantly lower scores to common errors that a base model might otherwise produce.

Inference and the Acceptance Threshold

During the inference phase, the BTR evaluates the top-N candidates produced by a base model (e.g., T5). To ensure that the reranker only intervenes when it has high confidence, an acceptance threshold ($\lambda$) is introduced. A candidate suggested by the BTR is only accepted if its score exceeds the score of the base model's top choice by the margin $\lambda$. This prevents unnecessary "lateral moves" where the model might swap one valid construction for another without a clear gain in quality.

Experimental Results

Performance on Standard Benchmarks

The BTR was evaluated on the three primary GEC benchmarks: CoNLL-14, BEA-2019, and JFLEG. Using a T5-base model as the candidate generator, the addition of BTR yielded consistent improvements:

  • CoNLL-14: Achieved an $F_{0.5}$ score of 65.47, a 0.36-point increase over the base model.
  • BEA-2019: Reached an $F_{0.5}$ of 71.27, representing a significant 0.76-point boost.
  • JFLEG: Improved the GLEU score to 59.52 (+0.48), indicating enhanced fluency and naturalness.

Model Agnosticism and Efficiency

An important finding was the BTR's model-agnostic nature. A BTR trained on candidates from a T5-base model was capable of improving the outputs of a T5-large model. This suggests that the bidirectional "judging" criteria learned by the BTR generalize across different scales of generative models.

In terms of efficiency, while the BTR requires more intensive pre-training (approximately 13 days on A100 GPUs), it is highly efficient during inference. Because it processes all tokens in a candidate sentence in parallel rather than autoregressively, it can score multiple candidates rapidly.

Discussion and Conclusion

The success of the Bidirectional Transformer Reranker underscores the importance of bidirectional context in understanding the complexities of grammar. By moving away from the constraints of left-to-right generation during the evaluation phase, the BTR effectively identifies errors that are only apparent when the full sentence structure is visible.

Future research may focus on expanding the pre-training regime of the BTR and exploring its application in other sequence-generation tasks, such as abstractive summarization and machine translation, where global context is equally vital. While the system is currently limited by the quality of the candidates provided by the base model, it represents a significant step forward in the "hindsight" evaluation of machine-generated text.

Summary updated

BibTeX
@inproceedings{zhang2023bidirectional,
  author = {Ying Zhang and Hidetaka Kamigaito and Manabu Okumura},
  title = {{Bidirectional Transformer Reranker for Grammatical Error Correction}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2023},
  doi = {10.18653/v1/2023.findings-acl.234},
}
Figure