Context-aware Adversarial Attack on Named Entity Recognition

Shuguang Chen, Leonardo Neves, Thamar Solorio

TL;DR

This paper introduces a novel approach to create adversarial examples for Named Entity Recognition (NER) systems by focusing on perturbing the most "informative" words within a sentence. Their methods demonstrate a significant ability to deceive NER models, highlighting vulnerabilities that current defenses might overlook.

What Problem Does This Paper Address?

Large pre-trained language models (PLMs) have revolutionized Natural Language Processing (NLP), but they remain susceptible to adversarial attacks. While adversarial attacks are well-studied for tasks like text classification, they are less effective for Named Entity Recognition (NER) because existing methods don't account for NER's specific labeling schemes. This can lead to mislabeled adversarial examples that don't accurately reflect the intended attack. The paper aims to address this by developing context-aware adversarial attacks that specifically target NER systems, making them more robust and revealing their vulnerabilities.

Methods

The authors propose a two-stage pipeline for generating context-aware adversarial examples for NER:

  1. Candidate Selection: This stage identifies which words in a sentence are most "informative" for NER models and thus good targets for perturbation. They explore several automated methods:
  2. Random (RDM): Selects non-entity words randomly.
  3. POS Tagging (PST): Selects words with specific Part-of-Speech tags (adjectives, nouns, adverbs, verbs) known to be semantically rich.
  4. Dependency Parsing (DEP): Identifies non-entity words that are syntactically related (ascendants/descendants) to entity instances.
  5. Chunking (CHK): Focuses on non-entity words within noun chunks that are close to entity instances, preserving syntactic coherence.
  6. Gradient (GDT): Uses the gradients of the victim model to identify non-entity words most influential in predicting entity labels. This is based on Integrated Hessians.
  7. Candidate Replacement: Once candidate words are selected, they are replaced to create adversarial examples. The goal is to maintain semantic and syntactic similarity to the original sentence while deceiving the model. Two methods are employed:
  8. Synonym Replacement: Replaces candidate words with their synonyms from WordNet. This aims to preserve semantics and make the adversarial examples less noticeable to humans.
  9. Masked Language Model (MLM) Replacement: Uses a masked language model (RoBERTa) to predict replacements for masked candidate words, aiming to preserve both semantics and syntax.

Datasets

The experiments were conducted on three commonly used NER datasets:

  • CoNLL03: A standard dataset for NER.
  • OntoNotes5.0: A larger, more diverse dataset.
  • W-NUT17: A dataset containing noisy, user-generated text, which presents a unique challenge due to its informal nature and potential misspellings.

Key Insights and Ideas

  • Informative words are key: Perturbing words that are highly informative for NER models (identified by gradient attribution or syntactic relationships) is significantly more effective at deceiving the model than random word perturbations.
  • Trade-off between similarity and effectiveness: Synonym replacement maintains higher textual similarity but results in a smaller performance decrease in the NER model. Conversely, MLM replacement, while potentially sacrificing some textual similarity, leads to a larger performance decrease, making it more effective for attacking the model.
  • Dataset characteristics matter: Adversarial attacks are less effective on noisy, short, and informal text (like W-NUT17) because the model has less reliable context to rely on for predictions.

Key Results

  • The proposed context-aware adversarial attack methods are more effective than strong baselines in deceiving NER models.
  • When perturbing five words, F1 scores of NER models decreased by 10-20% on average.
  • Gradient (GDT) and Random (RDM) candidate selection methods were found to be most effective in deceiving the model. However, RDM sacrifices text similarity, potentially making adversarial examples easier to detect.
  • Dependency parsing (DEP) showed effectiveness even with slight perturbations.
  • POS tagging (PST) was generally the least effective candidate selection method.
  • Masked Language Model replacement led to a larger performance decrease compared to synonym replacement, despite potentially lower textual similarity.

Limitations and Future Work

  • Linguistic Knowledge Dependency: The proposed methods require linguistic knowledge (POS tags, dependency parsing), which might need extension for languages other than English, especially for minority languages.
  • Computational Resources: The methods may not be suitable for scenarios with low computational resources or real-time applications.
  • Future Work: The paper implicitly suggests exploring more sophisticated candidate selection and replacement strategies, as well as extending these methods to other languages and NLP tasks. Further research could also focus on developing more robust defenses against these context-aware attacks.

Summary updated

BibTeX
@inproceedings{chen2024context,
  author = {Shuguang Chen and Leonardo Neves and Thamar Solorio},
  title = {{Context-aware Adversarial Attack on Named Entity Recognition}},
  booktitle = {EACL},
  year = {2024},
}
Figure