Informed Named Entity Recognition Decoding for Generative Language Models

Tobias Deußer, Lars Hillebrand, Christian Bauckhage, Rafet SifaarXiv 2023

TL;DR

The paper introduces iNERD (Informed Named Entity Recognition Decoding), a framework that reframes Named Entity Recognition (NER) as a generative task for decoder-only Large Language Models (LLMs). By incorporating a novel constrained decoding mechanism that masks out invalid tokens at inference time, iNERD completely eliminates LLM hallucinations and delivers state-of-the-art performance on financial NER datasets while remaining highly adaptable to new entity classes.

What Problem Does This Paper Address?

Traditional Named Entity Recognition (NER) systems treat the problem as a token classification task, typically relying on "encoder-only" architectures like BERT. In this setup, every word in a sentence is assigned a label (e.g., "B-ORG" for the beginning of an organization) using rigid tagging schemes like IOB (Inside-Outside-Beginning), as illustrated below:

Figure 1: Illustration of Named Entity Recognition as a token classification task with the IOB tagging scheme. Each input token is classified either as B-Entity type, I-Entity type, or O.

While effective, this approach has two major drawbacks: it requires retraining the classification layer whenever entity classes change, and it fails to leverage the massive language-understanding breakthroughs of modern generative "decoder-only" LLMs (like Llama or GPT).

However, simply asking a standard LLM to generate named entities out-of-the-box introduces a massive hurdle: hallucinations. Generative models frequently alter the original text, invent non-existent entities, or fail to follow strict formatting constraints required for downstream data pipelines. The authors tackle this gap by making generative LLMs safe and highly effective for structured information extraction.

Methods

The iNERD framework relies on three core components:

  1. Generative Formatting: Instead of token tags, the target output is structured as an extension of the input text using special structural tokens. For example: "EU rejects German call to boycott British lamb. <CT> Organisation <TCS> EU <ES> Location <TCS> German <ES> Location <TCS> British <ES>" Here, <CT> signals the start of entity generation, <TCS> separates the entity type from its content, and <ES> separates distinct entities. Crucially, entity types (like "Organisation") are kept as regular text tokens rather than special tokens, preserving the model's pre-trained semantic understanding of those words.

  2. Informed Decoding (The iNERD Algorithm): To eliminate hallucinations, the authors introduce a post-processing step during inference that dynamically masks the model's vocabulary scores based on four strict structural rules:

  3. After a combine (<CT>) or separator (<ES>) token, only allow valid entity types or the end-of-sequence token.
  4. After an entity type, force the type-content separator (<TCS>).
  5. After <TCS>, only allow tokens that actually exist in the original input sentence ($I_s$).
  6. During entity content generation, only allow the continuation of the phrase from the input sentence or the <ES> token to close the entity.

This process ensures the model can never generate a word that wasn't in the source text.

Figure 2: Illustration of the first two steps taken during the inference pipeline of our complete model setup. The model starts with the Input IInference as shown in Equation 2, which is fed into the generative language model (GLM). This outputs a score vector S over the vocabulary, which in turn is processed by the iNERD algorithm as described in Algorithm 1. The highest-scoring token from the vocabulary is then appended to the input, and the process starts anew. This is repeated until the model predicts the end-of-sequence token.
  1. Coarse-Tuning: Before evaluating on specific tasks, the models undergo a "coarse-tuning" phase where they are trained on a massive, merged corpus of diverse NER datasets to learn the general syntax of the extraction task.

Datasets

The authors evaluated iNERD across eight diverse datasets spanning general, biomedical, and financial domains:

  • General Purpose: CoNLL-2003, CoNLL++, OntoNotes, Few-NERD, and WNUT-17 (which focuses on unusual/emerging entities).
  • Biomedical: JNLPBA and NCBI-Disease.
  • Financial: FiNER-ORD.

Together, the combined training corpus comprised 290,317 sentences.

Key Insights and Ideas

  • Preserving Natural Token Embeddings Matters: Unlike prior generative NER attempts that added special tokens for entity types (e.g., <ORG>), iNERD uses standard words ("Organisation"). This allows the LLM to leverage its pre-trained knowledge of what an "organization" actually is, accelerating convergence.
  • The LoRA Bottleneck: Surprisingly, larger models (like Llama-13B) did not always outperform smaller ones (like the 3B RedPajama model) during coarse-tuning. The authors attribute this to Low-Rank Adaptation (LoRA). Freezing the base weights and updating only a small fraction of parameters restricted the larger models' capacity to learn the subtle nuances of datasets with massive entity class sets (like Few-NERD's 66 classes).
  • Domain Pre-training is a Superpower: The 2.7B BioMedLM model achieved exceptional results on biomedical datasets, proving that domain-specific pre-training remains vital even when using constrained decoding strategies.

Key Results

  • New State-of-the-Art: iNERD established a new state-of-the-art on the financial FiNER-ORD dataset, outperforming the previous best model by a substantial margin of over 4% $F_1$ score (achieving up to 83.75% $F_1$ with Llama-13B).
  • Competitive with Encoder Baselines: On standard benchmarks like CoNLL-2003 and CoNLL++, iNERD performed on par with or better than classic encoder-only baselines like BERT-Base, without requiring complex, task-specific classification heads.
  • Zero-Shot Adaptability: Even without dataset-specific fine-tuning, coarse-tuned models equipped with iNERD achieved highly respectable scores (e.g., 92.09% $F_1$ on CoNLL++), demonstrating that the system can seamlessly adapt to new entity distributions on the fly.

Detailed fine-tuning results across all datasets can be seen in the evaluation table below:

Fine-tuning results across all eight datasets

Limitations and Future Work

While iNERD excels in low-to-medium complexity settings, it struggles on datasets with highly granular entity hierarchies. For instance, on Few-NERD (66 classes) and OntoNotes (18 classes), traditional encoder-only models with specialized architectures (like PL-Marker) still hold the upper hand.

Moving forward, the authors plan to scale this approach to massive generative models (such as the 70-billion parameter Llama variation) and explore training without LoRA to bypass parameter bottlenecks. Furthermore, they note that iNERD's rigid, rule-based masking structure is highly applicable to other rigid information extraction tasks, making relation extraction and event identification promising frontiers for future research.

Summary updated

BibTeX
@misc{deuer2023informed,
  author = {Tobias Deußer and Lars Hillebrand and Christian Bauckhage and Rafet Sifa},
  title = {{Informed Named Entity Recognition Decoding for Generative Language Models}},
  year = {2023},
  eprint = {2308.07791},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2308.07791},
}
Figure