Hamidreza Ghader, Christof Monz
Proceedings of Machine Translation Summit XVII: Research Track. 2019.
Abstract
This research offers a detailed investigation into the internal representations of the two most dominant architectures in Neural Machine Translation (NMT): the Transformer and the Recurrent Neural Network (RNN). By moving away from traditional extrinsic probing methods, the authors utilize intrinsic nearest neighbor analysis to reveal how these models prioritize linguistic information. The study finds that Transformers are significantly better at preserving lexical semantics, while RNNs dedicate more internal capacity to capturing sentence structure and syntax.
Introduction: Beyond the "Black Box"
Deep learning models are often criticized as "black boxes." To understand what linguistic information NMT encoders capture, researchers typically employ extrinsic probing, where hidden states are used to train separate classifiers for tasks like part-of-speech tagging. However, this does not reveal what the model intrinsically finds important.
This paper addresses this gap by asking: If we look at a specific word's representation in a sentence, what other word occurrences in the dataset does the model think are most similar? By analyzing these "nearest neighbors," we can determine whether the model groups words based on their dictionary meaning (semantics) or their grammatical function (syntax).
Methodology
The authors compared a two-layer bidirectional LSTM (RNN) with a six-layer Transformer using an "intrinsic" toolkit:
- Nearest Neighbor Mapping: For every word occurrence, they identified the top 10 most similar hidden states in the corpus using cosine similarity. This allows for a visualization of how the model clusters concepts.
- Lexical Semantics (WordNet Coverage): They measured how many of these neighbors were related via WordNet (synonyms, hyponyms, etc.) or were neighbors of the static word embedding.
- Syntactic Similarity (PARSEVAL): They used the PARSEVAL metric to compare the grammatical subtree of a query word with the subtrees of its nearest neighbors. If the neighbors share similar tree structures, the model is prioritizing syntax.
Key Insights and Results
The "Semantic" Transformer vs. The "Syntactic" RNN
The analysis revealed a fundamental divergence in how these architectures process language:
- Lexical Semantics: Transformers achieved 67-74% WordNet coverage, whereas RNNs only managed 24-51%. This suggests that Transformers keep the core meaning of a word highly accessible, even in deeper layers.
- Syntax: In English-German tasks, RNNs showed a higher syntactic similarity score (0.38) compared to Transformers (0.31). RNN hidden states diverge significantly from their original word embeddings, "warping" representations to prioritize structural roles over dictionary definitions.
Positional Bias and Directionality
RNNs exhibit a distinct positional bias: words at the beginning or end of a sentence have more "focused" representations, while words in the middle are more "diluted" by context. Transformers do not show this bias, treating all positions with consistent focus.
Furthermore, in bidirectional RNNs, the backward layer (reading right-to-left) is significantly better at capturing word meanings than the forward layer. The authors suggest the forward layer is more heavily taxed with encoding long-distance context as it processes the sentence sequentially.
Conclusion
This study demonstrates that Transformers are the "kings of word meaning," maintaining high fidelity to lexical semantics. In contrast, RNNs are more "aware" of the parse tree, transforming input embeddings aggressively to represent syntactic structures.
Future work may expand this analysis to the NMT decoder or investigate middle layers of the Transformer, where recent research suggests significant syntactic processing may occur. Additionally, testing these findings on morphologically rich or low-resource languages remains a vital next step.
Summary updated