FLAT: Chinese NER Using Flat-Lattice Transformer

Xiaonan Li, Hang Yan, Xipeng Qiu, Xuanjing Huang

Abstract

Chinese Named Entity Recognition (NER) faces unique challenges due to the lack of explicit word boundaries. While lattice-based models incorporate lexicon information to enhance character-based representations, they often suffer from computational inefficiency and difficulty in capturing long-range dependencies. This paper introduces FLAT (Flat-LAttice Transformer), a novel architecture that converts complex word-character lattices into a flat sequence of spans. By employing a specialized relative position encoding to maintain structural relationships, FLAT achieves state-of-the-art performance across multiple benchmarks while offering significant speed improvements—up to 16 times faster than traditional lattice-based models.

Introduction

Named Entity Recognition (NER) is a fundamental task in Natural Language Processing (NLP). In English, spaces provide clear word boundaries, allowing models to easily leverage word-level information. However, Chinese is written without spaces, making word segmentation a prerequisite or a concurrent challenge for NER. While character-based models avoid segmentation errors, they often fail to utilize the rich semantic information contained within words.

Lattice-based models were developed to bridge this gap. A lattice is a directed acyclic graph (DAG) that represents a character sequence along with all potential words matched from a lexicon. Despite their effectiveness, existing lattice-based models, such as Lattice LSTMs, face two primary limitations. First, their sequential nature makes them computationally inefficient and difficult to parallelize on modern GPUs. Second, recurrent and convolutional architectures struggle to capture long-range dependencies, which are often essential for disambiguating entities in complex sentences.

Methodology: The FLAT Architecture

The authors propose FLAT to address these challenges by "flattening" the lattice structure into a sequence of spans. This approach allows the model to leverage the parallelization and long-range modeling capabilities of the Transformer architecture.

The FLAT architecture utilizes a flat sequence of spans and a specialized relative position encoding to capture lattice structure within a Transformer framework.

Converting Lattice to Spans

In FLAT, every character and potential word in the lattice is treated as an individual "span." Each span is defined by its textual content and its coordinates: a head (start) index and a tail (end) index corresponding to the original character sequence. For instance, in a sequence of characters $c_1, c_2, c_3$, a word spanning from $c_1$ to $c_2$ would have a head of 1 and a tail of 2.

Relative Position Encoding

By flattening the lattice, the explicit graph structure is lost. To reconstruct this structure internally, FLAT introduces a sophisticated relative position encoding. For any two spans $i$ and $j$, the model calculates four distinct distances:

  • Head-to-Head ($d_{ij}^{hh}$)
  • Head-to-Tail ($d_{ij}^{ht}$)
  • Tail-to-Head ($d_{ij}^{th}$)
  • Tail-to-Tail ($d_{ij}^{tt}$)

These four distances are transformed into a dense vector and integrated directly into the Transformer's self-attention mechanism. This allows the model to understand the spatial and structural relationships between any two tokens—whether they are adjacent, overlapping, or one is contained within the other—while maintaining the benefits of global interaction.

Experimental Setup

The performance of FLAT was evaluated on four standard Chinese NER benchmarks:

  • Ontonotes 4.0 and MSRA: Large-scale, general-domain datasets.
  • Resume: A domain-specific dataset focused on financial sector resumes.
  • Weibo: A challenging dataset consisting of informal social media posts.

To ensure a fair comparison, the authors utilized the same lexicons and pre-trained embeddings as previous state-of-the-art models.

Key Results and Discussion

FLAT demonstrated superior performance across all tested datasets, establishing new state-of-the-art F1 scores. On the Ontonotes dataset, for example, FLAT improved the F1 score from 74.85 to 76.45 compared to previous leading models.

FLAT achieves a significant speedup compared to previous lattice-based models, reaching over 16x the speed of Lattice LSTM when using batching.

Beyond accuracy, the most striking result is the model's inference speed. As shown in the performance metrics, FLAT is significantly faster than its predecessors. When utilizing batch processing (batch size = 16), FLAT is 16.32 times faster than the standard Lattice LSTM. This efficiency stems from the removal of recurrent components, making the model highly "GPU-friendly" and practical for real-time deployment.

Ablation studies further highlighted the importance of the lexicon. When "self-matched" words (words that a character is a part of) were masked, the model's performance dropped significantly. This confirms that the primary driver of success is the model's ability to effectively integrate and interact with potential word information through the self-attention mechanism.

Conclusion

FLAT represents a significant advancement in Chinese NER by successfully combining the benefits of lattice-based information with the efficiency of the Transformer. While the model excels on large datasets, the authors noted that improvements on smaller datasets like Weibo and Resume were less pronounced, suggesting that Transformers may require more data to reach their full potential compared to LSTMs. Future research could explore extending the "flattening" approach to other structured data types, such as dependency trees or general graphs, by further adapting the relative position encoding scheme.

Summary updated

BibTeX
@inproceedings{li2020flat,
  author = {Xiaonan Li and Hang Yan and Xipeng Qiu and Xuanjing Huang},
  title = {{FLAT: Chinese NER Using Flat-Lattice Transformer}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2020},
  doi = {10.18653/v1/2020.acl-main.611},
}
Figure