Robust Learning for Text Classification with Multi-source Noise Simulation and Hard Example Mining

Guowei Xu, Wenbiao Ding, Weiping Fu, Zhongqin Wu, Zitao Liu

Introduction

In real-world applications, particularly in education and document processing, NLP models often encounter text generated by Optical Character Recognition (OCR) engines. Unlike standard typos, OCR noise is visual in nature—mistaking "dog" for "dag" due to character similarity. While pre-trained models like BERT excel on clean text, they are surprisingly fragile when faced with these visual misinterpretations. This paper addresses the "OCR gap" by proposing a training framework that builds intrinsic robustness without the need for expensive, manually labeled noisy datasets.

Methodology

The proposed framework introduces a three-pronged strategy to enhance model resilience through automated noise generation and targeted learning.

Multi-source Noise Simulation

To capture the complexity of real-world OCR errors, the researchers utilized three distinct simulation methods:

  • Rule-based: Swapping tokens based on a confusion matrix derived from real-world OCR/clean text pairs.
  • Attack-based: Employing adversarial techniques to identify model weak spots and replacing words with visually similar synonyms.
  • Model-based: Training a 6-layer Transformer to act as a "noise injector," learning to generate contextually plausible span-level noise.

Hard Example Mining (HEM) and Stability Loss

Not all noisy samples provide equal training value. The framework dynamically identifies "hard examples"—noisy sentences where the model's internal representation differs significantly from the clean version, measured via cosine distance.

The proposed robust learning framework, illustrating the pipeline from noise simulation to hard example mining and the joint training objective.

To ensure the model treats clean and noisy versions of the same sentence similarly, a "stability loss" term ($L_{sim}$) is added to the standard classification loss ($L_{stand}$). The final training objective is defined as: $$L = \alpha * L_{stand} + (1 - \alpha) * L_{sim}$$ This forces the model to produce nearly identical internal embeddings regardless of whether the input is pristine or corrupted.

Experimental Setup and Datasets

The framework was evaluated on three Chinese text classification tasks involving primary school student essays: Metaphor Detection, Personification Detection, and Parallelism Detection. To create a realistic benchmark, the authors photographed handwritten texts and processed them through commercial OCR engines (Hanvon and TAL OCR), providing a "ground truth" for natural, non-simulated noise.

Key Results and Insights

The proposed framework consistently outperformed standard BERT and other robust training baselines across the majority of test categories.

  • Performance Gains: On the Metaphor detection task using the TAL OCR engine, the framework improved the F1 score from 0.838 (baseline BERT) to 0.871.
  • Contextual Noise: The model-based simulation revealed that OCR errors often lead to contextually plausible "hallucinations" rather than just character swaps.
  • Efficiency: By using Hard Example Mining, the model avoids being overwhelmed by trivial noise and focuses on errors that actually alter semantic understanding.
  • Generalization: Robust training maintained or slightly improved performance on clean text, suggesting the model learned more generalized features.

Conclusion

This "simulate-and-mine" framework provides a scalable solution for making NLP models resilient to machine-generated noise. While the study focused on Chinese OCR, the methodology is language-agnostic and holds potential for other domains such as Automatic Speech Recognition (ASR) transcripts. Future work will explore its efficacy in more complex tasks like Named Entity Recognition and Question Answering.

Summary updated

BibTeX
@inproceedings{xu2021robust,
  author = {Guowei Xu and Wenbiao Ding and Weiping Fu and Zhongqin Wu and Zitao Liu},
  title = {{Robust Learning for Text Classification with Multi-source Noise Simulation and Hard Example Mining}},
  booktitle = {ECML/PKDD},
  year = {2021},
  doi = {10.1007/978-3-030-86517-7\_18},
}
Figure