Skip to main content
QUICK REVIEW

[Paper Review] $k$NN-NER: Named Entity Recognition with Nearest Neighbor Search

Shuhe Wang, Xiaoya Li|arXiv (Cornell University)|Mar 31, 2022
Topic ModelingComputer Science11 citations
TL;DR

This paper proposes $k$NN-NER, a retrieval-augmented framework for Named Entity Recognition that enhances vanilla NER models by interpolating predictions from $k$ nearest neighbors retrieved from a cached training set during inference. By leveraging similarity-based neighbor search without retraining, $k$NN-NER achieves state-of-the-art performance, including a 72.03 F1-score on Chinese Weibo NER and comparable results with 40% less training data.

ABSTRACT

Inspired by recent advances in retrieval augmented methods in NLP~\citep{khandelwal2019generalization,khandelwal2020nearest,meng2021gnn}, in this paper, we introduce a $k$ nearest neighbor NER ($k$NN-NER) framework, which augments the distribution of entity labels by assigning $k$ nearest neighbors retrieved from the training set. This strategy makes the model more capable of handling long-tail cases, along with better few-shot learning abilities. $k$NN-NER requires no additional operation during the training phase, and by interpolating $k$ nearest neighbors search into the vanilla NER model, $k$NN-NER consistently outperforms its vanilla counterparts: we achieve a new state-of-the-art F1-score of 72.03 (+1.25) on the Chinese Weibo dataset and improved results on a variety of widely used NER benchmarks. Additionally, we show that $k$NN-NER can achieve comparable results to the vanilla NER model with 40\% less amount of training data. Code available at \url{https://github.com/ShannonAI/KNN-NER}.

Motivation & Objective

  • Address the long-tail entity recognition challenge in NER, where rare or unseen entities are poorly handled by standard models.
  • Improve few-shot and low-resource learning capabilities by accessing relevant training examples through retrieval.
  • Enhance model generalization without requiring additional training or architectural modifications.
  • Demonstrate that inference-time retrieval of similar training examples can outperform standard memorization-based training.
  • Show that $k$NN-NER maintains strong performance even when training data is reduced by 40%, indicating data efficiency.

Proposed method

  • Cache representation-label pairs from the hidden states of a pre-trained vanilla NER model (e.g., BERT) during training.
  • During inference, encode the input token (e.g., 'Washington') and perform $k$ nearest neighbor (kNN) search in the datastore using cosine similarity.
  • Retrieve $k$ most similar training examples and extract their label distributions.
  • Interpolate the vanilla NER model’s output distribution with the $k$ nearest neighbor label distributions using a learnable or fixed weighting scheme.
  • Use the interpolated distribution as the final prediction for each token, improving robustness on rare or out-of-vocabulary entities.
  • Apply the method to various pre-trained models (BERT, RoBERTa, ChineseBERT) across English and Chinese NER benchmarks without retraining.

Experimental results

Research questions

  • RQ1Can $k$ nearest neighbor search from a cached training set improve NER performance on long-tail and rare entities?
  • RQ2Does the proposed $k$NN-NER framework enhance few-shot and low-resource learning without additional training?
  • RQ3How sensitive is the performance to the choice of $k$ in the kNN search?
  • RQ4Can $k$NN-NER achieve comparable results to standard NER models with significantly reduced training data?
  • RQ5Does the retrieval-augmented approach consistently improve performance across diverse NER benchmarks, including multilingual and low-resource settings?

Key findings

  • On the Chinese Weibo NER dataset, $k$NN-NER achieves a new state-of-the-art F1-score of 72.03, representing a +1.23 improvement over the vanilla ChineseBERT-Large model.
  • On Chinese OntoNotes 4.0, the method achieves a +1.75 F1-score improvement over the vanilla BERT-Base model when using $k$=256.
  • With only 60% of the training data, $k$NN-NER matches the performance of the full-data vanilla model on Chinese OntoNotes 4.0, demonstrating strong data efficiency.
  • The performance stabilizes at $k$=256, with no further gain at $k$=512, indicating robustness to hyperparameter choice.
  • The method consistently improves F1 scores across all evaluated benchmarks, including CoNLL03, OntoNotes5.0, MSRA, and Weibo NER, with gains ranging from +0.11 to +1.63.
  • The interpolation mechanism effectively leverages semantically similar training examples, improving predictions for rare or unseen entities without retraining.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.