RockNER: A Simple Method to Create Adversarial Examples for Evaluating the Robustness of Named Entity Recognition Models

Bill Yuchen Lin, Wenyang Gao, Jun Yan, Ryan Moreno, Xiang Ren

Introduction

Named Entity Recognition (NER) is a cornerstone of natural language processing, enabling systems to identify and categorize entities such as people, locations, and organizations. While state-of-the-art models achieve impressive scores on standard benchmarks like OntoNotes 5.0, these evaluations are often conducted on "static" datasets. In real-world applications, models encounter a constant stream of new entities and shifting linguistic contexts.

This paper addresses a critical vulnerability: the tendency of NER models to memorize specific entity names rather than learning to reason from context. For instance, a model might correctly identify "Beijing" as a city simply because it appeared frequently in the training data, rather than understanding the sentence structure. To investigate this, the authors introduce RockNER, a framework designed to "stress-test" models using natural-looking adversarial examples.

Methodology

The RockNER framework employs a two-tiered pipeline to generate adversarial examples that remain linguistically natural while challenging a model's robustness.

Overview of the RockNER pipeline showing entity-level and context-level attacks.

Entity-Level Attack

The first stage focuses on the entities themselves. Instead of random word swaps, RockNER leverages Wikidata to identify semantically similar but "out-of-distribution" replacements. By mapping an entity like "Beijing" to its Wikidata class (e.g., "big city"), the system can replace it with a less common entity from the same category, such as "Bari." This ensures the replacement is technically accurate for the label but likely unfamiliar to the model.

Detailed workflow of the entity-level attack using Wikidata mappings.

Context-Level Attack

The second stage targets the surrounding context. Using a pre-trained BERT model, RockNER substitutes "semantic-rich" words—nouns, verbs, and adjectives—with grammatically valid alternatives. To ensure these substitutions are challenging, the system selects words that are plausible but not the most likely (e.g., words ranked 100–200 in BERT’s prediction list). This tests whether the model relies too heavily on specific phrasing patterns found in training data.

The OntoRock Benchmark

To evaluate model performance, the authors created OntoRock, a new benchmark generated by applying the RockNER pipeline to the OntoNotes test and development sets. OntoRock is significantly more diverse than the original dataset, featuring a vocabulary of entity words roughly three times larger. Crucially, the "seen" rate is much lower; for example, only 17% of Geo-Political Entities (GPE) in OntoRock appeared in the original training set, compared to 75% in the standard test set.

Results and Analysis

The evaluation revealed a substantial "brittleness" in current NER systems. Even high-performing models experienced significant performance degradation:

  • Performance Collapse: The state-of-the-art RoBERTa-CRF model saw its F1 score drop from 92.4% on the original data to 58.5% on the full OntoRock benchmark. Older architectures like BLSTM-CRF were even more vulnerable, plummeting from 84.6% to just 32.4%.
  • Memorization vs. Reasoning: A key finding was that entity swaps caused much larger performance drops than context swaps. For RoBERTa-CRF, context-only attacks resulted in a minor dip (to 87.2%), whereas entity-only attacks led to a crash (to 63.4%). This confirms that models rely heavily on memorizing names rather than inferring entity types from context.
  • Common Failure Modes: When encountering unfamiliar names, models frequently misclassified GPEs as general Locations (LOC), suggesting a "fallback" behavior when memory fails.
  • Robustness through Pre-training: Transformer-based models (BERT, RoBERTa) proved more robust than earlier models, likely because their massive pre-training exposed them to a wider variety of obscure entities.

Conclusion

RockNER demonstrates that high benchmark scores can be deceptive, masking a lack of true linguistic reasoning. The authors found that simple data augmentation, such as Random Masking (replacing characters within entities during training), can force models to pay more attention to context, improving robustness. Future research should focus on developing architectures with stronger inductive biases that prioritize contextual "trigger words" over rote memorization of entity strings.

Summary updated

BibTeX
@inproceedings{lin2021rockner,
  author = {Bill Yuchen Lin and Wenyang Gao and Jun Yan and Ryan Moreno and Xiang Ren},
  title = {{RockNER: A Simple Method to Create Adversarial Examples for Evaluating the Robustness of Named Entity Recognition Models}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2021},
  doi = {10.18653/v1/2021.emnlp-main.302},
}
Figure