Lattice-BERT: Leveraging Multi-Granularity Representations in Chinese Pre-trained Language Models

Yuxuan Lai, Yijia Liu, Yansong Feng, Songfang Huang, Dongyan Zhao

Abstract

Chinese pre-trained language models usually process text as a sequence of characters, while ignoring more coarse granularity, e.g., words. In this work, we propose a novel pre-training paradigm for Chinese -- Lattice-BERT, which explicitly incorporates word representations along with characters, thus can model a sentence in a multi-granularity manner. Specifically, we construct a lattice graph from the characters and words in a sentence and feed all these text units into transformers. We design a lattice position attention mechanism to exploit the lattice structures in self-attention layers. We further propose a masked segment prediction task to push the model to learn from rich but redundant information inherent in lattices, while avoiding learning unexpected tricks. Experiments on 11 Chinese natural language understanding tasks show that our model can bring an average increase of 1.5% under the 12-layer setting, which achieves new state-of-the-art among base-size models on the CLUE benchmarks. Further analysis shows that Lattice-BERT can harness the lattice structures, and the improvement comes from the exploration of redundant information and multi-granularity representations.

Introduction

In English, tokenization is relatively straightforward due to natural word boundaries. In contrast, Chinese text is a continuous sequence of characters. Standard Chinese pre-trained language models (PLMs), such as BERT, typically process text character-by-character. This approach often misses crucial word-level semantics. For instance, the characters "老" (old) and "板" (board) combine to mean "boss" (老板), a semantic shift that is difficult to capture from individual characters alone.

While some models attempt to integrate word-level information using fixed segmentation tools, they are vulnerable to cascading errors if the segmenter fails. Lattice-BERT addresses this by utilizing a word lattice: a graph structure that simultaneously includes characters and all possible valid word segmentations. This allows the model to leverage multi-granularity information without being tethered to a single, potentially incorrect segmentation.

Methodology

Integrating a lattice into a Transformer architecture presents two primary challenges: structural mismatch and information leakage. Lattice-BERT introduces two key innovations to solve these issues.

Lattice Position Attention (LPA)

Because a word lattice is a graph rather than a linear sequence, standard positional embeddings are insufficient. Lattice-BERT employs Lattice Position Attention (LPA) to explicitly encode the structural relationships between tokens. Instead of simple linear indices, LPA calculates attention based on absolute positions, relative distances, and seven specific positional relationships (e.g., whether a token is contained by another, overlaps, or is detached).

The seven positional relationships used in Lattice Position Attention (LPA) to capture structural dependencies.

Masked Segment Prediction (MSP)

Standard Masked Language Modeling (MLM) can lead to "cheating" in a lattice structure. If a character is masked but its overlapping word remains visible, the model can deduce the missing character without understanding the broader context. To prevent this, the authors propose Masked Segment Prediction (MSP). The model identifies "minimal segments"—clusters of overlapping characters and words—and masks the entire segment, forcing the model to rely on non-overlapping context.

Overall architecture of Lattice-BERT, showing the transformation from sentence to lattice and the Masked Segment Prediction (MSP) task.

Experiments and Results

Lattice-BERT was pre-trained on an 18.3 GB corpus of unlabeled Chinese text and evaluated on 11 tasks, including the CLUE benchmark and sequence labeling tasks like Named Entity Recognition (NER).

  • State-of-the-Art Performance: Lattice-BERT achieved a new SOTA among base-size models on the CLUE benchmark, outperforming character-only baselines by an average of 1.5% across 11 tasks.
  • Efficiency: Despite the added complexity of the lattice, the model remains parameter-efficient at 100M parameters, significantly smaller than dual-encoder multi-granularity models like AMBERT (176M).
  • Boundary Detection: The model showed a 25% reduction in nested entity errors in NER tasks, demonstrating its superior ability to handle overlapping semantic boundaries.

Conclusion

Lattice-BERT demonstrates that redundancy in word lattices is a feature that provides rich, multi-faceted context. By unifying character and word representations in a single graph-based encoder and preventing information leakage through MSP, the model achieves superior performance on Chinese NLU tasks. While the lattice structure increases computational overhead by roughly 48%, the gains in accuracy and boundary detection make it a powerful paradigm for non-spaced languages.

Summary updated

BibTeX
@inproceedings{lai2021lattice,
  author = {Yuxuan Lai and Yijia Liu and Yansong Feng and Songfang Huang and Dongyan Zhao},
  title = {{Lattice-BERT: Leveraging Multi-Granularity Representations in Chinese Pre-trained Language Models}},
  booktitle = {Conference of the North American Chapter of the Association for Computational Linguistics},
  year = {2021},
  doi = {10.18653/v1/2021.naacl-main.137},
}
Figure