[Paper Review] Robust Encodings: A Framework for Combating Adversarial Typos
This paper introduces Robust Encodings (RobEn), a task-agnostic framework that enhances NLP model robustness against adversarial typos by mapping sentences to a discrete, stable set of encodings. By optimizing for stability and fidelity, RobEn enables exact robust accuracy computation and achieves 71.3% average robust accuracy across GLUE tasks when combined with BERT—significantly outperforming prior defenses like typo-corrector-based methods.
Despite excellent performance on many tasks, NLP systems are easily fooled by small adversarial perturbations of inputs. Existing procedures to defend against such perturbations are either (i) heuristic in nature and susceptible to stronger attacks or (ii) provide guaranteed robustness to worst-case attacks, but are incompatible with state-of-the-art models like BERT. In this work, we introduce robust encodings (RobEn): a simple framework that confers guaranteed robustness, without making compromises on model architecture. The core component of RobEn is an encoding function, which maps sentences to a smaller, discrete space of encodings. Systems using these encodings as a bottleneck confer guaranteed robustness with standard training, and the same encodings can be used across multiple tasks. We identify two desiderata to construct robust encoding functions: perturbations of a sentence should map to a small set of encodings (stability), and models using encodings should still perform well (fidelity). We instantiate RobEn to defend against a large family of adversarial typos. Across six tasks from GLUE, our instantiation of RobEn paired with BERT achieves an average robust accuracy of 71.3% against all adversarial typos in the family considered, while previous work using a typo-corrector achieves only 35.3% accuracy against a simple greedy attack.
Motivation & Objective
- To develop a reusable, task-agnostic defense framework that confers guaranteed robustness against adversarial typos without compromising model architecture.
- To address the limitations of existing defenses—such as heuristic approximations or incompatibility with state-of-the-art models like BERT—by introducing a discrete encoding bottleneck.
- To ensure robustness through two core desiderata: stability (perturbations map to few encodings) and fidelity (downstream models maintain high accuracy on clean inputs).
- To enable exact computation of robust accuracy by leveraging tractable encoding-based inference, avoiding the loose bounds of certifiable training.
- To demonstrate generalization across multiple NLP tasks using a single, precomputed encoding function.
Proposed method
- The core mechanism is an encoding function α that maps input sentences to a smaller, discrete space of encodings, acting as a bottleneck for downstream models.
- Stability is enforced by ensuring all perturbations of a sentence map to a small set of encodings, formalized via clustering objectives over token-level encodings.
- Fidelity is preserved by optimizing encodings to maintain representational quality so downstream models perform well on unperturbed inputs.
- The framework uses agglomerative clustering with a hyperparameter γ to balance stability (γ=0) and fidelity (γ=1), enabling trade-off analysis.
- RobEn supports exact robust accuracy computation by enumerating all valid perturbations within the attack surface, avoiding lower-bound approximations.
- The method is compatible with any downstream model, including BERT, and encodings can be reused across tasks after a one-time construction.
Experimental results
Research questions
- RQ1Can a reusable, task-agnostic encoding framework provide guaranteed robustness against adversarial typos without requiring retraining for each model or task?
- RQ2How can stability and fidelity be jointly optimized in a discrete encoding space to ensure robustness while preserving model performance?
- RQ3To what extent can RobEn improve robust accuracy compared to existing defenses like typo-correctors or data augmentation, especially under worst-case attacks?
- RQ4Does the framework scale to state-of-the-art models like BERT, and can it achieve exact robust accuracy computation without convex relaxation or bounds?
- RQ5Can RobEn generalize across diverse NLP tasks, such as those in the GLUE benchmark, with a single precomputed encoding function?
Key findings
- RobEn achieves an average robust accuracy of 71.3% across six GLUE tasks when paired with BERT, significantly outperforming the previous state-of-the-art defense using a typo corrector, which achieved only 35.3% under a greedy attack.
- The robust accuracy is computed exactly, avoiding the loose lower bounds typical of certifiably robust training, due to the tractable structure of the encoding space.
- For 25% of examples in RTE and 66% in SST-2, all perturbations of a sentence map to a single encoding (|Bα(x)| = 1), indicating strong stability.
- The agglomerative clustering-based encoding with γ = 0.5 achieves the highest robust accuracy on SST-2, demonstrating a clear trade-off between stability and fidelity.
- RobEn also defends against internal permutation attacks, achieving 81.4% robust accuracy on the same six tasks, compared to a drop from 86.2% to 15.7% for standard BERT.
- The framework generalizes across tasks: the same encoding function can be reused across multiple NLP tasks without retraining, enabling task-agnostic robustness.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.