In Arabic and Bengali handwriting, a character's identity often turns on a few pixels. The letters ب, ت and ث share the same stroke shape and differ only in the number and position of small dots. A Bengali consonant becomes a different grapheme when a small vowel sign is attached. Current recognizers treat each full character or grapheme as one indivisible class. As a result, the sub-character marks that carry the most meaning are also the cheapest thing for an attacker or for page degradation to flip. Arabic OCR benchmarks already record this failure: dots and stroke elongations trigger hallucinations and broken words even in large vision-language models (KITAB-Bench).
We propose to split the recognizer's output along the script's own structure. One head predicts the coarse stroke skeleton, which should be stable under small pixel changes. A second head predicts the fine marks, which must be sensitive to exact position. We then harden each head with adversarial training, meaning training on worst-case small input perturbations found by gradient ascent. We apply label smoothing, which replaces one-hot targets with slightly softened ones, only to the mark head, where genuine visual ambiguity exists. The bet is that this gives better worst-case robustness per unit of training compute than adversarially training a whole-character model. It should also give calibrated uncertainty about marks without the false robustness that label smoothing is known to produce.
Core Claim
Complex-script characters factor into two parts. The first is the skeleton: the Arabic dotless letter body (rasm), or the Bengali base consonant or conjunct. The second is the marks: dot pattern, vowel sign, diacritic. These two parts relate to each other roughly the way classification relates to localization in object detection. The skeleton needs features that ignore small shifts and noise. The marks need features that track small spatial details.
Detection research shows that forcing both through one head causes their gradients to interfere, and that splitting the heads helps. This holds for clean training (Lu et al., YOLO-ERF) and for adversarial training (Robust and Accurate Object Detection via Adversarial Learning). We claim three things.
First, in whole-character recognizers, errors caused by adversarial or natural perturbations concentrate in the mark channel. Second, a recognizer with decoupled skeleton and mark heads, trained with per-head adversarial perturbations, reaches lower character error rate (CER) under adaptive attack than an equally expensive whole-character adversarially trained model, at matched clean CER. Third, smoothing only the mark head improves mark calibration without the gradient masking that uniform label smoothing causes. Gradient masking means a distorted loss surface that stalls attackers and makes a model look robust when it is not (Label Smoothing and Adversarial Robustness; Gradient Masking of Label Smoothing in Adversarial Robustness).
The closest existing work is Det-AdvProp, which arbitrates adversarial perturbations between a detector's classification and box heads. It works only on bounding boxes, never touches sequence recognition, and never asks what label smoothing does to the head conflict. The obvious extension would port its Max-Max rule onto a text recognizer's alignment and decoding modules. Our proposal differs in where the split sits. We decouple along the target itself, using the script's morphology, not along the recognizer's pipeline stages. We also treat label smoothing as a head-specific tool whose masking risk is measured directly, rather than as a global regularizer.
Research Program
Base recognizer. We use a decoupled-alignment design in the style of Decoupled Attention Network for Text Recognition. That paper computes character-position attention maps from visual features alone, with a convolutional alignment module, and then decodes characters from those maps. It removes the drift in which one wrong character corrupts all later attention. We keep that alignment module and replace the single character classifier at each decoding step with two heads.
Building the targets. For Arabic, a fixed table derived from Unicode maps each letter to a skeleton class and a dot-pattern class (none, one, two or three dots, above or below). Harakat (short-vowel marks) become an additional mark class where the transcription contains them. For Bengali, each grapheme cluster, as produced by a grapheme tokenizer like BnGraphemizer (GraDeT-HTR), maps to a base consonant or conjunct plus vowel-sign and consonant-diacritic slots. The mapping is lossless. At decoding time, we restrict the output to skeleton–mark pairs that actually occur, so the model cannot output nonexistent characters. We also build a transformer variant on the HATFormer encoder–decoder, including its BlockProcessor chunking, which preserves thin dots. This variant checks that the effect does not depend on DAN's architecture.
Training objective. Let $x$ be a line image and $s, m$ its skeleton and mark sequences. Let $L_s$ and $L_m$ be the per-head sequence losses, with total loss $L = L_s + \lambda L_m$, where $\lambda$ weights the mark head. Following the Max-Max rule, we compute two perturbations, $\delta_s$ by attacking $L_s$ and $\delta_m$ by attacking $L_m$, each within budget $\Delta$. We train on whichever one hurts more overall:
$$\delta^\star = \arg\max_{\delta \in \{\delta_s,\ \delta_m\}} L(x+\delta; s, m),$$
$$\min_\theta \; L(x; s, m) + L(x+\delta^\star; s, \tilde m_\epsilon).$$
Here $\theta$ are the model parameters, and $\tilde m_\epsilon$ is the mark target smoothed with strength $\epsilon$ over the small mark vocabulary. Skeleton targets stay one-hot, so the skeleton head's margins are never capped. Clean and adversarial inputs pass through separate normalization statistics (auxiliary normalization, as in Det-AdvProp), which limits the clean-accuracy drop that adversarial training usually causes.
Threat models. We use two. The first is a standard small $L_\infty$ budget on grayscale pixels. The second is a sparse patch budget: a few small patches anywhere on the line. The patch budget mimics inserting, erasing or moving a dot, which is the specific weakness KITAB-Bench documents. The attacker is the adaptive, uncertainty-weighted sequence attack of Adaptive Adversarial Attack on Scene Text Recognition. That paper reports over 99.9% success against coupled CTC recognizers on Latin scene text but proposed no defense. For our models, we extend it to target the skeleton head, the mark head, or both, and we add random restarts and output-diversified starting points. Those two additions are what exposed label smoothing's masking in the image classification studies.
Baselines
Naive reference. A whole-character DAN-style recognizer and HATFormer, trained with ordinary cross-entropy and no adversarial training. This anchors clean accuracy. The published clean numbers are 8.6% CER on Muharaf for overtrained HATFormer (9.9% with standard training) and 15.4% on KHATT (HATFormer); 13.4% CER for the Muharaf SFR baseline (Muharaf); and 6.19% CER / 14.20% WER on BN-HTRd for GraDeT-HTR. We found no reported result on Lacuna for adversarial robustness of any Arabic or Bengali handwriting recognizer. We will therefore establish robust-CER baselines ourselves and will not borrow them.
Strongest competitor. Whole-character adversarial training: the same recognizer trained with multi-step perturbations of its single character loss, with auxiliary normalization. This is the main threat. If a wide enough single head can learn the skeleton–mark structure implicitly, our factorization adds nothing. For fairness, it gets the same data, synthetic pretraining, attack steps per iteration, budget, number of hyperparameter trials and GPU-hours. Our method beats it if its robust CER under the full adaptive attack is at least a pre-registered margin lower at clean CER no worse than +0.5 points, on both Muharaf and BN-HTRd.
Factorization-only model. The two-head model with no adversarial training. This separates the benefit of decoupling from the benefit of hardening.
Uniform smoothing baseline. Whole-character adversarial training plus uniform label smoothing over the full grapheme vocabulary, which can run to hundreds of classes. This tests whether confining smoothing to the mark head matters.
Rule ablation. Our full model with a joint perturbation on the summed loss instead of Max-Max. This tests whether the arbitration rule matters in this setting.
Budget-matched augmentation. Clean-trained models get extra epochs so their wall-clock cost equals the adversarial models'.
Why not just…?
Why not just adversarially train the existing whole-character recognizer? This is the serious alternative, and nothing in the file settles it. Det-AdvProp's evidence that shared heads suffer gradient conflict under attack comes from detection, and the analogy to text recognition is our hypothesis. The comparison above settles it directly. The per-head error breakdown adds a diagnostic: if whole-character adversarial training already drives mark errors under attack down to the skeleton-error level, the factorization is unnecessary, and we will report that.
Why not just augment with random dot insertion and erasure? This is cheap and targets the right features, so it is a real threat against natural degradation. Evidence that random augmentation falls short against worst-case inputs comes only from other settings. Det-AdvProp found AutoAugment weaker than model-dependent adversarial augmentation on COCO and COCO-C. Gaussian noise combined with label smoothing produced masking rather than robustness (Gradient Masking of Label Smoothing in Adversarial Robustness). We include a morphology-aware dot and vowel-sign augmentation baseline and score it on both adaptive attacks and natural degradation. If it matches us on natural degradation but not under attack, we will narrow the claim to worst-case robustness.
Why not just use label smoothing, which costs nothing? On CIFAR-10, a smoothed model scored 74.83% under PGD but 0.15% under output-diversified attack and 6.86% under AutoAttack, while adversarial training held about 49–53% (Label Smoothing and Adversarial Robustness). Transfer attacks cut smoothed models' robust accuracy by up to 32% (Gradient Masking of Label Smoothing in Adversarial Robustness). We use smoothing only as a calibration tool on the mark head, never as a defense, and we test it for masking with the same diagnostics those papers used.
Why not just use a large vision-language model? KITAB-Bench reports that vision-language models cut CER by 60% relative to Tesseract. They still hallucinate on dots and elongation, and the best reached only 65% on PDF-to-Markdown. We report a vision-language model as a clean-accuracy reference point where feasible, but it is not a robustness baseline.
Proposed Experiments and Decisive Checks
We run Arabic experiments on Muharaf and KHATT and Bengali experiments on BN-HTRd and Bongabdo, with synthetic pretraining following HATFormer and GraDeT-HTR. IAM (Decoupled Attention Network for Text Recognition reports 6.4% CER) is a negative control. Latin script has almost no mark structure beyond i and j, so we predict no benefit there. A gain on IAM would mean the effect comes from something other than morphology.
The metrics are:
- clean CER and WER;
- robust CER under the $L_\infty$ and patch threat models, with the adaptive attack at several step counts;
- CER split into skeleton errors and mark errors;
- expected calibration error of the mark head per character;
- step-wise gradient cosine similarity (SGCS), which measures how consistent the attack's gradient direction is across steps;
- the gap between white-box robust CER and robust CER under transfer attacks crafted on the clean model.
Four results decide the project, each pre-registered.
The premise must hold. On clean-trained whole-character models, more than half of attack-induced and degradation-induced errors must be mark errors. If not, the factorization targets the wrong channel and we stop.
Hardening must beat hardening. At matched compute, the factored adversarially trained model must show lower adaptive-attack CER than whole-character adversarial training on both scripts, with no gain on IAM.
Smoothing must not mask. Mark-only smoothing must lower mark calibration error while keeping SGCS and the white-box/transfer gap close to the unsmoothed adversarially trained model. Uniform smoothing is predicted to reduce SGCS and widen the gap. If mark-only smoothing shows the same signs, we drop smoothing from the method and report it as a negative result.
The ablations must attribute the gain. The factorization-only model and the joint-perturbation variant must each fall short of the full model. Otherwise the gain belongs to whichever ingredient remains.
References
- KITAB-Bench: A Comprehensive Multi-Domain Benchmark for Arabic OCR and Document Understanding
- Object Detection for UAV Aerial Scenarios Based on Vectorized IOU
- YOLO-ERF: lightweight object detector for UAV aerial images
- Robust and Accurate Object Detection via Adversarial Learning
- Label Smoothing and Adversarial Robustness
- Gradient Masking of Label Smoothing in Adversarial Robustness
- Decoupled Attention Network for Text Recognition
- GraDeT-HTR: A Resource-Efficient Bengali Handwritten Text Recognition System utilizing Grapheme-based Tokenizer and Decoder-only Transformer
- HATFormer: Historic Handwritten Arabic Text Recognition with Transformers
- Adaptive Adversarial Attack on Scene Text Recognition
- Muharaf: Manuscripts of Handwritten Arabic Dataset for Cursive Text Recognition