Abstract
Standard Neural Machine Translation (NMT) models typically rely on a single, deterministic way to segment input sentences into words or subwords, which often discards useful linguistic information. This paper introduces a Lattice-Based Transformer Encoder that integrates multiple segmentation hypotheses into a single graph structure. By utilizing novel positional encodings and structural attention mechanisms, the model significantly improves translation quality by capturing the inherent ambiguity in language segmentation. Experimental results on Chinese-English and English-German translation tasks demonstrate significant improvements in BLEU scores over standard Transformer baselines.
Introduction
In NMT, the initial step of tokenization—breaking a sentence into words or subwords (e.g., via Byte Pair Encoding)—is often ambiguous. In languages like Chinese, where no spaces exist between words, different segmenters may produce conflicting outputs. Even in English, the choice of subword vocabulary size is somewhat arbitrary, and different granularities can lead to different semantic representations. Choosing a single "best" segmentation can lead to downstream translation errors.
Previous research utilized Recurrent Neural Networks (RNNs) to handle "lattices"—directed acyclic graphs representing multiple segmentation paths. However, the Transformer architecture, which is the current state-of-the-art for NMT, is designed for parallel sequences rather than graphs. This paper addresses how to feed complex, non-linear lattices into the parallelized Transformer architecture without losing structural relationships.
Methods
The authors propose two primary modifications to the standard Transformer encoder to accommodate lattice inputs:
Lattice Positional Encoding (LPE)
Standard Transformers use linear positional encodings (1, 2, 3...) to denote word order. In a lattice, words have varying lengths and can overlap. LPE assigns positions based on the node indices in the lattice graph. For instance, if a word spans from character index 0 to 2, its position is derived from these indices. This ensures that any path through the lattice maintains a consistent chronological order.
Lattice-Aware Self-Attention (LSA)
To help the model understand the graph topology, the attention mechanism is modified to account for structural relations. The authors define eight specific relations between any two edges in the lattice (e.g., "left adjacent," "includes," "overlaps"). These relations are transformed into learnable embeddings and integrated into the attention calculation, allowing the model to perceive how different segmentation hypotheses relate spatially.
Experimental Setup
The model was evaluated on two major tasks:
- NIST Chinese-English (Zh-En): A large-scale dataset (1.25M pairs) where word segmentation is notoriously difficult. Lattices were built using three segmenters: PKU, MSR, and CTB.
- IWSLT 2016 English-German (En-De): A smaller dataset (191k pairs) used to test subword lattices created by combining different BPE merge settings (8k, 16k, and 32k).
Results and Discussion
The Lattice-Transformer demonstrated superior performance across both tasks:
- Zh-En Performance: The model (LPE + LSA) achieved a BLEU score of 41.26, significantly outperforming the best single-segmentation Transformer baseline (40.35) and vastly exceeding previous Lattice-RNN models (~32.95).
- En-De Performance: Even for English, using a lattice of different subword granularities improved the BLEU score by approximately 1.1 points over the standard 16k BPE baseline.
- Efficiency: The LSA mechanism adds only about 6k parameters to a 90M parameter model. While the input sequence length increases, the model remains highly parallelizable. However, the lattice model is approximately 2.2x slower to train than a standard Transformer due to the increased sequence length.
Conclusion
The "uncertainty" in language segmentation is a valuable feature that can be leveraged for more robust NMT. By encoding multiple hypotheses into a lattice and using specialized attention and positional mechanisms, the Transformer can learn richer representations. Future work may involve applying this graph-encoding method to other structured inputs, such as syntax trees or named entity information.
Summary updated