Abstract
Large language models (LLMs) have been widely used for several applications such as question answering, text classification and clustering. While the preliminary results across the aforementioned tasks looks promising, recent work has dived deep into LLMs performing poorly for complex Named Entity Recognition (NER) tasks in comparison to fine-tuned pre-trained language models (PLMs). To enhance wider adoption of LLMs, our paper investigates the robustness of such LLM NER models and its instruction fine-tuned variants to adversarial attacks. In particular, we propose a novel attack which relies on disentanglement and word attribution techniques where the former aids in learning an embedding capturing both entity and non-entity influences separately, and the latter aids in identifying important words across both components. This is in stark contrast to most techniques which primarily leverage non-entity words for perturbations limiting the space being explored to synthesize effective adversarial examples. Adversarial training results based on our method improves the F1 score over original LLM NER model by 8% and 18% on CoNLL-2003 and Ontonotes 5.0 datasets respectively.
Introduction
Named Entity Recognition (NER) is a fundamental task in Natural Language Processing, essential for identifying and categorizing entities such as names, organizations, and locations. Despite the success of Large Language Models (LLMs) in various domains, they exhibit significant fragility in NER tasks. Minor, word-level modifications can lead to misclassifications or hallucinations, revealing a lack of adversarial robustness.
Current research in adversarial attacks for NER faces two primary challenges: semantic drift and context bias. Many existing attacks generate nonsensical sentences that lose the original meaning, while models often over-rely on surrounding context rather than the entity itself. This paper addresses these gaps by proposing a novel adversarial attack framework that leverages disentangled representations to separate entity and context information, enabling more precise and semantically consistent perturbations.
Methodology
The proposed framework generates high-quality adversarial examples through a multi-stage process involving disentanglement, word attribution, and targeted substitution.
Disentanglement and Word Attribution
The core innovation lies in the disentanglement of word embeddings. Using an auto-encoder architecture coupled with a discriminator, the model learns to separate embeddings into distinct entity and context components. This separation is crucial to prevent the model from being biased toward only perturbing context words. Following disentanglement, Integrated Gradients (IG) are employed for word attribution, identifying the most influential words within both the entity and context components for the model's prediction.
Targeted Substitution and Guardrails
Once important words are identified, the framework performs targeted substitutions:
- Entity Substitution: Category-consistent replacements are sourced from Wikidata (e.g., replacing "Manchester United" with "FC Barcelona").
- Context Substitution: A language model (GPT-J) is used to generate semantically appropriate replacements for context words.
To ensure the generated adversarial examples maintain semantic similarity to the original text, the Universal Sentence Encoder (USE) acts as a guardrail, ranking candidate sentences and selecting those with the highest similarity.
Experimental Evaluation
The method was evaluated on three benchmark NER datasets:
- CoNLL-2003: A standard news-based dataset.
- Ontonotes 5.0: A large-scale corpus covering 18 entity types.
- MultiCoNER: A complex dataset featuring fine-grained entities in short contexts.
The framework was tested against various architectures, including BERT, instruction-tuned T5, and Llama 2 (7B).
Results and Discussion
The experimental results demonstrate that the proposed attack is both more efficient and more effective than existing baselines.
Robustness Gains
Adversarial training using the generated examples led to substantial improvements in model robustness. As shown in Figure 6, F1 scores under attack increased by 8% on CoNLL-2003 and 18% on Ontonotes 5.0. Furthermore, the attack achieved a 10% higher success rate on CoNLL-2003 compared to baselines while requiring 69% fewer candidate samples than state-of-the-art methods like CLARE.
Insights into Model Bias
A key finding is the prevalence of context bias in standard models. Without disentanglement, word attribution methods selected context words 98.9% of the time, suggesting that models "cheat" by relying on surrounding text. Disentanglement forces the attack to target entities directly, leading to more diverse and realistic adversarial examples.
Conclusion and Future Work
This research highlights the importance of disentangling entity and context information to improve the adversarial robustness of LLMs in NER tasks. While the results are promising across multiple architectures, future work will explore extending the internal attribution mechanisms to a broader range of decoder-only "black-box" models. Additionally, the authors aim to integrate attribution and similarity scoring into a joint optimization framework and investigate how these robustness trends scale with significantly larger models.
Summary updated