Hostname: page-component-6766d58669-tq7bh Total loading time: 0 Render date: 2026-05-23T19:02:00.880Z Has data issue: false hasContentIssue false

Towards a robust deep learning framework for Arabic sentiment analysis

Published online by Cambridge University Press:  06 September 2024

Azzam Radman
Affiliation:
Computer Information Systems, Jordan University of Science and Technology, Irbid, Jordan
Rehab Duwairi*
Affiliation:
Computer Information Systems, Jordan University of Science and Technology, Irbid, Jordan
*
Corresponding author: Rehab Duwairi; Email: rehab@just.edu.jo
Rights & Permissions [Opens in a new window]

Abstract

In spite of the superior performance deep neural networks have proven in thousands of applications in the past few years, addressing the over-sensitivity of these models to noise and/or intentional slight perturbations is still an active area of research. In the computer vision domain, perturbations can be directly applied to the input images. The task in the natural language processing domain is quite harder due to the discrete nature of natural languages. There has been a considerable amount of effort put to address this problem in high-resource languages like English. However, there is still an apparent lack of such studies in the Arabic language, and we aim to be the first to conduct such a study in this work. In this study, we start by training seven different models on a sentiment analysis task. Then, we propose a method to attack our models by means of the worst synonym replacement where the synonyms are automatically selected via the gradients of the input representations. After proving the effectiveness of the proposed adversarial attack, we aim to design a framework that enables the development of models robust to attacks. Three different frameworks are proposed in this work and a thorough comparison between the performance of these frameworks is presented. The three scenarios revolve around training the proposed models either on adversarial samples only or also including clean samples beside the adversarial ones, and whether or not to include weight perturbation during training.

Information

Type
Article
Creative Commons
Creative Common License - CCCreative Common License - BY
This is an Open Access article, distributed under the terms of the Creative Commons Attribution licence (http://creativecommons.org/licenses/by/4.0/), which permits unrestricted re-use, distribution and reproduction, provided the original article is properly cited.
Copyright
© The Author(s), 2024. Published by Cambridge University Press
Figure 0

Figure 1. Long and short sequence percentages in the training (left) and test (right) datasets.

Figure 1

Figure 2. Model Architectures. Left is the architecture of the LSTM-based, GRU-based, and CNN-based models, and right is the architecture of the MHA-based model. For the LSTM-CNN-based, GRU-CNN-based, and MHA-CNN-based architectures, an additional 1d CNN layer is added in between the AraVec embeddings and the next layer.

Figure 2

Table 1. Examples of clean and adversarial samples for the LSTM-based model after applying standard training

Figure 3

Algorithm 1. Adversarial attack.

Figure 4

Algorithm 2. Perturb inputs only (scenario 1).

Figure 5

Algorithm 3. Perturb both inputs and weights (scenario 2).

Figure 6

Algorithm 4. Perturb both inputs and weights and train on both clean and adversarial examples (scenario 3).

Figure 7

Figure 3. LSTM-based model standard training results. Top is the loss function value, middle is the weighted F1-score value, and bottom is the accuracy value.

Figure 8

Figure 4. LSTM-based model scenario 1 results. Top is the loss function value, middle is the weighted F1-score value, and bottom is the accuracy value.

Figure 9

Figure 5. LSTM-based model scenario 2 results. Top is the loss function value, middle is the weighted F1-score value, and bottom is the accuracy value.

Figure 10

Figure 6. LSTM-based model scenario 3 results. Top is the loss function value, middle is the weighted F1-score value, and bottom is the accuracy value.

Figure 11

Table 2. Results of the seven models on the validation and test splits after standard training. Loss is the binary cross-entropy loss, F1 is the weighted F1-score, and Acc is the accuracy score. Both clean and adversarial versions for each split are used for evaluation

Figure 12

Table 3. Results of the seven models on the validation and test splits after adversarial training. Loss is the binary cross-entropy loss, F1 is the weighted F1-score, and Acc is the accuracy score. Both clean and adversarial versions for each split are used for evaluation

Figure 13

Figure A1. GRU-based model results. The first row shows the results of the standard training process. The second row shows the results of training on adversarial examples only (scenario 1). The third row shows the results of training on perturbed examples and weights (scenario 2). The fourth row shows the results of training on both clean and perturbed examples where the weights are also perturbed (scenario 3)). The left column shows the loss function value. The second column shows the weighted F1-score value. The third column shows the accuracy value.

Figure 14

Figure A2. MHA-based model results. The first row shows the results of the standard training process. The second row shows the results of training on adversarial examples only (scenario 1). The third row shows the results of training on perturbed examples and weights (scenario 2). The fourth row shows the results of training on both clean and perturbed examples where the weights are also perturbed (scenario 3)). The left column shows the loss function value. The second column shows the weighted F1-score value. The third column shows the accuracy value.

Figure 15

Figure A3. CNN-based model results. The first row shows the results of the standard training process. The second row shows the results of training on adversarial examples only (scenario 1). The third row shows the results of training on perturbed examples and weights (scenario 2). The fourth row shows the results of training on both clean and perturbed examples where the weights are also perturbed (scenario 3)). The left column shows the loss function value. The second column shows the weighted F1-score value. The third column shows the accuracy value.

Figure 16

Figure A4. LSTM-CNN-based model results. The first row shows the results of the standard training process. The second row shows the results of training on adversarial examples only (scenario 1). The third row shows the results of training on perturbed examples and weights (scenario 2). The fourth row shows the results of training on both clean and perturbed examples where the weights are also perturbed (scenario 3)). The left column shows the loss function value. The second column shows the weighted F1-score value. The third column shows the accuracy value.

Figure 17

Figure A5. GRU-CNN-based model results. The first row shows the results of the standard training process. The second row shows the results of training on adversarial examples only (scenario 1). The third row shows the results of training on perturbed examples and weights (scenario 2). The fourth row shows the results of training on both clean and perturbed examples where the weights are also perturbed (scenario 3)). The left column shows the loss function value. The second column shows the weighted F1-score value. The third column shows the accuracy value.

Figure 18

Figure A6. MHA-CNN-based model results. The first row shows the results of the standard training process. The second row shows the results of training on adversarial examples only (scenario 1). The third row shows the results of training on perturbed examples and weights (scenario 2). The fourth row shows the results of training on both clean and perturbed examples where the weights are also perturbed (scenario 3)). The left column shows the loss function value. The second column shows the weighted F1-score value. The third column shows the accuracy value.