Abstract
Robust sequence-to-sequence modelling is an essential task in the real world where the inputs are often noisy. Both user-generated and machine generated inputs contain various kinds of noises in the form of spelling mistakes, grammatical errors, character recognition errors, all of which impact downstream tasks and affect interpretability of texts. In this work, we devise a novel sequence-to-sequence architecture for detecting and correcting different real world and artificial noises (adversarial attacks) from English texts. Towards that we propose a modified Transformer-based encoder-decoder architecture that uses a gating mechanism to detect types of corrections required and accordingly corrects texts. Experimental results show that our gated architecture with pre-trained language models perform significantly better that the non-gated counterparts and other state-of-the-art error correction models in correcting spelling and grammatical errors. Extrinsic evaluation of our model on Machine Translation (MT) and Summarization tasks show the competitive performance of the model against other generative sequence-to-sequence models under noisy inputs.
Introduction
Most Natural Language Processing (NLP) models are "fair-weather" systems, assuming input text is linguistically perfect. However, real-world data is inherently messy. Noise typically originates from two primary sources: user-generated errors (typos, slang, and grammatical slips) and machine-generated errors (Optical Character Recognition (OCR) or Speech-to-Text artifacts). Standard sequence-to-sequence (Seq2Seq) models often struggle with these because noise is rarely a simple character swap; it frequently involves "run-on" words, missing characters, or inserted "junk" tokens. Existing denoising models like BART or T5 are typically trained on noise injected after tokenization, making them less effective at handling the raw, messy text encountered in practical applications.
Proposed Architecture: gated-Trans
To address these challenges, we introduce gated-Trans (g-Trans), which augments the standard Transformer architecture with a suite of trainable gates. This mechanism allows the model to intelligently decide how to process each token based on its perceived noise level and contextual relevance.
The Gating Mechanism
- Masked Encoder: Unlike standard encoders, this component utilizes a mask gate. It calculates the probability that a token is "noisy." If identified as such, the model "soft-masks" the token, signaling the network to rely more on surrounding context than the literal (potentially corrupted) input.
- Conditional Decoder: For every output step, the decoder employs three normalized gates:
- Copy Gate: Passes a token directly from the input to the output (ideal for correct words).
- Generate Gate: Synthesizes a brand-new token (ideal for correcting typos).
- Skip Gate: Ignores a token entirely. This is a critical innovation for handling insertion-based noise or "hallucinations" in the input that should not appear in the final output.
Experimental Results
We evaluated g-Trans on both intrinsic denoising benchmarks (ALTA, ICDAR, and IMDb with infused noise) and extrinsic downstream tasks (WMT14 for translation and CNN/DailyMail for summarization).
Key Findings
- Denoising Superiority: On real-world OCR datasets (ALTA/ICDAR), gated versions consistently outperformed their non-gated counterparts, showing improvements of approximately 0.5% in Word Recognition Rate (WRR) and up to 2.5% in BLEU score.
- Robustness to Adversarial Noise: When subjected to "Random" noise—the most difficult category involving arbitrary insertions and deletions—the T5-based gated model (g-T5) achieved a WRR of 98.1%, significantly surpassing the base T5 model.
- Downstream Task Gains: In Machine Translation and Summarization, gated models yielded cleaner outputs. For instance, in summarization tasks with noisy input, g-Trans successfully filtered out random numbers and artifacts that standard models mistakenly preserved.
Discussion and Conclusion
The "Skip Gate" represents a major contribution to robust Seq2Seq modelling. By allowing the model to bypass contextually irrelevant or nonsensical tokens, g-Trans handles adversarial attacks and OCR "junk" more gracefully than traditional architectures. Furthermore, the gating mechanism is backbone-agnostic; adding these gates to BERT, BART, and T5 consistently improved performance, suggesting the architecture addresses a fundamental weakness in how Transformers handle noisy sequences.
Future work will explore incorporating visual features for OCR tasks and extending the architecture to handle resource-scarce languages and different morphological structures beyond English.
Summary updated