Skip to main content
QUICK REVIEW

[Paper Review] Robust Textual Embedding against Word-level Adversarial Attacks

Yichen Yang, Xiaosen Wang|arXiv (Cornell University)|Feb 28, 2022
Adversarial Robustness in Machine LearningComputer Science10 citations
TL;DR

This paper proposes Fast Triplet Metric Learning (FTML), a novel method to enhance robustness against word-level adversarial attacks by learning word embeddings that pull synonyms closer and push non-synonyms apart in the embedding space. FTML achieves state-of-the-art robust accuracy across multiple models (CNN, LSTM, BERT) with minimal training overhead, significantly improving resilience to attacks like PWWS and HLA while maintaining high clean accuracy.

ABSTRACT

We attribute the vulnerability of natural language processing models to the fact that similar inputs are converted to dissimilar representations in the embedding space, leading to inconsistent outputs, and we propose a novel robust training method, termed Fast Triplet Metric Learning (FTML). Specifically, we argue that the original sample should have similar representation with its adversarial counterparts and distinguish its representation from other samples for better robustness. To this end, we adopt the triplet metric learning into the standard training to pull words closer to their positive samples (i.e., synonyms) and push away their negative samples (i.e., non-synonyms) in the embedding space. Extensive experiments demonstrate that FTML can significantly promote the model robustness against various advanced adversarial attacks while keeping competitive classification accuracy on original samples. Besides, our method is efficient as it only needs to adjust the embedding and introduces very little overhead on the standard training. Our work shows great potential of improving the textual robustness through robust word embedding.

Motivation & Objective

  • To address the vulnerability of NLP models to word-level adversarial attacks, where synonym substitutions lead to inconsistent predictions despite semantic similarity.
  • To identify that model robustness is undermined by dissimilar representations of semantically similar inputs in the embedding space.
  • To propose a general, efficient method to learn robust word embeddings that are invariant to synonym substitutions.
  • To improve model robustness without relying on expensive adversarial training or complex certified defense mechanisms.
  • To demonstrate the effectiveness and efficiency of FTML across diverse architectures, including BERT, on standard NLP benchmarks.

Proposed method

  • FTML introduces a triplet loss that pulls words closer to their synonyms (positive samples) and pushes them away from non-synonyms (negative samples) in the embedding space.
  • The method integrates this triplet loss into standard training, requiring only minor adjustments to the embedding layer with negligible computational overhead.
  • It leverages a synonym dictionary to define positive and negative samples for each word, enabling targeted optimization of word representations.
  • For BERT, the vocabulary is expanded during fine-tuning to include high-frequency actual words, improving embedding representation for full words.
  • The approach uses a weighted combination of standard cross-entropy loss and triplet loss, with hyperparameters α and β tuned for trade-off between clean and robust accuracy.
  • The method is generalizable to any language once a synonym dictionary is available, enabling broad applicability beyond English.

Experimental results

Research questions

  • RQ1Can learning more consistent word embeddings through synonym proximity improve model robustness against word-level adversarial attacks?
  • RQ2How does the proposed triplet metric learning approach compare to standard adversarial training in terms of robustness and efficiency?
  • RQ3What is the impact of expanding BERT’s vocabulary with actual words on the performance of FTML?
  • RQ4How sensitive is FTML’s performance to hyperparameters α and β in the loss function?
  • RQ5Can FTML maintain high clean accuracy while significantly improving robust accuracy across diverse models and datasets?

Key findings

  • FTML achieves a robust accuracy of 81.2% against PWWS attacks on the IMDB dataset when BERT’s vocabulary is expanded to include 50,000 actual words, compared to only 16.6% for standard fine-tuned BERT.
  • The robustness of FTML-trained BERT models improves with increasing vocabulary size, reaching 81.2% robust accuracy with 50,000 added words, while clean accuracy remains stable at around 92.2–92.5%.
  • FTML maintains high clean accuracy (92.2–92.5%) even when the vocabulary is expanded, indicating no degradation in generalization.
  • The method is robust to hyperparameter variations, with stable performance across a wide range of β values (10⁻³ to 10³), and achieves optimal trade-off with β=1.
  • FTML significantly outperforms state-of-the-art baselines in robustness against multiple word-level attacks, including PWWS, HLA, and GA, while introducing minimal training overhead.
  • The method generalizes well across models, demonstrating strong robustness improvements on CNN, LSTM, and BERT architectures without architectural modifications.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.