A Representation Level Analysis of NMT Model Robustness to Grammatical Errors (2025)

Abstract: Understanding robustness is essential for building reliable NLP systems. Unfortunately, in the context of machine translation, previous work mainly focused on documenting robustness failures or improving robustness. In contrast, we study robustness from a model representation perspective by looking at internal model representations of ungrammatical inputs and how they evolve through model layers. For this purpose, we perform Grammatical Error Detection (GED) probing and representational similarity analysis. Our findings indicate that the encoder first detects the grammatical error, then corrects it by moving its representation toward the correct form. To understand what contributes to this process, we turn to the attention mechanism where we identify what we term *Robustness Heads*. We find that *Robustness Heads* attend to interpretable linguistic units when responding to grammatical errors, and that when we fine-tune models for robustness, they tend to rely more on *Robustness Heads* for updating the ungrammatical word representation.

## introduction neural machine translation (nmt) has seen great success, especially since the introduction of the transformer architecture @xcite . recent advances in nmt introduced models that can translate between over 200 languages @xcite . while this achievement is impressive and drives the deployment in real-world scenarios, evaluating and understanding nmt robustness remains essential for building reliable nmt systems. early works have focused on documenting the robustness failures of nmt models, or improving their robustness @xcite @xcite @xcite . however, there has been limited analysis of model representations in response to noise. therefore, our goal in this work is to fill this gap by analyzing robustness from a representation perspective. our hypothesis is that the encoder detects and corrects the representation of the ungrammatical word by moving its representation toward the correct form. to study the detection part, we use ged probing to evaluate how the accuracy of detecting the ungrammatical word changes through the encoder layers. for the correction part, we measure the representation distance between the ungrammatical word and its correct grammatical form. we find that generally the probing performance increases in the first half layers of the model, then plateaus or decreases, while the representation distance on the overall decreases along model layers. to understand what contributes to correcting the representations, we turn to the attention mechanism due to its crucial contribution to transformer model performance. we identify what we term robustness heads, which are attention heads that contribute to moving the ungrammatical word's representation toward its correct form. we find that after fine-tuning models on ungrammatical sentences, and thus, making them more robust, they learn to rely more on robustness heads for updating the ungrammatical word's representation especially in deeper layers where we hypothesize that the correction is happening. our work addresses the following research questions and makes the following contributions: rq1: how do models represent and handle grammatical errors to achieve robustness? nmt encoders inherently implement a grammatical error correction (gec) setup in which they first detect the ungrammatical word, then correct it by moving its representation toward the grammatical form. rq2: how does grammatical error representation differ across models and languages? models respond similarly to grammatical errors however we find differences across languages which we attribute to their linguistic differences. rq3: how does fine-tuning for robustness influences models to achieve improved robustness? fine-tuned models exhibit similar behavior to their base models but tend to rely more on robustness heads for handling grammatical errors and enhancing their resilience to noisy inputs. ## related work there have been multiple works analyzing transformer models representations for different purposes. probing has been explored for understanding information that is encoded in pre-trained model representations @xcite @xcite @xcite , as well as to understand the effect of fine-tuning @xcite @xcite , and contextual embeddings @xcite . the attention module, given its importance in the success of the transformer architecture, has also been explored for interpreting transformer models @xcite @xcite . other works have focused on understanding and comparing between different models through the lens of similarity analysis @xcite @xcite . in our work, we combine all these techniques to understand nmt models robustness to grammatical errors. fine-tuning on downstream tasks leads to changes in representations that might not be favorable (e.g. catastrophic forgetting), and thus has been an active area of analysis @xcite @xcite @xcite . our work focuses on understanding the effects of fine-tuning for robustness to grammatical errors in the context of nmt, where we look at both model representations and downstream nmt performance. robustness is of critical importance for nlp models. early works have explored improving robustness to different types (e.g. user generated data, automatic speech recognition, non native speakers, ...) of noise by using synthetic data @xcite @xcite @xcite @xcite . recent works show that even large language models (llms) witness performance degradation when confronted with synthetic noise @xcite . multiple techniques were introduced to deal with noise or adversarial attacks by pushing noisy or adversarial samples representations to be similar to those of the original samples @xcite @xcite and our experiments show that nmt encoders do this inherently when trained on synthetic noise. while analyzing the robustness of nmt transformer models has been an area of exploration @xcite @xcite @xcite , the focus was more on documenting model failures under noise or adversarial attacks rather than analyzing the model internals, therefore, our work is an attempt to fill this gap. in computer vision, however, cianfarani et al. (2022) explored representation similarity to understand adversarially trained deep neural networks (dnns) and compare them to non-robust dnns, while we focus on understanding the effect of fine-tuning nmt transformer models on synthetic grammatical errors, and we compare them against their base model as a less robust model, as well as against a domain adapted model. in addition, we probe the linguistic features encoded in the representations and we compare the models on the basis of their attention mechanism. ## methodology our analysis starts by introducing grammatical errors in the dataset, which we describe in §3.1. subsequently, in §3.2 we describe how we fine-tune models for robustness to analyze the effects of finetuning. finally, in §3.3 we present the methods of our analysis, namely: ged probing, representation similarity, and robustness heads, where we describe our method for finding robustness heads, and analyzing their attention to pos tags. ## conclusion and future work in this work, we analyze transformer nmt encoders under the effect of grammatical noise, and investigate how fine-tuning for robustness affects model behavior and internal representations. we find that the encoder -especially after fine-tuningimplements a gec setup: it first detects the error and then corrects it by adjusting the representation of the ungrammatical word towards its correct form. to better understand this behavior, we propose a method for finding robustness headsattention heads that attend to pos tags and help detect and correct the grammatical error. additionally, we find that fine-tuning on grammatical errors leads the model to use more robustness heads especially in deeper layers. these findings suggest a practical strategy for improving robustness in nmt systems: fine-tuning only the encoder on (synthetically) noisy data can substantially enhance robustness without degrading performance on clean data. this makes it an efficient and interpretable alternative to full model fine-tuning. in practice, such systems may benefit from selectively introducing common error types-especially those relevant to their deployment context-during fine-tuning. furthermore, our analysis framework, which combines ged probing, representational similarity and influential attention heads, is model-agnostic and generalizable. it provides a systematic way to audit robustness across different models and languages and could be applied to other encoderdecoder nlp systems. although we focused our analysis on encoderdecoder models, we hypothesize that decoder-only models may exhibit a similar behavior especially in their early layers, therefore, we will extend this analysis to decoder only models in future work.