Post-hoc analysis of A rabic transformer models (2022)

Abstract: Arabic is a Semitic language which is widely spoken with many dialects. Given the success of pre-trained language models, many transformer models trained on Arabic and its dialects have surfaced. While there have been an extrinsic evaluation of these models with respect to downstream NLP tasks, no work has been carried out to analyze and compare their internal representations. We probe how linguistic information is encoded in the transformer models, trained on different Arabic dialects. We perform a layer and neuron analysis on the models using morphological tagging tasks for different dialects of Arabic and a dialectal identification task. Our analysis enlightens interesting findings such as: i) word morphology is learned at the lower and middle layers, ii) while syntactic dependencies are predominantly captured at the higher layers, iii) despite a large overlap in their vocabulary, the MSA-based models fail to capture the nuances of Arabic dialects, iv) we found that neurons in embedding layers are polysemous in nature, while the neurons in middle layers are exclusive to specific properties.

## introduction arabic is a linguistically rich language, with its structures realized using both concatenative and templatic morphology. the agglutinating aspect of the language adds to the complexity where a given word could be formed using multiple morphemes. for example, the word (fosqynakmwh 1 -and we gave it to you to drink) combines a conjunction, a verb, and three pronouns. at another longitude, arabic has three variants: classical arabic (ca), modern standard arabic (msa) and dialectal arabic (da). while the msa is traditionally considered as the de facto standard in the written medium and da being the predominantly spoken counterpart, this has changed recently (mubarak and darwish, 2014; zaidan and callison-burch, 2014; durrani et al., 2014). due to the recent influx of social media platforms, dialectal arabic also enjoys a significant presence in the written medium. transfer learning using contextualized representations in pre-trained language models have revolutionized the arena of downstream nlp tasks. a plethora of transformer-based language models, trained in dozens of languages are uploaded every day now. arabic is no different. several researchers have released and benchmarked pre-trained arabic transformer models such as arabert @xcite , arabicbert @xcite , camelbert @xcite , marbert @xcite and qarib @xcite etc. these models have demonstrated state-of-the-art performance on many tasks as well as their ability to learn salient features for arabic. one of the main differences among these models is the genre and amount of arabic data they are trained on. for example, arabert was trained only on the msa (modern standard arabic), arabicbert additionally used da during training, and camelbert-mix used a combination of all types of arabic text for training. multilingual models such as mbert and xlm are mostly trained on wikipedia and commoncrawl data which is predominantly msa @xcite . figure 1 summarizes the training data regimes of these models. this large variety of arabic pre-trained models motivates us to question how their representations encode various linguistic concepts? to this end, we present the first work on interpreting deep arabic models. we experiment with nine transformer models including: five arabic bert models, arabic albert, arabic electra, and two multilingual models (mbert and xlm). we analyze their representations using msa and dialectal partsof-speech tagging and dialect identification tasks. this allows us to compare the representations of arabic transformer models using tasks involving different varieties of arabic dialects. we analyze representations of the network at layer-level and at neuron-level using diagnostic classifier framework @xcite . the overall idea is to extract feature vectors from the learned representations and train probing classifiers towards understudied auxiliary tasks (of predicting morphology or identifying dialect). we additionally use the linguistic correlation analysis method @xcite to identify salient neurons with respect to a downstream task. our results show that: ## methodology our methodology is based on the class of interpretation methods called as the probing classifiers. the central idea is to extract the activation vectors from a pre-trained language model as static features. these activation vectors are then trained towards the task of predicting a property of interest, a linguistic task that we would like to probe the representation against. the underlying assumption is that if the classifier can predict the property, the representations implicitly encode this information. we train layer @xcite and neuron probes @xcite using logistic-regression classifiers. formally, consider a pre-trained neural language model m with l layers: {l 1 , l 2 , . . . , l l }. given a dataset @xmath0, w 2 , ..., w n } with a corresponding set of linguistic annotations @xmath1, t w 2 , ..., t w n }, we map each word w i in the data d to a sequence of latent representations: d m -→ @xmath2, . . . , z n }. the layer-wise probing classifier is trained by minimizing the following loss function: for neuron analysis, we use linguistic correlation analysis (lca) as described in @xcite . lca is also based on the probing classifier paradigm. however, they used elastic-net regularization @xcite that enables the selection of both focused and distributed neurons. the loss function is as follows: the regularization parameters λ 1 and λ 2 are tuned using a grid-search algorithm. the classifier assigns weight to each feature (neuron) which serves as their importance with respect to a class like noun. we ranked the neurons based on the absolute weights for every class. we select salient neurons for the task such as pos by iteratively selecting top neurons of every class. a minimum set of neurons is identified by iteratively selecting top neurons that achieves classification performance comparable (within a certain threshold) to the oracle -accuracy of the classifier trained using all the features in the network. ## experimental setup in this section, we describe our experimental setup including the arabic transformer models, probing tasks that we have used to carry the analysis and the classifier settings. ## analysis and discussion our goal is to carry out a comparative investigation of the knowledge encoded in different arabic transformer models. first we compare the representations in terms of how much linguistic information is preserved in the network using the overall accuracy on the understudied auxiliary tasks. then we analyze how such information is preserved across individual layers of the model. lastly, we analyze the distribution of neurons across the model with respect to these tasks. ## conclusion and future work in this paper we carry out a post-hoc analysis on a number of arabic transformer models using five linguistic tasks. our results enlighten interesting insights: i) neural networks learn non-trivial amount of linguistic knowledge with lower and middle layers capturing word morphology and higher layers learning more universal phenomenon, ii) we found that salient neurons are distributed across the network, but some layers contribute more salient neurons towards a task, iii) we found some neurons to be polysemous in nature while other capturing very specialized properties, iv) lastly we showed that msa-based models do not capture dialectal nuances despite having a large overlap with dialects. for future work, we aim to expand this analysis to include more tasks and explore related languages such as the families of semitic, germanic or latin languages.