Introduction
Most Pre-trained Language Models (PLMs) for Chinese, such as the original BERT, treat text as a sequence of individual characters. However, Chinese is a language where meaning is heavily concentrated in words, which are often composed of multiple characters. The meaning of a word is not always the sum of its parts; for instance, the characters for "elder" (老) and "board" (板) combine to form "boss" (老板).
While previous research attempted to incorporate word-level information, these efforts often relied on a single "best guess" for word segmentation, which is prone to errors. Alternatively, using separate encoders for words and characters is computationally expensive and limits interaction between granularities. Lattice-BERT addresses these challenges by representing sentences as "word lattices" rather than simple character sequences, incorporating both fine-grained characters and coarse-grained words into a unified Transformer architecture.
The Lattice-BERT Architecture
Lattice-BERT utilizes a directed acyclic graph (DAG) where nodes represent character positions and edges represent every possible character or word found in a large vocabulary (102K words). This structure allows the model to process all potential segmentations simultaneously, avoiding the pitfalls of pre-segmentation errors.
Lattice Position Attention (LPA)
Standard Transformers use simple linear position IDs, which are insufficient for a non-linear lattice. Lattice-BERT introduces Lattice Position Attention (LPA), a sophisticated mechanism that considers absolute positions (start and end points), relative distances, and explicit positional relations.
LPA explicitly models seven types of relationships between tokens, such as whether one token contains another or if they overlap on the left. This ensures the model maintains the structural integrity of the lattice without losing track of the positional relationships between overlapping units.
Masked Segment Prediction (MSP)
In standard BERT, random tokens are masked for prediction. In a lattice, this creates a risk of "information leakage." For example, if the word "research" is masked, the model could "cheat" by looking at the unmasked individual characters for "re" and "search." To prevent this, Lattice-BERT uses Masked Segment Prediction (MSP). MSP identifies "minimal segments"—clusters of overlapping tokens—and masks the entire segment at once, forcing the model to rely on broader context rather than local overlapping clues.
Results and Performance
Lattice-BERT was evaluated on 11 diverse Chinese NLU tasks from the CLUE (Chinese Language Understanding Evaluation) benchmark, including classification, machine reading comprehension (MRC), and sequence labeling.
Key results include:
- State-of-the-Art Performance: Lattice-BERT (base-size) outperformed all other base-sized models on the CLUE leaderboard at the time of submission.
- Consistent Gains: The model achieved an average improvement of 1.5% over character-only baselines in the 12-layer setting and 2.0% in the 6-layer "lite" setting.
- Efficiency: It outperformed AMBERT (a prominent multi-granularity model) by 0.9% in classification and 1.3% in MRC, despite using a more unified and parameter-efficient architecture.
Analysis of attention scores indicates that the model learns to dynamically shift its focus. In tasks like Named Entity Recognition, it prioritizes word-level tokens that match the ground-truth segmentation, effectively performing implicit word segmentation while solving downstream tasks.
Conclusion and Future Work
Lattice-BERT demonstrates that the inherent redundancy of a word lattice is a strength, providing rich clues for robust representation learning. While the model requires approximately 48% more computational resources than a vanilla character-level BERT due to the increased token count, the performance gains across the CLUE benchmark justify the cost. Future work may explore adapting this lattice structure to integrate phrases or word-pieces into PLMs for other languages beyond Chinese.
Summary updated