Interpreting Arabic Transformer Models

Ahmed Abdelali, Nadir Durrani, Fahim Dalvi, Hassan SajjadarXiv 2022

TL;DR

This paper probes the internal workings of Arabic transformer models, revealing how they encode linguistic information like morphology and dialect. They found that while models trained on Modern Standard Arabic (MSA) capture morphology well, they struggle with dialectal nuances, highlighting the need for dialect-specific training data.

What Problem Does This Paper Address?

Pre-trained language models (PLMs) have revolutionized Natural Language Processing (NLP), with many transformer models now available for Arabic. While these models are often evaluated on downstream tasks, there's a significant gap in understanding how they internally represent linguistic knowledge, especially considering Arabic's rich morphology and diverse dialects. This paper aims to bridge this gap by directly comparing the internal representations of various Arabic PLMs, investigating what linguistic information they learn and where in the network it's stored.

Methods

The authors employ a "probing classifier" framework to analyze the internal representations of PLMs. This involves:

  • Extracting Activation Vectors: They take the output (activation vectors) from specific layers of the pre-trained models.
  • Training Probing Classifiers: These activation vectors are then used as features to train simple classifiers (logistic regression) on auxiliary linguistic tasks.
  • Layer-wise Analysis: They train separate classifiers for each layer of the PLM to understand how linguistic knowledge evolves across the network.
  • Neuron-wise Analysis (Linguistic Correlation Analysis - LCA): This technique identifies individual "salient" neurons responsible for specific linguistic properties. They use elastic-net regularization to select important neurons and then identify a minimal set that achieves near-oracle performance.

Datasets

The study utilizes the following datasets for evaluation:

  • Arabic Treebank (ATB): Used for Modern Standard Arabic (MSA) Part-of-Speech (POS) tagging.
  • POS Multidialects (DIA): A dataset of tweets from four Arabic dialects (Egyptian, Levantine, Gulf, Maghrebi) for dialectal POS tagging.
  • Dialect Identification (DID): A dataset of intrasentential code-switched sentences between MSA and Egyptian Arabic for dialect identification.

The paper also implicitly refers to the large corpora used to pre-train the models, including Arabic Wikipedia, Common Crawl, and various Arabic news and tweet datasets.

Key Insights and Ideas

  • Morphology in Lower Layers, Dialect in Higher Layers: Word morphology is primarily learned in the lower and middle layers of the transformer models. In contrast, understanding dialectal nuances requires more complex knowledge, which is preserved even in the final layers.
  • MSA Models Miss Dialectal Nuances: Despite significant vocabulary overlap between Modern Standard Arabic (MSA) and its dialects, models trained only on MSA struggle to capture dialectal specificities. This strongly suggests the need for dialect-aware pre-training data.
  • Polysemous vs. Specialized Neurons: Neurons in the embedding layers tend to be "polysemous" (handling multiple meanings/properties), while neurons in the middle layers become more specialized for specific linguistic features.
  • Salient Neurons are Distributed but Layer-Dependent: While important neurons (salient neurons) for a given task are distributed across the network, certain layers contribute more significantly than others. The embedding and final layers often contribute a substantial amount of salient neurons.
  • Efficiency in Representation: A surprisingly small subset of neurons (as low as 5-10%) can achieve performance comparable to using the entire network's representations, suggesting redundancy and potential for more efficient models.

Key Results

  • CAMELBERT-Mix Outperforms: The CAMELBERT-mix model, trained on a combination of MSA, Classical Arabic, and Dialectal Arabic, consistently performed well across all tasks, especially the dialect-related ones.
  • MSA-only Models Lag on Dialect Tasks: Models trained solely on MSA (like mBERT) showed significantly poorer performance on dialect identification and dialectal POS tagging compared to models that included dialectal data in their training.
  • Layer-wise Performance: For morphology tasks (ATB), middle layers generally yielded the best performance. For dialect identification (DID), the task requires non-local dependencies, leading to lower performance in the embedding layer compared to contextualized layers.
  • Neuron Efficiency: The study found that for ATB, DIA, and DID tasks, only 5%, 10%, and 7% of neurons, respectively, were sufficient to achieve performance close to the "oracle" (using all features).

Limitations and Future Work

  • Limitations: The paper acknowledges that the analysis is limited to three specific probing tasks. The performance of ALBERT is noted as an outlier, with its embedding layer contributing less to top neurons, which warrants further investigation into its word embedding capabilities.
  • Future Work: The authors propose expanding this analysis to include more linguistic tasks and a wider range of languages, particularly focusing on groups of related languages (e.g., Semitic, Germanic, Latin families). This would allow for a more comprehensive understanding of how PLMs generalize and transfer knowledge across linguistic structures.

Summary updated

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 these models have been compared with respect to downstream NLP tasks, no evaluation has been carried out to directly compare the internal representations. We probe how linguistic information is encoded in Arabic pretrained models, trained on different varieties of Arabic language. We perform a layer and neuron analysis on the models using three intrinsic tasks: two morphological tagging tasks based on MSA (modern standard Arabic) and dialectal POS-tagging and a dialectal identification task. Our analysis enlightens interesting findings such as: i) word morphology is learned at the lower and middle layers ii) dialectal identification necessitate more knowledge and hence preserved even in the final 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.
BibTeX
@misc{abdelali2022interpreting,
  author = {Ahmed Abdelali and Nadir Durrani and Fahim Dalvi and Hassan Sajjad},
  title = {{Interpreting Arabic Transformer Models}},
  year = {2022},
  eprint = {2201.07434},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2201.07434},
}
Figure