Benchmarking Transformer-based Language Models for Arabic Sentiment and Sarcasm Detection
Paper · 2021 · Ibrahim Abu Farha and Walid Magdy
Summary
Several pretrained systems could read Arabic by the time Abu Farha and Magdy ran their study. Choosing among them was difficult because the systems had usually been evaluated on different tasks. A good result on question answering, for example, offered little guidance about whether a system could tell when a tweet was sarcastic. The authors bring the available systems together for a common test on ArSarcasm-v2. They study two kinds of text classification. One assigns a tweet positive, negative or neutral sentiment. The other decides whether the tweet is sarcastic. Both tasks use the same collection of tweets, but each has its own labels and scoring rule.
The results table compares 24 systems and variants, including a recurrent baseline, multilingual transformers and transformers pretrained specifically for Arabic. The authors use fine-tuning to adapt each pretrained system to the task at hand. MARBERT, whose pretraining corpus included a substantial share of tweets, earns 0.724 on the sentiment measure and 0.584 on F1 for the sarcastic class. AraBERT-large v2 ties it on sentiment. MARBERT has the highest sarcasm score. The multilingual systems generally finish below the strongest Arabic-specific alternatives. Within the AraBERT family, the large variants perform better than the corresponding base variants when the version and segmentation setting are held fixed.
The trial also shows why the score alone can be an incomplete guide to choosing a system. The AraELECTRA discriminator reaches 0.709 on sentiment and 0.578 on sarcasm, close to the larger AraBERT variants on the latter task. It takes 2:40 to fine-tune for a sarcasm epoch at batch size 4 on the authors’ machine. AraBERT-large v2 takes 5:57 under those conditions. At the slower end, AraGPT2-large takes 11:27 per epoch, and the authors run out of memory when they try to fine-tune AraGPT2-Mega.
The comparisons point to several properties that matter together. Arabic-only pretraining, exposure to social-media language and greater capacity can all accompany higher scores. The three completed AraGPT2 variants trail the leading BERT and ELECTRA systems, even though they use the same Arabic pretraining corpus as some stronger entries. That makes the way a system learns from its pretraining text a plausible part of the explanation. The evidence comes from two tasks on one tweet benchmark, where the systems differ in several properties at once.
Deep dive: Benchmarking Transformer-based Language Models for Arabic Sentiment and Sarcasm Detection
An Arabic Twitter benchmark compares how well pretrained transformers detect sentiment and sarcasm and how long they take to fine-tune. · about 31 minutes to read
The problem and its context
What a common test makes possible
The paper starts from a practical problem in Arabic natural language processing. Researchers had access to pretrained systems with a growing range of designs, but evidence about their relative merits was scattered. A release might include sentiment results, another might focus on question answering, and another might report only how well it predicted text during pretraining. Each result could serve the purpose of its own study. Together, they still left a researcher choosing a system for a new task with few direct comparisons.
A benchmark gives those comparisons a common point of reference. In this case, the authors ask how the systems perform when they learn from the same labeled tweets and are assessed on the same held-out tweets. They choose sentiment, which already had a substantial history in Arabic research, and sarcasm, which had received less attention. The tasks are related through the texts they examine. A tweet has a sentiment label and can also be judged sarcastic. The sentiment label describes its polarity, and the sarcasm label records a separate judgment. Having both on each tweet lets the authors compare the behavior of the same systems across the two tasks while keeping the collection of messages fixed.
This also gives the comparison a particular domain. A system may have learned largely from edited Arabic, from a mixture of formal writing and social-media posts, or from a multilingual collection in which Arabic is one of many languages. The benchmark asks what those different starting points offer when the target is Arabic as written on Twitter. The distinction between Modern Standard Arabic, abbreviated MSA, and dialectal Arabic matters here because the paper identifies differences in dialect coverage among the pretraining corpora. It also describes a history of sentiment research in which attention gradually expanded from MSA to dialectal language.
From word representations to reusable pretrained systems
The paper places this question in a transition from static to contextual representations. Earlier approaches such as Word2Vec, GloVe and fastText supplied word embeddings, numerical representations that a downstream system could use as input. In the paper’s account, their common limitation was that a word’s representation did not change with the surrounding words. Contextual approaches such as ELMo addressed that issue. The authors also identify ULMFiT as an earlier effort to make knowledge learned from language transferable across tasks.
BERT extended the use of pretraining through the transformer. The underlying idea is to learn representations from a large body of text first and adapt them to a labeled task later. The paper describes successful uses of BERT and related approaches in areas such as sentence completion, question answering and sentiment. It also shows how quickly the category diversified. RoBERTa revised the BERT recipe. ELECTRA changed the prediction problem used during pretraining. The GPT family learned by predicting text in sequence. T5 represented another line of development. Adopting transformers still left researchers with substantial choices about the language data and the training objective.
Much of this development began with English systems. Multilingual BERT, or mBERT, offered another route by pretraining on Wikipedia material across many languages. Work on French, Vietnamese, Finnish and Dutch illustrates the parallel interest in systems devoted to a single language. For Arabic, the paper identifies AraBERT as the first Arabic-specific transformer of this kind. Its release made it possible to start from a system built for Arabic rather than relying solely on a multilingual one. The later arrival of several Arabic alternatives turned that possibility into a selection problem in its own right.
The earlier evaluations also reflected the different aims of the releases. AraBERT was tested on sentiment, question answering and named entity recognition. AraELECTRA’s original evaluation centered on question answering. The AraGPT2 release used training perplexity, a measure of how well the system predicted the text, as its evidence. GigaBERT was designed partly to transfer from English to Arabic and had been tested on tasks including part-of-speech tagging and relation extraction. These choices established different kinds of usefulness. A paired test of sentiment and sarcasm could answer a question those release evaluations left open.
What Arabic sentiment and sarcasm research already offered
Early Arabic sentiment analysis concentrated on MSA. The paper describes subsequent work that introduced a sentiment lexicon that could be expanded, assembled a collection of tweets, and built datasets for evaluating sentiment systems. Research compared classifiers built from engineered features with neural systems using word embeddings. In the earlier comparative study described by the authors, neural systems with embeddings improved on classical approaches such as support vector machines, and fine-tuned AraBERT improved further across the benchmarks that study examined. Other work had already evaluated MARBERT on several Arabic sentiment collections. The new question was how such systems would rank against a wider set of contemporary alternatives under shared conditions.
Research on Arabic sarcasm and irony had a shorter history in the paper’s account. An early effort gathered tweets with political keywords and used the Arabic equivalent of a sarcasm hashtag to identify likely examples. This is a form of distant supervision: a signal that occurs in the text supplies a way to find or label examples. The study then explored cues including punctuation, emoticons, quotations and signs of opposition or changes in sentiment. Random Forest was the strongest classifier in that experiment. The work illustrates an earlier approach in which researchers specified candidate cues explicitly and compared classifiers that used them.
An Arabic irony shared task combined a related hashtag-based collection strategy with manual labeling for a sample of tweets. Its winning entry explored features such as n-grams, sentiment indicators and word embeddings, alongside several classifier types. DAICT added a corpus of ironic tweets. The original ArSarcasm collection took a different starting point by returning to tweets from earlier sentiment datasets and adding sarcasm judgments. That gave researchers a way to ask both questions about the same message, an arrangement the expanded ArSarcasm-v2 benchmark retained.
The earlier ArSarcasm results also illustrate how the scoring rule shapes a comparison. Its recurrent baseline was evaluated with F1 for the sarcastic class. A later evaluation of MARBERT on that collection reported macro F1, which averages across classes. The two measures give different weight to recognizing sarcastic examples, so the paper treats the published scores as answers to different questions. In the new benchmark, every system is evaluated with the shared task’s official measures. That choice makes the class being prioritized part of the common experimental setup.
The method, step by step
Start with tweets that carry both sets of labels
ArSarcasm-v2 extends the original ArSarcasm dataset and provides a new training and test split. To expand the collection, the dataset creators sampled additional tweets from Twitter. They also drew from DAICT to ensure that sarcastic material would be represented. The DAICT examples used in the extension went through a fresh round of annotation alongside the newly collected tweets. The purpose was to apply a common labeling process to the incoming examples. The creators used Appen to organize the annotation.
Each tweet has labels for sarcasm, sentiment and dialect. For the benchmark, the sentiment and sarcasm labels define the prediction tasks. The dialect labels characterize the resource. The paper uses dialect coverage in discussing pretraining and possible reasons for the observed results, while its main evaluation pools the tweets in each task. A sentiment classifier learns to distinguish positive, negative and neutral messages. A sarcasm classifier learns to distinguish sarcastic from non-sarcastic messages. A tweet can therefore appear in the training and evaluation of both tasks, with a different target attached for each.
The complete dataset contains 15,548 tweets. The benchmark uses 12,548 for training and 3,000 for testing. The training split provides examples from which to learn the task. The test split provides the reference labels used to score the resulting predictions. The separation between these splits is distinct from the separation between pretraining and fine-tuning. Pretraining has already taken place using a much broader text collection by the time a released transformer enters the benchmark. Fine-tuning is where the system learns the particular classification requested for these tweets.
From labeled Arabic tweets to benchmark scores
The steps in order.
Choose systems with different pretraining histories
The benchmark begins with several ways of sharing pretraining across languages. mBERT uses the BERT-base architecture and was pretrained on Wikipedia dumps for 104 languages. GigaBERT is bilingual, with an Arabic and English design aimed in part at cross-language transfer. The paper describes its earlier training collection as around 13M news articles from different sources. It also describes English augmentation and code-switched examples. These choices make GigaBERT a distinct comparison from mBERT. The XLM-R base and large variants add a multilingual RoBERTa family and allow the study to compare different sizes within that family.
The AraBERT variants offer several comparisons within Arabic-only pretraining. The earlier v0.1 and v1 releases used 23GB of text. The v0.2 and v2 releases used 77GB. The authors include base variants of both generations and large variants from the later one. Certain versions expect Farasa pre-segmentation. Farasa changes how the input is divided before it goes through the rest of the system’s text preparation. This matters because the comparison includes pairs built to read differently prepared text, even where their version generation and parameter count are the same.
The paper describes the earlier AraBERT recipe as applying Farasa to segment Arabic and then training a SentencePiece tokenizer with a vocabulary of 60K sub-word tokens. In subword tokenization, a unit passed to the system can be part of a word. Pre-segmentation and sub-word tokenization are distinct steps in the recipe. Farasa is the additional segmentation step for the variants that call for it. The authors follow the released AraBERT pipeline so that the comparison reflects the input preparation expected by each checkpoint.
Arabic BERT, as named in the paper, is a separate family from AraBERT. Its base and large variants were pretrained using 95GB drawn from the Arabic unshuffled OSCAR corpus and Arabic Wikipedia. Arabic ALBERT draws from those same named sources and supplies base, large and xlarge variants. The benchmark thus includes several ways of changing capacity within a mainly Arabic text setting. The parameter labels indicate differences in size within a family. They also make it possible to ask whether the score patterns that accompany a move from base to large are consistent across families.
ARBERT, MARBERT and QARiB broaden the comparison in the direction of pretraining content. The paper describes ARBERT’s material as mostly MSA. MARBERT was designed with greater dialect coverage in mind. Its recipe included a randomly sampled collection of 1B Arabic tweets, and the paper describes the final corpus as around 128GB, with 50% of it coming from tweets. QARiB also mixes styles and sources. The paper lists news, tweets and subtitles among its sources. These systems make it possible to compare the results of releases that have seen informal language with those of releases described mainly through sources such as news and Wikipedia.
Separate the text a system saw from the prediction it learned to make
A pretraining corpus supplies examples. The pretraining objective specifies what the system is asked to learn from those examples. The benchmark brings together different objectives, including cases where the paper reports the same source corpus. This is useful because a broad comparison of available systems would otherwise leave the amount and nature of the text entangled with the training procedure in every case.
A BERT-style masked language objective asks the system to recover tokens that have been hidden. Text on both sides of a hidden token can contribute to the prediction. The resulting representations are later adapted to a task such as assigning a label to a tweet. The label is learned during the downstream classification experiment. The masked-token task provides a starting representation of the input rather than supervision about sentiment or sarcasm itself.
ELECTRA instead trains a discriminator to detect which tokens have been replaced. A generator proposes replacements during pretraining, and the discriminator learns to distinguish those replacements from the original tokens. The discriminator is the component typically taken forward into downstream training. Abu Farha and Magdy evaluate both components as starting points for classification. That decision gives them an extra comparison within one pretraining system. It also lets a reader identify precisely which component the paper has in mind when it describes AraELECTRA as a strong and efficient option.
AraGPT2 uses a causal language objective. It learns to predict what follows from the text available up to that point, a setup suited to text generation. The authors take its stacked transformer decoder and adapt it to sequence classification. Base, medium and large variants yield scores. The attempted run with the mega variant encounters a memory limit. The later AraBERT versions, AraELECTRA and AraGPT2 share the 77GB Arabic corpus identified in the paper. They still differ in architecture and training procedure, so the common corpus gives the comparison a firmer reference point without making the released systems identical in other respects.
Adapt the pretrained systems to the two tasks
The authors use Hugging Face’s Transformers library. Its AutoModelForSequenceClassification interface selects the sequence-classification implementation appropriate to the checkpoint. A fully connected layer sits above the pretrained system and turns the representation of the input into scores for the available classes. Training with the sentiment labels gives this layer and the pretrained system practice at distinguishing the sentiment categories. A separate fine-tuning run uses the sarcasm labels to learn the other prediction problem.
The paper reports 5 epochs of training, a learning rate of 5e−6 and a maximum sequence length of 128 tokens for the transformers. An epoch is a pass through the training examples, and the learning rate controls the scale of adjustments made during training. The sequence limit concerns the units recognized by the tokenizer. The same maximum number of tokens can cover different amounts of original text when the input is segmented differently. The benchmark applies the common sequence setting while preserving the expected AraBERT preprocessing where applicable.
The authors also train a recurrent baseline, the BiLSTM, with Mazajak word embeddings. A bidirectional long short-term memory system processes the sequence in both directions. Its inputs and architecture provide a point of comparison from outside the transformer families. The baseline uses 128 hidden units, a rectified linear unit activation, and Adam with a learning rate of 0.0001. Its configuration is separate from the common transformer settings. The purpose of including it is to compare the newer systems with an established kind of classifier on the same benchmark.
Score the classes the shared task prioritizes
The official sarcasm measure is F1 for the sarcastic class. Precision for that class asks how frequently a prediction of sarcasm agrees with the annotation. Recall asks how much of the annotated sarcasm the classifier identifies. F1 combines the two through their harmonic mean. In notation, that definition is:
F1꜀ = 2 × P꜀ × R꜀ ÷ (P꜀ + R꜀)
Here c denotes the class, P꜀ is precision for that class, and R꜀ is its recall. F1꜀ is the resulting class-specific score. The factor 2 is part of the harmonic-mean definition. Multiplication forms the product in the numerator, the plus sign adds precision and recall in the denominator, and division gives the score. For the sarcasm headline measure, c is the sarcastic class.
For sentiment, the paper defines its primary measure as the average of the positive-class F1 and the negative-class F1. In notation, the definition is:
F PN = (F1ₚ + F1ₙ) ÷ 2
F PN denotes the sentiment measure used for ranking. F1ₚ is F1 for positive tweets and F1ₙ is F1 for negative tweets. The plus sign combines the two scores and division by 2 gives each the same weight. Neutral remains a possible prediction. Errors involving neutral can affect the measure when they change the precision or recall of a scored class. For instance, assigning a positive label to a neutral tweet adds an incorrect positive prediction. The definition omits a separate neutral-class F1 term.
The paper also reports sentiment accuracy and recall, and precision and recall columns for sarcasm. Its headline comparisons use the shared-task measures. That distinction matters when reading the tables. A change in overall sentiment accuracy can accompany a tie in F PN, because the former counts correct predictions across the task while the latter gives equal weight to the two specified class scores. On sarcasm, the most direct evidence for the task’s priority comes from the column explicitly labeled as F1 for the sarcastic class.
Experiments and results
The test set and the comparisons it supports
All the headline scores come from ArSarcasm-v2’s held-out test split. The distribution of sarcasm labels is uneven. Training includes 2,168 sarcastic tweets and 10,380 non-sarcastic tweets. Testing includes 821 sarcastic tweets and 2,179 non-sarcastic tweets. That distribution helps explain the importance of the chosen metric. A system can get many individual decisions right by recognizing the more common non-sarcastic class, but a high sarcastic-class F1 also requires finding sarcastic examples and avoiding incorrect sarcasm predictions.
Sentiment has its own imbalance. The test split includes 575 positive tweets, 1,677 negative tweets and 748 neutral tweets, according to the split entries in the paper’s dataset table. An overall accuracy score puts each tweet on the same footing, making the distribution of labels relevant to how much each class contributes. The official sentiment measure instead averages two class scores with equal weight. This gives the less frequent positive class the same direct influence on the headline measure as the negative class. The paper’s inclusion of both F PN and accuracy lets a reader see how the ranking depends on which property is being measured.
The results table puts the recurrent classifier alongside the pretrained systems. It also supplies useful reference points within the transformer group. mBERT represents a broadly multilingual starting point. The two XLM-R sizes let a multilingual family compete at different capacities. The Arabic-only group includes formal-corpus and mixed-corpus checkpoints, as well as different architectures and objectives. Each entry is a complete recipe as evaluated in the paper. A difference between unrelated rows can therefore reflect several properties of the systems together.
Sentiment has a shared lead
MARBERT and AraBERT-large v2 share the highest reported sentiment F PN, at 0.724. Their other sentiment measures differ. MARBERT has reported recall of 0.664 and accuracy of 0.693. AraBERT-large v2 has recall of 0.660 and accuracy of 0.700. The tie therefore pertains specifically to the official measure of positive and negative sentiment. The table gives AraBERT-large v2 the higher overall accuracy of the pair and MARBERT the higher value in the recall column.
QARiB follows the leaders with 0.720 F PN in the main results table. AraBERT-large v0.2 follows with 0.718. The AraELECTRA discriminator reaches 0.709, which also appears for AraBERT-base v0.2. AraBERT-base v2 scores 0.711. These scores place several Arabic-specific choices close together on the official sentiment measure, even though their pretraining histories and their computational requirements differ.
Selected systems on ArSarcasm-v2 test sentiment F PN
MARBERT and AraBERT-large v2 share the lead, with QARiB close behind.
The numbers
| System or setting | F PN |
|---|---|
| mBERT | 0.625 |
| BiLSTM | 0.691 |
| XLM-R-large | 0.699 |
| AraELECTRA discriminator | 0.709 |
| AraBERT-large v0.2 | 0.718 |
| QARiB | 0.720 |
| AraBERT-large v2 (this paper) | 0.724 |
| MARBERT | 0.724 |
The BiLSTM baseline scores 0.691 on sentiment. It ties both AraBERT-base v0.1 and Arabic ALBERT-xlarge on this measure. That is an important part of the sentiment result. The most successful transformers improve on the baseline, but the baseline is competitive with several released variants on this particular test. Gains come from choosing an effective starting point and configuration, rather than from the transformer label alone.
Among the multilingual systems, XLM-R-large scores 0.699 on sentiment, ahead of GigaBERT at 0.673 and XLM-R-base at 0.661. mBERT has the lowest reported sentiment F PN, at 0.625. XLM-R-large matches the score of Arabic BERT-large and exceeds that of Arabic BERT-base, which is 0.687. Its showing is consistent with the authors’ observation that a larger multilingual system can reach results found among Arabic-only systems. The strongest results in this experiment still come from the Arabic-specific group.
The AraGPT2 scores show a different pattern across sizes. Base reaches 0.662 on sentiment and medium reaches 0.666. Large falls to 0.629. The large variant therefore approaches the bottom of the table on F PN in spite of its size. These results fit alongside the stronger Arabic-only encoders as evidence that Arabic pretraining by itself accounts for only part of the ranking. The AraGPT2 family has Arabic pretraining and access to a substantial corpus. Its performance on the benchmark still depends on what its architecture and training procedure make available for classification.
Sarcasm separates systems that look similar on sentiment
MARBERT has the highest F1 for the sarcastic class, at 0.584. AraBERT-large v0.2 follows at 0.579. The AraELECTRA discriminator and ARBERT each reach 0.578. AraBERT-large v2, which shares the lead on sentiment, scores 0.575 on sarcasm. The leading group therefore looks somewhat different when the goal is finding sarcastic tweets. In particular, the two large AraBERT variants exchange positions between the two headline measures.
Selected systems on ArSarcasm-v2 test sarcastic-class F1
MARBERT leads a closely spaced group of Arabic-specific systems.
The numbers
| System or setting | F1-sarcastic |
|---|---|
| mBERT | 0.425 |
| BiLSTM | 0.483 |
| AraGPT2-medium | 0.522 |
| XLM-R-large | 0.551 |
| AraBERT-large v2 | 0.575 |
| ARBERT | 0.578 |
| AraELECTRA discriminator | 0.578 |
| AraBERT-large v0.2 | 0.579 |
| MARBERT (this paper) | 0.584 |
The recurrent baseline records 0.483 for sarcastic-class F1. mBERT scores 0.425, while GigaBERT reaches 0.527. The two XLM-R variants score 0.518 for base and 0.551 for large. Here the leading Arabic-only systems improve substantially on the recurrent baseline in the authors’ comparison. This is the basis for their observation that the gains from choosing a strong Arabic-specific transformer stand out particularly on sarcasm. Sentiment and sarcasm use different measures, so the informative comparisons are against the baseline within each task.
QARiB illustrates the distinction between the tasks particularly well. Its sentiment score puts it close to the leaders, but its sarcastic-class F1 is 0.551, equal to XLM-R-large. ARBERT at 0.578 is close to the sarcasm lead while scoring 0.695 on sentiment. A system’s rank on one task therefore gives only partial guidance about its rank on the other, even when the input consists of the same tweets. The units that matter for the prediction and the errors favored by the metric can differ with the label being learned.
The AraGPT2 variants are tightly grouped on sarcasm. Base and medium report 0.522, and large reports 0.521. The family sits below the leading encoders while exceeding the BiLSTM and mBERT scores on this measure. That distinction matters for interpreting the paper’s conclusion about causal pretraining. The results place AraGPT2 behind the strongest choices for these classification tasks. The individual entries still outperform some alternatives, and there is little change in the sarcasm score as the tested AraGPT2 variants get larger.
The sarcasm results table also presents columns labeled precision and recall. For instance, it lists 0.714 in both columns for MARBERT while giving 0.584 in the explicitly sarcastic-class F1 column. Those entries should be read as the table labels present them. The paper identifies the class scope of the headline F1, but the precision and recall headers do not explain their averaging scope. The headline F1 therefore supplies the clearest basis for comparing performance specifically on sarcastic tweets.
The time measurements change the choice among strong systems
The authors time one epoch of sarcasm fine-tuning on their experimental server at a batch size of 4. A batch is the group of examples processed together in a training step. The server has a 32 core CPU, 512GB of RAM and a Quadro RTX 6000 with 24GB of GPU memory. Fixing the task, batch size and machine makes the timings comparable within the study. Each duration describes a pass through downstream training, after the original pretraining has already been completed.
At the fast end, Arabic ALBERT-base takes 1:56 per epoch. It scores 0.663 on sentiment and 0.555 on sarcasm. MARBERT takes 2:47 and provides the leading joint result across the two tasks. ARBERT takes 2:55 and finishes close to MARBERT on sarcastic-class F1. These comparisons show why the fastest run and the strongest score are different answers to the system-selection question. They also show that reaching the leading group does not invariably require one of the longest runs.
The AraELECTRA discriminator offers the paper’s clearest example of competitive scores with a shorter run. The paper’s system comparison lists it at 135M parameters, with a time of 2:40 per epoch. The two large AraBERT variants are listed at 371M parameters. AraBERT-large v0.2 takes 5:51 and earns 0.579 on sarcasm. AraBERT-large v2 takes 5:57 and earns 0.575. The discriminator’s 0.578 falls between them on the timed task. The large AraBERT variants have stronger headline sentiment scores, so the attraction of the faster choice depends on which task and metric have priority.
AraGPT2-large is the slowest of the systems for which the paper reports a completed timing. With 792M parameters, it takes 11:27 per sarcasm epoch. AraGPT2-medium takes 5:55, and base takes 2:34. The longer runs in that family bring little change in sarcastic-class F1, and the large variant has the weakest sentiment score of the family. AraGPT2-Mega has no corresponding timing or test result because the authors could not complete fine-tuning within the machine’s memory. The comparison therefore records both a cost for the completed runs and a feasibility limit for the attempted larger run.
What the ablations show
Size helps when the comparison stays within AraBERT
The study offers comparisons among released checkpoints rather than a separate set of ablations created by retraining a system with individual design choices removed. The paired variants nonetheless help narrow the interpretation. Some hold the named corpus and segmentation setting fixed while changing size. Others compare releases with shared pretraining data but different objectives. The amount that can be learned from each pair depends on what the two releases have in common.
AraBERT v0.2 supplies one of the closest size comparisons. Its base version scores 0.709 on sentiment and 0.556 on sarcasm. Its large version scores 0.718 and 0.579, respectively. The comparison within v2 points in the same direction. The base scores of 0.711 on sentiment and 0.525 on sarcasm rise to 0.724 and 0.575 with the large variant. The direction is consistent within each segmentation setting. This supports the authors’ observation that larger variants tend to perform better when the training data are comparable.
The pattern extends to the base and large variants of XLM-R and of Arabic BERT, where the larger entry has a higher headline score on each task. Arabic ALBERT gives a more qualified picture. Its xlarge variant has the strongest sentiment result in that family, at 0.691. The base variant has the family’s strongest sarcasm result, at 0.555, while the large and xlarge variants score 0.523 and 0.530. AraGPT2’s size comparisons also depart from the simple pattern. Within the benchmark, the benefits of added capacity are clearest in some families and for some tasks.
Segmentation and corpus changes show up differently across tasks
The AraBERT version pairs let the reader follow Farasa pre-segmentation while staying within the same version generation and capacity. In the later base variants, the segmented v2 has a sentiment F PN of 0.711, compared with 0.709 for v0.2. On sarcasm, v2 scores 0.525 and v0.2 scores 0.556. The large pair gives the same direction on each task. The segmented v2 is ahead on sentiment, and v0.2 is ahead on sarcastic-class F1. The early base pair also follows that direction, with v1 improving on v0.1 for sentiment and v0.1 ahead for sarcasm.
These are comparisons of checkpoints designed for their respective preprocessing pipelines. They do not measure the effect of turning a preprocessing switch on and off after keeping the pretrained checkpoint fixed. Their value is to show that the gains associated with one released segmentation setting depend on what the classifier is asked to do. The repeated ordering within the AraBERT pairs gives more direct evidence about those releases than a comparison between unrelated systems with different tokenizers and corpora.
Moving from the early AraBERT base releases to the later ones likewise provides a qualified view of more pretraining data. The later generation uses 77GB compared with 23GB for the earlier one. Sentiment improves in the comparisons within each segmentation setting. On sarcasm, the later v0.2 and v2 score below their corresponding earlier base versions. These release comparisons involve a changed pretraining collection and belong to different generations. They show why the amount of text is an incomplete description of what changed and why a larger corpus need not produce the same direction of movement on both tasks.
The authors also suggest that cleaning choices could contribute to the difference they observe between AraBERT and Arabic BERT. They describe AraBERT’s preprocessing as removing non-Arabic words and note that the Arabic BERT training text includes some such material inline. This is an explanation proposed from the differences between the recipes. A direct test would need to separate that cleaning choice from the other corpus and preparation differences between the releases. The benchmark establishes the relative scores of the complete recipes.
Shared data make the objective comparisons more informative
AraBERT’s later releases, AraELECTRA and AraGPT2 use the same reported 77GB corpus. Against that common data source, the AraELECTRA discriminator performs close to large AraBERT on sarcasm, while the AraGPT2 variants score lower. The comparison makes it harder to explain the ranking solely through which raw corpus was available. It brings the objective and architecture into focus. The prediction exercises are different: reconstructing hidden tokens, recognizing replacements, or predicting the next token. In the paper’s interpretation, the representations learned by the first two kinds of system are better starting points for the classifications examined here.
The generator and discriminator results sharpen that observation within AraELECTRA. The generator reports 0.663 on sentiment and 0.527 on sarcasm. The discriminator reaches 0.709 and 0.578. Choosing which component to fine-tune makes a visible difference on both tasks. Their different parameter counts and roles during pretraining limit attribution to a single factor. The reported timings also give an instructive detail: the smaller generator takes 2:51 per epoch, while the larger discriminator takes 2:40. Parameter count is helpful as a broad indicator of cost, and the comparison shows why measurements remain valuable when the components themselves differ.
Pretraining on tweets fits the benchmark, with different results by task
MARBERT and QARiB show that a training mixture with social-media text can yield strong scores on Twitter sentiment. MARBERT also leads sarcasm. This is consistent with the argument that prior exposure to informal writing and dialect helps when the downstream material contains both. QARiB’s sarcasm result and ARBERT’s strong position on that task qualify the explanation. A tweet-inclusive corpus can be part of a successful recipe, while its presence alone gives limited information about the final ranking.
The language-coverage comparison has a similar structure. The leading Arabic-only systems outperform the multilingual entries, and the larger XLM-R variant improves on the smaller one. Some Arabic-only entries fall below XLM-R-large. Across the full comparison, specialization is associated with the strongest results, while capacity and other design choices affect where any individual system finishes. This is useful evidence for choosing among the tested releases. It leaves a more specific causal question open: how much of the gain would remain if an otherwise identical system were pretrained with a different allocation of languages?
Limitations
The authors’ stated boundaries
The authors describe the work as a starting point for a broader Arabic benchmark. They identify other classification tasks, generation and information extraction as areas for future evaluation. This matters especially for the interpretation of AraGPT2. The authors associate its causal objective with uses such as sentence completion and generation, while their own experiment attaches a classifier and evaluates labels on Arabic tweets. Its weaker position is evidence about the chosen downstream use. Generation quality remains a separate empirical question.
The paper also documents a hardware boundary. AraGPT2-Mega exceeded the available memory when the authors attempted fine-tuning. Accordingly, its absence from the score table supplies information about feasibility in this setup. Its performance on sentiment and sarcasm remains unmeasured. The conclusion that larger systems can demand more resources rests on the completed runs and this observed memory failure, with any specific time or memory comparison tied to the experimental procedure.
The authors present the findings about language coverage and social-media text in the context of the resources they tested. Their proposal to extend the benchmark recognizes that selecting an Arabic system depends on what it will do. ArSarcasm-v2 puts informal language at the center of the experiment. Other target tasks could place different demands on the vocabulary, the pretraining objective, or the kind of knowledge a useful representation must preserve.
Boundaries visible in the design
Both downstream tasks come from one collection and one train/test split. This strengthens the comparison of systems on those tweets while leaving generalization to other collections open. The data extension combines random Twitter sampling with material drawn from a corpus rich in sarcasm. That procedure provides examples of the phenomenon the authors need to test. It also means that performance on the benchmark describes the resulting mixture. The relative frequency of sarcasm in a different stream of tweets could affect the practical behavior of a classifier applied there.
Dialect annotations offer the possibility of looking at performance within language varieties. The paper reports aggregate scores for the two tasks. It does not present per-dialect results that would locate which varieties account for MARBERT’s advantage, or a comparison that separates familiarity with dialect from familiarity with Twitter as a source. The interpretation about dialectal pretraining is grounded in what the paper reports about the corpora and the target texts. The scope of the measurement is still the pooled test set.
The corpus descriptions also vary in how much detail they provide. The paper gives 61GB for ARBERT in its discussion of earlier work and in its system comparison table, while the experimental setup gives 66GB. Its descriptions of the sources are also uneven, with the setup emphasizing news and the comparison table listing a wider range. These differences leave the exact ARBERT corpus size and composition uncertain within the paper. The score comparison can still be read as a comparison of the named release. An explanation that depends on a precise count of its pretraining text has less secure footing.
Shared downstream settings are convenient for a broad benchmark. The reported scores describe the systems under that recipe, and the paper gives no distribution of scores across repeated training runs. Consequently, close values among the strongest sarcasm entries can establish their reported ordering without establishing how stable that ordering would be across repeats. The same applies to fine-tuning choices. A common learning rate and training length make the experiment easier to compare, while leaving open whether separate tuning for each family would change some positions.
The primary metrics also define what counts as an improvement. Sentiment F PN gives separate, equal weight to positive and negative F1. It leaves neutral performance visible only through its effects on those classes and through the other reported measures. Sarcastic-class F1 emphasizes the class of interest in a dataset with many more non-sarcastic than sarcastic examples. Neither headline score by itself gives a full account of which kinds of tweets are being confused. Detailed error examples and consistently identified per-class measures would be needed to diagnose those confusions.
Finally, the cost experiment measures a training epoch on one task and one machine at the stated batch size. It addresses the cost of adapting the released systems in those conditions. It leaves original pretraining expenditure, prediction latency and behavior on different hardware open. The broad increase in time for larger variants is visible in several families, but individual comparisons such as the two AraELECTRA components show that architecture and training behavior can complicate the relationship. The useful result is the recorded combination of elapsed time and classification score for each completed run.
What came after
Arabic evaluation broadened beyond tweet classification
AraT5 addressed Arabic language generation using a text-to-text transformer, putting generated text at the center of the task. Its scope follows a direction the benchmark authors explicitly identified for further work. The benchmark’s AraGPT2 results describe adaptation to sentiment and sarcasm labels. AraT5 takes up the complementary question of building a transformer for Arabic tasks where the output is text. AraT5
GPTAraEval took a broader evaluation question to ChatGPT in Arabic NLP. The connection is the value of looking across Arabic tasks when judging a system’s usefulness. The earlier benchmark examines many pretrained checkpoints under the same supervised classification procedure. The later work’s stated scope is a comprehensive evaluation of a particular system across Arabic NLP. The description establishes that change of emphasis while leaving specific task outcomes and experimental overlap open. GPTAraEval
TARJAMAT evaluates Bard and ChatGPT on machine translation across ten Arabic varieties. The earlier study treats dialect exposure as a possible contributor to performance and reports pooled scores on Arabic tweets. TARJAMAT puts variety directly into the definition of its translation evaluation. That moves the role of dialect from an explanation about the training data to an explicit dimension of the task being assessed. TARJAMAT
NADI 2022 takes up dialect in a different way through a shared task on nuanced Arabic dialect identification. On ArSarcasm-v2, dialect is a recorded property of the examples and sentiment or sarcasm is the output the system predicts. In dialect identification, identifying the variety is itself the objective. The connection between the studies is the need for evaluation that accounts for variation within Arabic, with the later shared task assigning that variation a different experimental role. NADI 2022
Sarcasm work expanded the comparison and the available evidence
The human and machine comparison in Sarcasm Detection is Way Too Easy! revisits what a sarcasm score can establish by including human performance in the empirical question. Abu Farha and Magdy’s benchmark gives a relative ordering among systems under a particular evaluation. Bringing people into the comparison changes the reference point for interpreting how difficult the task is. The later work’s stated scope supports that connection without equating its human and machine evaluations with the exact setup of the earlier benchmark. Sarcasm Detection is Way Too Easy!
Sarcasm in Sight and Sound takes the benchmarking problem into multimodal sarcasm detection. ArSarcasm-v2 supplies text to a sequence classifier. The later work addresses a setting in which sight and sound enter the task and pairs benchmarking with expansion of the resources used to study it. The change concerns what evidence is available to the detector as well as the comparative evaluation of detectors. Sarcasm in Sight and Sound
The S3D work addresses the supply of annotated sarcasm examples through weak supervision. The earlier benchmark depends on a dataset whose expansion combined targeted collection with a common annotation process. S3D takes dataset construction as its subject and uses weak supervision to produce a sarcasm-annotated resource. The two studies are connected by a practical dependency of sarcasm evaluation: comparisons can only measure behavior on the examples and labels the dataset makes available. S3D
GetSmartMSEC addresses sarcasm in the context of a SemEval task, using contextual word embeddings and a Gaussian approach to irony-type identification. Its task description introduces a finer question about the type of irony. The earlier benchmark uses a binary sarcasm decision for its headline score. A type identification task changes the distinctions the system must learn and gives the evaluation a different way to ask what information a contextual representation preserves. GetSmartMSEC
Efficiency and task fit remained subjects of Arabic benchmarks
ArabicTransformer returns to the relationship between efficiency and training objective through a Funnel Transformer and ELECTRA objective. Abu Farha and Magdy observed that the AraELECTRA discriminator could approach the scores of larger AraBERT variants at a shorter fine-tuning time. ArabicTransformer takes efficiency as a design aim and combines an ELECTRA objective with a different transformer architecture. The connection lies in examining what a system’s training procedure and architecture can deliver under computational constraints. ArabicTransformer
The intent detection study from AraFinNLP benchmarks Arabic BERT variants on a new classification task. It carries the head-to-head evaluation question into a setting where the labels concern intent. The sentiment and sarcasm results supply a reason for doing that comparison anew. Even under a common input domain, the preferred variant changed with the label and measure. Intent detection provides a different test of task fit for the Arabic BERT family. SMASH at AraFinNLP2024
Other citing works extend the range of Arabic classification problems and adaptation methods. The stance study from StanceEval uses prompt engineering for Arabic stance detection, placing the formulation of the request at the center of adaptation. CHILLAX combines machine learning and transformers for offensive-language and hate-speech detection. The MarsadLab shared-task entry uses specialized AraBERT variants for readability prediction. Each defines a different target label and a corresponding setting in which to evaluate an Arabic system. SMASH at StanceEval 2024 · CHILLAX · MarsadLab at BAREC
Arabic punctuation prediction supplies another evaluation target, centered on where punctuation belongs. The Qur’an question-answering work addresses the construction of faithful data splits for a low-resource setting. One foregrounds what a trained system should predict, and the other foregrounds how examples should be divided to support a meaningful evaluation. Those concerns connect to separate choices in the earlier benchmark, where shared-task labels specify the prediction target and a common split makes the scores directly comparable. Arabic Punctuation Prediction · SMASH at Qur’an QA
Whose Pragmatics? returns to Arabic social media through stereotype detection in Egyptian Arabic and frames cultural grounding as a bottleneck. The earlier benchmark asks whether systems exposed to dialect and tweets are better starting points for sentiment and sarcasm. The later work names a more specific variety and a different kind of social judgment, bringing cultural grounding into the evaluation question. The connection is the importance of specifying which language, context and judgment a system must handle before interpreting a score as evidence of broader Arabic competence. Whose Pragmatics?
Fields, topics and concepts
Shelves 4The field of science this work belongs to (OpenAlex fields).Computer Science · 19,503 worksArtificial Intelligence · 18,805 worksArts and Humanities · 17,959 worksLanguage and Linguistics · 17,789 works
Topics 3Research subjects and languages the work is about.Sentiment & emotion · 1,037 worksSemitic languages · 3,068 worksMultilingual & cross-lingual NLP · 888 works
Cite
Cite as Ibrahim Abu Farha and Walid Magdy. 2021. Benchmarking Transformer-based Language Models for Arabic Sentiment and Sarcasm Detection. Proceedings of the Sixth Arabic Natural Language Processing Workshop.
@inproceedings{farha2021benchmarking,
title = {{Benchmarking Transformer-based Language Models for Arabic Sentiment and Sarcasm Detection}},
author = {Ibrahim Abu Farha and Walid Magdy},
booktitle = {Proceedings of the Sixth Arabic Natural Language Processing Workshop},
year = {2021},
url = {https://aclanthology.org/2021.wanlp-1.3/}
}References
- Ahmed Abbasi, Hsinchun Chen, and Arab Salem. 2008. Sentiment analysis in multiple languages: Feature selection for opinion classification in web forums. ACM Transactions on Information Systems (TOIS), 26(3):1–34. OpenAlex ↗ · Scholar ↗
This page in Markdown https://md.research.elamur.ai/free/en/papers/farha-2021-benchmarking-transformer-based-language-models/