Label-Agnostic Sequence Labeling by Copying Nearest Neighbors

Sam Wiseman, Karl Stratos

Overview

This paper introduces a "label-agnostic" approach to sequence labeling that predicts labels by explicitly copying them from retrieved nearest neighbors in a training database. By learning a similarity function between word contexts rather than learning specific label categories, the model can perform impressive zero-shot transfer to entirely new label sets (such as moving from coarse to fine-grained tags) without any retraining.

The Challenge of Label-Dependent Models

Traditional sequence labeling models, such as those used for Part-of-Speech (POS) tagging or Named Entity Recognition (NER), are inherently "label-dependent." They learn a fixed mapping from input features to a specific, predefined set of tags. Consequently, changing the tag set—for instance, moving from 12 Universal POS tags to the 45 specific Penn Treebank tags—typically necessitates retraining the entire model from scratch.

While "retrieve-and-edit" models have emerged to address some of these issues by using similar examples as "hints," they often remain black boxes, making it difficult to interpret why a specific label was chosen. This paper proposes a more transparent and flexible alternative.

Methodology: Learning to Copy

The proposed label-agnostic model relies on two primary components: token-level similarity and structural coherence.

Token-Level Copying

Instead of predicting a label index directly, the model calculates the similarity between the current word ($x_t$) and all words in a retrieved set of neighbor sentences ($x_k^{(m)}$). Using BERT to generate contextual embeddings, the probability of selecting a label is proportional to the dot-product similarity between these embeddings. Essentially, the model identifies the most similar word in its memory and adopts its label.

The label-agnostic mechanism: the model predicts a tag for the target sequence $x$ by identifying and copying labels from similar word contexts in a training database.

Dynamic Programming (DP) for Coherence

Predicting labels on a word-by-word basis can result in "jittery" or inconsistent sequences. To mitigate this, the authors implement a DP-based decoding algorithm that encourages the model to copy contiguous segments from the neighbors. A transition penalty ($c$) is applied whenever the model switches to a new segment from the database, promoting structural consistency and improving interpretability.

The effect of the segment transition penalty $c$ on NER performance and segment length.

Experimental Setup

The model was evaluated on several standard benchmarks:

  • Penn Treebank (PTB): For standard and Universal POS tagging.
  • CoNLL 2003: For NER and Chunking.
  • OntoNotes: For fine-grained NER.

A key focus was "Zero-Shot" transfer, where the model is trained on one task (e.g., CoNLL Chunking) and tested on another with a different label set (e.g., CoNLL NER) simply by swapping the reference database at test time.

Key Insights

  • Similarity as a Universal Proxy: High-quality word representations allow the model to bypass learning specific label definitions. It only needs to recognize when two words function similarly in context.
  • Zero-Shot Flexibility: Because the model is label-agnostic, the "memory" (labeled database) can be swapped at test time. Providing a memory with fine-grained tags allows the model to output them immediately, even if it was trained on coarse ones.
  • Structural Contiguity: Human-labeled data possesses inherent syntactic chunks. By forcing the model to prefer sequence copying rather than individual tokens, it effectively leverages the underlying syntactic structure of the retrieved neighbors.

Results and Performance

  • Competitive Accuracy: On standard tasks where training and testing labels match, the Nearest Neighbor (NN) model performed within 0.1 to 0.5 points of a standard fine-tuned BERT model.
  • Zero-Shot Breakthrough: In the "Chunking → NER" transfer task, a standard BERT model failed (8.03 F1) because it could not map chunk tags to NER tags. The NN model achieved a massive 71.74 F1 by simply utilizing NER-labeled neighbors at test time.
  • DP Gains: The transition penalty $c$ improved NER test scores from 89.94 to 90.20, validating the importance of structural coherence for accuracy.

Limitations and Future Directions

The primary trade-off for this flexibility is retrieval overhead; processing 100 neighbors per sentence is more computationally intensive than a standard feed-forward pass. Additionally, the model's performance is strictly bound by the quality and coverage of the reference database. Future work may explore more complex "editing" operations beyond simple copying to handle tasks like translation or parsing.

Summary updated

BibTeX
@inproceedings{wiseman2019label,
  author = {Sam Wiseman and Karl Stratos},
  title = {{Label-Agnostic Sequence Labeling by Copying Nearest Neighbors}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2019},
  doi = {10.18653/v1/p19-1533},
}
Figure