Breaking BERT: Understanding its Vulnerabilities for Named Entity Recognition through Adversarial Attack

Anne Dirkson, Suzan Verberne, Wessel KraaijarXiv 2021

Introduction

While BERT and its domain-specific variants like BioBERT and SciBERT have achieved state-of-the-art performance in Natural Language Processing, their robustness remains a significant concern. Most research into adversarial attacks—deliberate attempts to deceive a model—has focused on text classification. However, Named Entity Recognition (NER), a sequence labeling task requiring the identification and categorization of specific entities (e.g., names, locations, or medical terms), presents a more complex challenge. This paper investigates whether these models truly understand linguistic context or if they primarily rely on memorizing entity lists encountered during training.

Methodology: Black-Box Adversarial Attacks

The researchers developed two "black-box" adversarial attack methods that do not require access to the model's internal parameters:

  1. Entity Context Attack: This method identifies non-entity words that are most influential to the model's prediction and replaces them with synonyms. To ensure human readability and semantic consistency, the authors employed Part-of-Speech (POS) filtering and a semantic similarity threshold using the Universal Sentence Encoder.
  2. Entity Attack: This involves replacing a correctly identified entity with another entity of the same category (e.g., substituting a well-known city with an obscure village).
Example of an Entity Context Attack where changing a single verb leads to a misclassification of the preceding entity.

These attacks are adaptive; the algorithm specifically targets changes that most effectively reduce the model's confidence, rather than introducing random noise.

Datasets

The study evaluated model performance across four diverse datasets covering general and specialized domains:

  • General Domain: CoNLL-2003 (standard benchmark) and W-NUT 2017 (social media entities).
  • Biomedical Domain: BC5CDR (chemicals and diseases) and the NCBI disease corpus.

Key Insights: Fragility and Memorization

The experimental results reveal several critical vulnerabilities in BERT-based NER models:

  • The Memorization Trap: The "Entity Attack" achieved staggering success rates (89.5% to 99.4%). When a common entity was replaced by a rare one, the models almost universally failed to recognize it. This suggests that BERT models act more like sophisticated list-matchers than contextual reasoners.
  • Contextual Fragility: In over 75% of successful context attacks, changing just one word—often a verb immediately adjacent to the entity—was sufficient to trigger a failure.
  • Importance of Proximity: Analysis of the "important" words shows a high concentration of influence in the immediate vicinity of the entity.
Probability distribution of important words relative to the entity position (at 0) for various BERT models.
  • Robustness Floor: Interestingly, SciBERT (trained from scratch on scientific text) was more vulnerable than BioBERT (initialized with general BERT weights). This suggests that massive, diverse pre-training provides a "robustness floor" that domain-specific training from scratch might sacrifice.

Experimental Results

The attacks proved highly effective across all tested models:

  • Context Attack Success: Models were fooled into incorrect predictions 20.2% to 42.2% of the time.
  • Entity Attack Success: Success rates reached up to 99.4%, demonstrating a near-total reliance on entity memorization.
  • Semantic Integrity: Human evaluation by linguistics experts confirmed that the adversarial examples remained largely acceptable and understandable, indicating that the attacks were not merely producing gibberish.

Limitations and Future Directions

While effective, the current attack generation faces hurdles such as word sense ambiguity and occasional grammatical shifts.

To improve NER robustness, the authors recommend exploring entity masking during fine-tuning—forcing the model to rely more on context—and curriculum learning, which introduces rarer and more difficult entities gradually during the training process. These strategies could help move models beyond simple memorization toward true linguistic understanding.

Summary updated

BibTeX
@misc{dirkson2021breaking,
  author = {Anne Dirkson and Suzan Verberne and Wessel Kraaij},
  title = {{Breaking BERT: Understanding its Vulnerabilities for Named Entity Recognition through Adversarial Attack}},
  year = {2021},
  eprint = {2109.11308},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2109.11308},
}
Figure