BANER: Boundary-Aware LLMs for Few-Shot Named Entity Recognition

Quanjiang Guo, Yihong Dong, Ling Tian, Zhao Kang, Yu Zhang, Sijie Wang · OpenReview

Abstract

Despite the recent success of two-stage prototypical networks in few-shot named entity recognition (NER), challenges such as over/under-detected false spans in the span detection stage and unaligned entity prototypes in the type classification stage persist. Additionally, LLMs have not proven to be effective few-shot information extractors in general. In this paper, we propose an approach called Boundary-Aware LLMs for Few-Shot Named Entity Recognition to address these issues. We introduce a boundary-aware contrastive learning strategy to enhance the LLM's ability to perceive entity boundaries for generalized entity spans. Additionally, we utilize LoRAHub to align information from the target domain to the source domain, thereby enhancing adaptive cross-domain classification capabilities. Extensive experiments across various benchmarks demonstrate that our framework outperforms prior methods, validating its effectiveness. In particular, the proposed strategies demonstrate effectiveness across a range of LLM architectures.

The Challenge of Few-Shot NER

Named Entity Recognition (NER) involves identifying specific entities in text—such as people, locations, or dates—and classifying them. Performing this task in a "few-shot" setting, where the model only sees 1 to 5 examples of a new category, is notoriously difficult. Current two-stage models, which first detect a text span and then classify it, frequently suffer from two major roadblocks:

  1. Boundary Errors: Models often exhibit "over-detection" (e.g., including surrounding words like "in 1961" instead of just "1961") or "under-detection" (e.g., identifying "Obama" but missing "Barack").
  2. Domain Gaps: When transitioning from a source domain (like News) to a target domain (like Medical), the mathematical "prototypes" used to represent categories often become unaligned, leading to misclassification.
Visualizing the problems of over/under-detected spans and unaligned prototypes versus the BANER solution.

The BANER Framework

To address these issues, the researchers introduced BANER (Boundary-Aware LLMs for Few-Shot NER). While it adopts a traditional two-stage framework, it incorporates two key innovations to sharpen the model's precision:

Boundary-Aware Contrastive Learning

During the span detection stage, the model uses a "contrastive loss" strategy. It doesn't just learn what a correct entity looks like; it explicitly learns to distinguish correct spans from "near-miss" negative samples (spans shifted by one or two words). This training forces the LLM to become hyper-sensitive to exact entity boundaries.

LoRAHub for Domain Adaptation

To resolve alignment issues across different domains, BANER utilizes LoRAHub. Instead of standard fine-tuning, it composes multiple Low-Rank Adaptation (LoRA) modules. This allows the model to dynamically align target domain information with the knowledge it already possesses from the source domain, creating more accurate prototypes for classification.

The two-stage BANER architecture: (a) Entity Span Detection with contrastive loss and (b) Entity Type Classification using LoRAHub.

Key Insights and Experimental Results

The researchers evaluated BANER on rigorous benchmarks, including Few-NERD (66 fine-grained types) and a Cross-Dataset transfer benchmark involving medical records (I2B2), news (CoNLL), and social media (WNUT).

  • State-of-the-Art Performance: On the Few-NERD "Intra" task, BANER achieved an average F1 score of 66.47, outperforming the previous best model (TadNER) by 5.2%.
  • Robust Cross-Domain Transfer: In 5-shot cross-dataset settings, BANER outperformed baselines by an average of 5.1%.
  • Layer-Specific Intelligence: A notable finding was that the 25th hidden layer of LLaMA-2-7B served as the "sweet spot" for boundary perception, yielding the best balance between precision and recall.
  • Generalizability: The strategy proved effective across different architectures, including Mistral-7B and LLaMA-3-8B, suggesting that boundary awareness is a fundamental improvement for LLM-based extraction.

Conclusion and Future Work

BANER demonstrates that Large Language Models can be transformed into high-precision information extractors by sharpening their perception of entity boundaries. While the current work focused on 7B and 8B parameter models, future research may explore scaling these strategies to larger models like LLaMA-3-70B and optimizing the inference speed of the two-stage pipeline.

Summary updated

Abstract

Despite the recent success of two-stage prototypical networks in few-shot named entity recognition (NER), challenges such as over/under-detected false spans in the span detection stage and unaligned entity prototypes in the type classification stage persist. Additionally, LLMs have not proven to be effective few-shot information extractors in general. In this paper, we propose an approach called Boundary-Aware LLMs for Few-Shot Named Entity Recognition to address these issues. We introduce a boundary-aware contrastive learning strategy to enhance the LLM's ability to perceive entity boundaries for generalized entity spans. Additionally, we utilize LoRAHub to align information from the target domain to the source domain, thereby enhancing adaptive cross-domain classification capabilities. Extensive experiments across various benchmarks demonstrate that our framework outperforms prior methods, validating its effectiveness. In particular, the proposed strategies demonstrate effectiveness across a range of LLM architectures. The code and data are released on https://github.com/UESTC-GQJ/BANER.
BibTeX
@inproceedings{guo2025baner,
  author = {Quanjiang Guo and Yihong Dong and Ling Tian and Zhao Kang and Yu Zhang and Sijie Wang},
  title = {{BANER: Boundary-Aware LLMs for Few-Shot Named Entity Recognition}},
  booktitle = {International Conference on Computational Linguistics},
  year = {2025},
  url = {https://openreview.net/forum?id=yaQilXbLPb},
}
Figure