A Closer Look at Parameter Contributions When Training Neural Language and Translation Models (2022)

Abstract: We analyze the learning dynamics of neural language and translation models using Loss Change Allocation (LCA), an indicator that enables a fine-grained analysis of parameter updates when optimizing for the loss function. In other words, we can observe the contributions of different network components at training time. In this article, we systematically study masked language modeling, causal language modeling, and machine translation. We show that the choice of training objective leads to distinctive optimization procedures, even when performed on comparable Transformer architectures. We demonstrate how the various Transformer parameters are used during training, supporting that the feed-forward components of each layer are the main contributors to the optimization procedure. Finally, we find that the learning dynamics are not affected by data size and distribution but rather determined by the learning objective.

## introduction neural models and transformers in particular have achieved a great performance in almost every natural language processing (nlp) task. however, they largely remain black-box systems despite various efforts to analyze them. much work has been devoted to understanding the dense representations that are created during training @xcite in an attempt to see whether known linguistic properties are present and how they are expressed in the model @xcite @xcite . however, the intrinsic dynamics of the training procedure itself have not been analyzed in depth for highly complex network architectures. in this paper, we take a closer look into the process of parameter optimization, aiming at • identifying the network components that contribute to the optimization of the loss function, in order to enable a systematic comparison, we set out with a standard architecture that we train from scratch for each individual task. we use the transformer architecture @xcite with its common parametrization and size, and train it with three popular learning objectives: masked language modeling (mlm) @xcite , causal language modeling (clm), and neural machine translation (nmt). the latter is an interesting special case as it is designed as a conditional language model in a sequence-to-sequence architecture with encoder and decoder components. for the analysis, we use loss change allocation (lca) @xcite , an indicator of the contribution of individual parameters to the decrease of the total loss. its accumulative properties provide us with a tool to perform a fine-grained analysis of the opaque optimization process of complex transformer-based neural nlp models. we can, therefore, examine how individual layers and sub-layer components contribute to the overall loss function. this confers a unique view of the training process and how the network parameters behave during the learning procedures. our analysis provides insight over the training dynamics broken down over the model layers and sub-layer components. on the one hand, we observe key differences in the learning dynamics across the objective arise from the nature of the loss function; depending whether being trained for gap-filling or auto-regressive prediction. on the other hand, we see clear differences linked to the nature of the sub-layer components. we use a consistent experimental setup to enable a systematic and fair comparison between mod-els and learning objectives. with this, we can observe all parameters when training our models from scratch. the methodology and setup are described in detail in sections 2 and 3 before we move on to our analyses and discussion of results in section 4. ## experimental setup models. we apply the common transformer base settings of @xcite . for consistency, we train all the models using the same toolkit, fairseq @xcite . we record the lca at every parameter update and refer the reader to appendix a for a details on model hyper-parameters. ## analyzing the training dynamics and parameter contributions in this section we systematically dissect the development of the training process using the lca indicator. in section 4.1, we look at the overall picture by aggregating the contributions throughout the entire training process. the aggregated figures showcase differences that originate from the training tasks and contrast the monolingual lms with the sequence-to-sequence mt model. in section 4.2 we zoom into the iterative training procedure to further analyze the dynamics of learning network parameters over time. in section 4.3 we analyze the individual attention heads and in section 4.4 we look at the parameters that hurt the optimization process. ## related work the role of the inner representations, and internal behaviors of neural models in nlp have been extensively studied @xcite . relevant directions investigate, for instance, the geometry of the learned representational spaces @xcite , probing the learned representations with simple classifiers @xcite , and the attention patterns at each step in the sequence @xcite . regarding the attention mechanism, while in the past, analyses have tended to focus on the role of the self-attention mechanism as an explanatory mechanism @xcite , recent work has been more nuanced about whether this is even necessary (bastings and filippova, 2020). @xcite argue that the attentive components are not inherently separable from the rest of the model; this has sparked analyses of attention models not directly involving attention weights. @xcite analyse vector norms and find reasonable word alignment, while @xcite show that feed-forward components act as key-value stores. @xcite analyse the effect of freezing different components on the interpretability of the attention mechanism, and @xcite use a novel decomposition of transformer embeddings to isolate the impact of the network components, showing that multi-head attention accounts for a small proportion of the embeddings. most such works tend to test and analyse fixed model checkpoints while there is value to analyzing these models over the course of the training process, much work in this direction emerged from outside the nlp community; e.g., lca was first proposed and tested using only vision classification datasets @xcite , and it has been used since in nlp to analyze nmt training dynamics @xcite . @xcite present another early work on the analysis of the training dynamics of lms; @xcite investigate the language modeling loss on model architecture, size, amount of training data and computing power. their work was key for the development of large-scale pretrained models like gpt-3 @xcite and switch-transformers @xcite . @xcite analyze the training dynamics of transformer-based models based on the stability of the gradients, leading them to propose an adaptive model initialization method. ## conclusions in this work, we take a closer look at the learning dynamics of transformer-based models using the loss change allocation (lca) indicator. specifically, we analyze the training dynamics for (1) masked language modeling, (2) causal language modeling, and (3) machine translation training objectives. we find that the training dynamics seem to be delimited by the training objective being either a gap-filling task or an auto-regressive prediction task, despite the similarities that the models present. in particular, the different layers of each model behave accordingly to the training objective used. we also show that the feed-forward blocks contribute more than the attention blocks to the decrease in loss during training, a finding that strengthens the relative importance of the former, and invites more research to understand this currently more obscure component. we also show that these dynamics are robust against changes in the size and distribution of the training data. the overall trends stay the same with different domains and languages reassuring that our findings are not just an artefact of a specific setup. in future work, we would like to study the training dynamics of systems trained with different optimizers and regularization techniques, such as, attention dropout or data augmentation. we would also like to investigate the influence of noisy training data on the training process. for this, we can apply controlled shuffling to the training data to influence the noise level and gradually remove syntactic information from the training signal.