<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Publishing DTD v1.2 20190208//EN" "JATS-journalpublishing1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:mml="http://www.w3.org/1998/Math/MathML" article-type="research-article" dtd-version="1.2" xml:lang="en">
<front>
<journal-meta>
<journal-id journal-id-type="publisher-id">ijeap</journal-id>
<journal-title-group><journal-title>International Journal of Engineering and Applied Physics</journal-title><abbrev-journal-title>IJEAP</abbrev-journal-title></journal-title-group>
<issn publication-format="electronic">2737-8071</issn>
<publisher><publisher-name>International Journal of Engineering and Applied Physics</publisher-name></publisher>
</journal-meta>
<article-meta>
<article-id pub-id-type="publisher-id">113</article-id>
<title-group><article-title>The Global and local attention for automatic Arabic text diacritization</article-title></title-group>
<contrib-group><contrib contrib-type="author" corresp="yes"><name><surname>Mijlad</surname><given-names>Ali</given-names></name><xref ref-type="aff" rid="aff1"/><email>a.mijlad@uae.ac.ma</email></contrib><contrib contrib-type="author"><name><surname>El Younoussi</surname><given-names>Yacine</given-names></name><xref ref-type="aff" rid="aff1"/></contrib></contrib-group>
<aff id="aff1">SIGL Laboratory, ENSATe, Abdelmalek Essaadi University, Tetouan, Morocco</aff>
<pub-date publication-format="electronic" date-type="pub"><day>25</day><month>1</month><year>2023</year></pub-date>
<volume>3</volume><issue>1</issue><fpage>653</fpage><lpage>661</lpage>
<history><date date-type="received"><day>31</day><month>8</month><year>2022</year></date><date date-type="rev-recd"><day>1</day><month>10</month><year>2022</year></date><date date-type="accepted"><day>3</day><month>10</month><year>2022</year></date></history>
<permissions><copyright-year>2023</copyright-year><license license-type="open-access" xlink:href="https://creativecommons.org/licenses/by/4.0/"><license-p>This is an open access article under the CC BY 4.0 license.</license-p></license></permissions>
<self-uri xlink:href="https://ijeap.org/ijeap/article/view/113"/>
<abstract><p>Automatic Arabic diacritization is the task to restore diacritic or vowel marks for a non-vocalized Arabic text. This task showed its importance in the natural language processing NLP field and it helps people with specific learning difficulties to access Arabic web content. To tackle the problem, we suggest a letter-based encoder-decoder that uses previous deep learning attention models known as Luong attention. The training of the models knew unstable loss. And, as was expected — from the proposed models — the model that uses local predictive attention achieved the best word and letter error rates. The best-achieved diacritic error rate in the test data is about 26.80%. Nevertheless, the models need improvements in future work.</p></abstract>
<kwd-group kwd-group-type="author"><kwd>Natural language processing</kwd><kwd>Encoder-decoder</kwd><kwd>Attention mechanism</kwd><kwd>Luong attention</kwd><kwd>Arabic diacritization</kwd></kwd-group>
</article-meta>
</front>
<body>
<sec id="sec1">
  <title>1. INTRODUCTION</title>
  <p>Arabic is a Semitic language, which can be classified into three levels: classical Arabic, Modern Standard Arabic MSA, and dialectal Arabic. It follows writing conventions based on consonants and the choice to include diacritics (vowels) or not. When they are included, they can appear above or below the letters. Besides, some reasons why diacritics are omitted are: people with good knowledge of Arabic can infer the vowels in non-diacritized texts, and the speed of typing may decrease if the diacritics are included. Nevertheless, Arabic vowels are important and can be of great help for people starting to learn that language. Additionally, they can enhance the reading and learning abilities of dyslexic learners. As mentioned by Al- Wabil et al.[1], the lack of phonological skills and working memory make an obstacle to learning for Arabic dyslexics. The excessive use of non-diacritized Arabic text on web content excludes that segment of society to access Arabic web content.</p>
  <p>Bishara’s study[2] shows the liaison between the students with learning disabilities and the orthographic depth of the Arabic language. Among the group of students who learned reading based on the fully diacritized form, they got the best measures of phonological and morphological processing, compared to the group of pupils that learned to read based on partially diacritized texts.</p>
  <p>In addition, Arabic diacritics can ameliorate some tasks in the natural language processing NLP field, like text-to-speech TTS. This, in return, is useful to access Arabic web content for visually impaired people by ameliorating — as in the work of Abuali et al.[3] — the screen readers’ accuracy. Machine translation, part-of-speech (POS) tagging, text classification, sentiment analysis, and information retrieval, are also tasks that can get influenced by Arabic diacritics. Hence, the importance of automating the Arabic vowels restoration.</p>
  <p>To evaluate the performance of an automatic diacritization system, diacritic error rate DER, and word error rate WER are the metrics to use. The former parameter calculates the percentage of characters that have wrong diacritics. The latter returns the ratio of words that have at least one wrong diacritic mark.</p>
  <p>Alansary’s work[4] is based on rules to solve the problem. For Gal’s system[5] it used the hidden Markov model HMM based on the bigram model and the Viterbi algorithm. Elshafei et al.’s work[6] also uses the HMM, after all the distribution of unigrams, bigrams, and trigrams of words are extracted. Ameur et al.[7] proposed a system where Arabic diacritization is done in two steps. First, a word-based HMM restores the diacritics based on the bigram model. Second, for the out-of-vocabulary OOV, a letter-based HMM restores the diacritics based on a 4-gram model. Hadjir et al.’s work[8] also uses the HMM with a Viterbi decoder to restore diacritics.</p>
  <p>Rashwan et al.[9] handled the problem by tokenizing the text and applying a memory of context to each token. Then, two parallel deep networks use the words and their contexts. One of those networks retrieves the features, while the other does the Part-of-speech POS tagging. The outputs of those deep nets are fed to another deep network to do the classification.</p>
  <p>Belinkov et al.’s work[10] and Abandah et al.[11] used bidirectional recurrent neural networks. Metwally et al.'s system[12] firstly does the morphological diacritization and the POS tagging, utilizing the HMM. Secondly, their system restores the same things, but this time for the Out-of-vocabulary OOV words. Lastly, the system does the syntactic vowelization based on POS tags, morphological features, and a Conditional Random Fields (CRFs) classifier.</p>
  <p>Zayyan et al.[13] tackled the problem using multi-lexical layers composed of word-based n-gram models, and letter-based n-gram models.</p>
  <p>Said et al.’s system[14] is a multilayered sequence. Firstly, common mistakes are auto-corrected and accompanied by tokenization. Secondly, the unseen words are extracted accompanied by inferring the morphological features based on rules and a morphological analyzer. Then comes POS tagging based on an HMM. POS helps in combination with rules to infer the case endings (syntactic diacritics). Eventually, the Conditional Random Field (CRF) model deals with the out-of-vocabulary OOV.</p>
  <p>Shaalan et al.’s work[15] uses lexicon retrieval that relies on an Arabic lexicon. The system also uses the bigram model. Besides, a Support Vector Machine SVM is used to do the tokenization and POS tag each token. A decision-maker module uses the three outputs —lexicon, bigram, and POS tags— and selects the internal diacritics. The case ending module determines the POS, chunk position, and case endings based on an SVM model.</p>
  <p>Shahrour et al.’s system[16] uses MADAMIRA1 as a baseline. They used syntactic features extracted based on the MaltPaser[17]. To retrieve the morpho-syntactic abstraction they used the J48 classifier.</p>
  <p>Chennoufi et al.’s system[18] firstly extracts — based on Alkhalil Morpho Sys2 — the morphological characteristics and diacritization forms of each word. Secondly, based on rules it eliminates inappropriate transitions. This is followed by a word-based HMM. Eventually, a letter-based HMM handles the non-diacritized words.</p>
  <p>Fashwan et al.’s work[19] restores the diacritics in two steps. One is morphological-wise using uni-morphological and statistical processing, morphological-based rules, and the processing of the undiacritized words (OOV). The second step restores the case endings using syntactic-based rules.</p>
  <p>Darwish et al.[20] use a word-based Viterbi algorithm, morphological patterns, the stems, and the diacritizations of named entities based on sequence labeling and transliteration. SVM ranking, linguistic rules, and morphological patterns are used to infer the case endings.</p>
  <p>Alqudah et al.[21] use MADAMIRA first, then its outputs that have higher confidence parameters are fed to a BLSTM.</p>
  <p>Abbad et al.[22] use a multi-component model to restore diacritics. First, it starts with a preprocessing phase followed by a deep learning component. Then comes a rule-based correction layer, followed by a trigram and bigram model, which solve the case of undiacritized words. Then comes the phase that uses Levenshtein distance for the remaining non-vocalized words.</p>
  <p>In this paper, we are going to present an approach to tackle the problem of diacritic restoration. Our approach mainly uses the attention-based encoder-decoder to solve the issue of diacritization at a letter-based level. We will apply to the problem three attention variants — global, local monotonic, and local predictive — proposed by Luong et al.[23] for the translation problem, and we are expecting that the local-predictive-based model will have the best results as it did for the translation task.</p>
  <p><sup>1</sup> https://camel.abudhabi.nyu.edu/madamira/</p>
  <p><sup>2</sup> https://sourceforge.net/projects/alkhalil/</p>
  <p>This work gets its novelty, compared to previous work, from the fact that we are comparing three attention-based deep learning models applied to a character-level — each input token (respectively, output token) is a character — diacritization problem because the attention-based models were applied at first to translation problems. This work also shows which of the models to use to solve the diacritization issue, and it gives what kind of ameliorations the preprocessing phase and the models need for future enhancement.</p>
</sec>
<sec id="sec2">
  <title>2. RESEARCH METHOD</title>
  <sec>
    <title>2.1. Additional Arabic knowledge background</title>
    <p>The basic vowels are mainly grouped into four types. Table 1 presents those four types, where each diacritic mark is written with the letter “ب” /b/ to make a good illustration. There are short vowels which are Fathah, Dammah, and Kasrah. Then there is the Tanwin group (nunations) in which every diacritic is written as a double short vowel. When read, the Tanwin is pronounced as a short vowel with an /n/ sound at the end. The third group is composed of Shaddah also known as germination. When written it is present in combination with short vowels, or Tanwin. The last group is composed of Sukun, which is assigned to consonants to indicate the absence of vowels and the near end of a syllable.</p>
    <p>In terms of functionality, we can have two diacritic classes [24]. First, there is the core-diacritic class, which plays a morphological or lexical role. This class disambiguates the lexical features of the word; otherwise, it defines the meaning of the word. Second, there is the case ending or the inflectional class that disambiguates the syntactic features of the same lexeme in a sentence.</p>
    <table-wrap id="tab1"><label>Table 1</label><caption><p>Arabic diacritics with their International Phonetic Alphabet representation (IPA)</p></caption><table>
    <colgroup>
      <col width="17%" />
      <col width="17%" />
      <col width="17%" />
      <col width="17%" />
      <col width="17%" />
      <col width="17%" />
    </colgroup>
    <thead>
      <tr>
        <th align="center"><bold>Diacritic Mark</bold></th>
        <th align="center"><bold>Name</bold></th>
        <th align="center"><bold>Type</bold></th>
        <th align="center"><bold>Transl.</bold></th>
        <th align="center"><bold>IPA</bold></th>
        <th align="center"><bold>Word Position</bold></th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td align="center">ب Fathah Short Vowels a /a/ Any َ ب Dammah Short Vowels u /u/ Any َ</td>
        <td align="center"></td>
        <td align="center"></td>
        <td align="center"></td>
        <td align="center"></td>
        <td align="center"></td>
      </tr>
      <tr>
        <td align="center">ب</td>
        <td align="center">kasrah</td>
        <td align="center">Short Vowels</td>
        <td align="center">i</td>
        <td align="center">/i/</td>
        <td align="center">Any</td>
      </tr>
      <tr>
        <td align="center">ابً</td>
        <td align="center">Tanwin Fath</td>
        <td align="center">Tanwin</td>
        <td align="center">F</td>
        <td align="center">/an/</td>
        <td align="center">End َ</td>
      </tr>
      <tr>
        <td align="center">ب</td>
        <td align="center">Tanwin Damm</td>
        <td align="center">Tanwin</td>
        <td align="center">N</td>
        <td align="center">/un/</td>
        <td align="center">End َ</td>
      </tr>
      <tr>
        <td align="center">ب</td>
        <td align="center">Tanwin Kasr</td>
        <td align="center">Tanwin</td>
        <td align="center">K</td>
        <td align="center">/in/</td>
        <td align="center">End َ</td>
      </tr>
      <tr>
        <td align="center">ب</td>
        <td align="center">Shaddah</td>
        <td align="center">Shaddah</td>
        <td align="center">~</td>
        <td align="center">:</td>
        <td align="center">Any َ</td>
      </tr>
      <tr>
        <td align="center">ب</td>
        <td align="center">Sukun</td>
        <td align="center">Sukun</td>
        <td align="center">o</td>
        <td align="center">∅</td>
        <td align="center">Any</td>
      </tr>
    </tbody>
  </table></table-wrap>
  </sec>
  <sec>
    <title>2.2. Preprocessing</title>
    <p>In this work, we used some preprocessing tasks used in the work of Abbad et al.[22]. Only the characters that have a relation to diacritic restoration are kept. The numbers are replaced by 0. The other chars are removed before the vowel restoration process. Then, from that sentence, we get a sequence input and a sequence output. The input sequence contains the mapping to a set of numeric labels representing the letters, while the output sequence contains the mapping to a set of numeric labels representing the eight mentioned diacritics in addition to the empty (absence of diacritic), start, and end tokens. Each input (respectively, output) sequence is padded with zeros to an input max length (respectively, an output max length).</p>
  </sec>
  <sec>
    <title>2.3. Global attention mechanism applied to diacritic restoration</title>
    <p>Our proposed system is based on the sequence to sequence with the attention mechanism model. We took the problem as a translation problem, where each input token is a letter and each target token is a diacritic mark. The model uses the baseline form of the Luong attention mechanism[23], also known as global attention. The aforementioned attention takes into consideration all the input sequence letters to make predictions. Figure 1 shows how Luong’s attention works:</p>
    <fig id="fig1"><label>Figure 1</label><caption><p><inline-graphic mimetype="image" mime-subtype="png" xlink:href="image002.png" /><italic>Global attention model by Luong et al.</italic></p></caption><graphic mimetype="image" mime-subtype="png" xlink:href="image001.png" /></fig>
    <sec>
      <title><italic>2.3.1. Encoder:</italic></title>
      <p>The encoder is composed of an embedding layer followed by a Gated Recurrent Unit GRU layer. The GRU inputs at each timestep <italic>t</italic> the embedded representation of <italic>x<sub>t</sub></italic> and the previously hidden state <italic>h<sub>t−1</sub></italic> to produce the hidden state <italic>h<sub>t</sub></italic> as follows:</p>
      <graphic mimetype="image" mime-subtype="png" xlink:href="image003.png" />
      <p>The encoder output, at the end of the sequence, all the hidden states expressed as <italic>h̅<sub>s</sub>= {h</italic><sub>1</sub><italic>, …, h<sub>Tx</sub></italic>}, where <italic>T<sub>x</sub></italic> is the length of the sequence.</p>
    </sec>
    <sec>
      <title><italic>2.3.2. Decoder:</italic></title>
      <p>The decoding does the following loop up to the end of the sequence:</p>
      <p>i. First computes the hidden state <italic>h<sub>t</sub></italic> based on the previously hidden state <italic>h<sub>t−1</sub></italic> and the previous output <italic>y<sub>t−1</sub></italic> ii. Align the source hidden state set <italic>h̅<sub>s</sub></italic> with hidden state <italic>h<sub>t</sub></italic> to calculate the score as follows:</p>
      <graphic mimetype="image" mime-subtype="png" xlink:href="image004.png" />
      <p><italic>V<sub>a</sub></italic> here is a trainable weight vector, and <italic>W<sub>a</sub></italic> is a trainable weight matrix.</p>
      <p>iii. Calculate the attention weight vector:</p>
      <graphic mimetype="image" mime-subtype="png" xlink:href="image005.png" />
      <p>iv. Determine the context vector as a weighted average over all source hidden states:</p>
      <graphic mimetype="image" mime-subtype="png" xlink:href="image006.png" />
      <p>v. Given <italic>W<sub>c</sub></italic> a trainable weight matrix, the attentional hidden state is calculated:</p>
      <graphic mimetype="image" mime-subtype="png" xlink:href="image007.png" />
      <p>vi. The attentional hidden state <italic>h̃<sub>t</sub></italic> is weighted – based on the trainable weight matrix <italic>W<sub>s</sub></italic> – and input to a</p>
      <p><italic>Softmax</italic> layer to produce the expected char at the time step <italic>t</italic>:</p>
      <graphic mimetype="image" mime-subtype="png" xlink:href="image008.png" />
    </sec>
  </sec>
  <sec>
    <title>2.4. Local attention applied to diacritic restoration</title>
    <p>We tackled here the problem by the use of the local forms of the Luong attention mechanism[23]. The local attention variants proposed by Luong et al.[23] concentrate only on a smaller subset of the source positions per target token. Figure 2 shows Luong local attention model:</p>
    <sec>
      <title><italic>2.4.1. Encoder:</italic></title>
      <fig id="fig2"><label>Figure 2</label><caption><p><inline-graphic mimetype="image" mime-subtype="png" xlink:href="image010.png" /><italic>Local attention model by Luong et al.</italic></p></caption><graphic mimetype="image" mime-subtype="png" xlink:href="image009.png" /></fig>
      <p>It does the same thing as the one defined in the global attention model part. The encoder here outputs a set of hidden states <italic>H= {h</italic><sub>1</sub><italic>, …, h<sub>Tx</sub></italic>}, where <italic>T<sub>x</sub></italic> is the length of the sequence.</p>
    </sec>
    <sec>
      <title><italic>2.4.2. Decoder:</italic></title>
      <p>The decoder in the sequence to sequence with local attention, at each time step it does the following: i. First, it takes the hidden state <italic>h<sub>t</sub></italic> at the top layer of the GRU.</p>
      <p>ii. The model predicts a single alignment position <italic>p<sub>t</sub></italic>, this help align the position of the current target t with</p>
      <p>the source token positions. This alignment can be either monotonic or predictive.</p>
      <p>The monotonic alignment assumes that the source and target are monotonically aligned. While the predictive one does not assume that rough alignment and it is calculated as:</p>
      <graphic mimetype="image" mime-subtype="png" xlink:href="image011.png" />
      <p>Where <italic>V<sub>p</sub></italic> and <italic>W<sub>p</sub></italic> are trainable parameters, <italic>S<sub>l</sub></italic>: is the length of the input sentence.</p>
      <p>The alignment <italic>p<sub>t</sub></italic> — either monotonic or predictive — is used to determine, at each time step, the windows <italic>[p<sub>t</sub>−D, p<sub>t</sub>+ D</italic>]. This gives the encoder hidden states <italic>h̅<sub>s</sub></italic> to be taken into consideration.</p>
      <p>iii. The alignment of the source states <italic>h̅<sub>s</sub></italic> with the hidden state <italic>h<sub>t</sub></italic> is calculated as in equation (2).</p>
      <p>iv. Calculate attention weights; for local monotonic, it is calculated as in the equation (3), while for the local</p>
      <p>predictive it uses, in addition, a Gaussian distribution centered at <italic>p<sub>t</sub></italic> as follows:</p>
      <graphic mimetype="image" mime-subtype="png" xlink:href="image012.png" />
      <p>Where <italic>s</italic> are integers within the window <italic>[p<sub>t</sub>−D, p<sub>t</sub>+ D</italic>], and <italic>σ= D/2</italic></p>
      <p>v. The context vector is calculated as in equation (4).</p>
      <p>vi. Attentional hidden state <italic>h̃<sub>t</sub></italic> is calculated as in equation (5).</p>
    </sec>
  </sec>
  <sec>
    <title>2.5. Dataset</title>
    <p>We used in this work the free-available benchmark dataset used in the comparative study of Fadel et al.[25]. That dataset was derived from different chosen books from the Tashkeela corpus. Then it was — in the same work of Fadel et al.[25] — cleaned, processed, and split into a training set with a percentage of 90%, and the remaining 10% was split in half for the validation and testing sets.</p>
    <p>From those three files provided by the mentioned work, we derived three other files, where each input sentence of the model has a maximum number of chars equal to 100. We have chosen that length because of the hardware limitations we have, and the model we have here is a letter-based one.</p>
    <p>We extracted more information about the final dataset we used. Table 2 shows more information about the tokens, chars, and sentences in the different datasets. Table 3 shows the percentage of the unseen words in the validation and blind sets in comparison to the train set.</p>
    <table-wrap id="tab2"><label>Table 2</label><caption><p>Some statistics about the datasets used in this work</p></caption><table>
    <colgroup>
      <col width="25%" />
      <col width="25%" />
      <col width="25%" />
      <col width="25%" />
    </colgroup>
    <thead>
      <tr>
        <th align="center"></th>
        <th align="center"><bold>Train set</bold></th>
        <th align="center"><bold>Validation set</bold></th>
        <th align="center"><bold>test set</bold></th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td align="center">Characters</td>
        <td align="center">7622220</td>
        <td align="center">377897</td>
        <td align="center">393552</td>
      </tr>
      <tr>
        <td align="center">Tokens</td>
        <td align="center">1177062</td>
        <td align="center">58635</td>
        <td align="center">60591</td>
      </tr>
      <tr>
        <td align="center">Numbers</td>
        <td align="center">2301</td>
        <td align="center">123</td>
        <td align="center">138</td>
      </tr>
      <tr>
        <td align="center">Digits</td>
        <td align="center">8978</td>
        <td align="center">480</td>
        <td align="center">507</td>
      </tr>
      <tr>
        <td align="center">Arabic words</td>
        <td align="center">1015627</td>
        <td align="center">50387</td>
        <td align="center">52179</td>
      </tr>
      <tr>
        <td align="center">Arabic letters</td>
        <td align="center">4015335</td>
        <td align="center">198913</td>
        <td align="center">207293</td>
      </tr>
      <tr>
        <td align="center">Diacritics</td>
        <td align="center">3431148</td>
        <td align="center">170025</td>
        <td align="center">177099</td>
      </tr>
      <tr>
        <td align="center">Undiacritized forms</td>
        <td align="center">75615</td>
        <td align="center">12747</td>
        <td align="center">13440</td>
      </tr>
      <tr>
        <td align="center">Diacritized forms</td>
        <td align="center">114792</td>
        <td align="center">16507</td>
        <td align="center">17233</td>
      </tr>
      <tr>
        <td align="center">Number of sentences</td>
        <td align="center">121531</td>
        <td align="center">6156</td>
        <td align="center">6417</td>
      </tr>
    </tbody>
  </table></table-wrap>
    <table-wrap id="tab3"><label>Table 3</label><caption><p>Percentage of out-of-vocabulary (OOV) in validation and blind sets compared to the training set</p></caption><table>
    <colgroup>
      <col width="33%" />
      <col width="33%" />
      <col width="33%" />
    </colgroup>
    <thead>
      <tr>
        <th align="center"></th>
        <th align="center"><bold>Validation set</bold></th>
        <th align="center"><bold>Test set</bold></th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td align="center">Diacritized OOV Arabic words (%)</td>
        <td align="center">18.78</td>
        <td align="center">20.03</td>
      </tr>
      <tr>
        <td align="center">Undiacritized OOV Arabic words</td>
        <td align="center">13.97</td>
        <td align="center">15.59</td>
      </tr>
    </tbody>
  </table></table-wrap>
  </sec>
  <sec>
    <title>2.6. Evaluation metrics</title>
    <p>As in previous works to evaluate our model, we used the diacritic and word error rates. Specifically, the ones defined in the work of Fadel et al.[25].</p>
    <p>i. Diacritic error rate (DER) is the rate to attribute wrong diacritics to chars in the text.</p>
    <p>ii. Word error rate (WER) is the rate of words that have at worst one wrong vowel mark.</p>
    <p>Those metrics — when calculated in Fadel et al.[25]'s work— non-Arabic characters are ignored, which is not the case in some previous works. This can give an unbiased view of the results. Furthermore, you have the choice to include the 'no-diacritic' option, which includes or does not the number of undiacritized letters from the original text. Additionally, the case-ending count can be included or not while computing those metrics.</p>
    <p>We also report the Sparse-Categorical-Crossentropy loss of the models during the training.</p>
  </sec>
</sec>
<sec id="sec3">
  <title>3. RESULTS AND DISCUSSIONS</title>
  <sec>
    <title>3.1. Loss versus epochs:</title>
    <p>In figure 3, the global-attention-based model has achieved the lowest validation loss value of 0.11375 at epoch number 2. We can see here that the model has low losses from the first epoch. We set the model to patience for three additional epochs to verify if the validation loss could reach another minimum. After the second epoch, the model overfits the data. The overfitting explanation is that the model could be too complicated for the data. That is why we saved the model at epoch 2.</p>
    <p>Figure 4 shows that the local-monotonic-based model has achieved the lowest loss at epoch 5 with a value of 0.0859. Here from the first epoch, the loss values were higher, and the model took 5 epochs to find a minimal validation loss. Here also the early stopping helped the model not to go further in the training and saved the best weights of the model at epoch 5.</p>
    <fig id="fig3"><label>Figure 3</label><caption><p><italic>Loss vs epoch for the global-attention-based model</italic></p></caption><graphic mimetype="image" mime-subtype="png" xlink:href="image013.png" /></fig>
    <fig id="fig4"><label>Figure 4</label><caption><p><italic>Loss vs epoch for the local-monotonic-attention-based model</italic></p></caption><graphic mimetype="image" mime-subtype="png" xlink:href="image014.png" /></fig>
    <p>Figure 5. <italic>Loss vs epoch for the local-predictive-attention-based model</italic></p>
    <p>Figure 5 shows the loss improvement during the training phase of the local-predictive-based model. We saved the model at epoch number 6 where the model reach a low validation loss of value 0.09910.</p>
    <p>Generally, the loss of the three models is not going smoothly to the minimum value. Those oscillations of the loss — we suggest — are due to the size of the network, or also the learning rate. Since the models we suggest have a small network size in terms of the number of neurons, this causes a lack of relationship representations; and that makes each batch change the network considerably.</p>
  </sec>
  <sec>
    <title>3.2. The Diacritic and word error rates:</title>
    <p>Tables 4 and 5 show the diacritic and word error rates achieved on the test set by the three models. The model with local predictive attention performs better on the blind dataset. We also can see that the monotonic performs badly compared to the global attention; this can be explained by the fact the output tokens are not all the time aligned with input tokens. One solution to this could be to augment the window<italic>[p<sub>t</sub>−D, p<sub>t</sub>+ D</italic>]. Due to the instability of the learning of the three models, we can have a hint about the high error rates. We suggest in the next subsection solutions to address the problems of high error rates and unstable loss values.</p>
    <table-wrap id="tab4"><label>Table 4</label><caption><p>Diacritic error rates of the three models</p></caption><table>
    <colgroup>
      <col width="33%" />
      <col width="33%" />
      <col width="33%" />
    </colgroup>
    <thead>
      <tr>
        <th align="center"></th>
        <th align="center"><bold>Diacritic Error Rate: DER (%)</bold></th>
        <th align="center"></th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td align="center"></td>
        <td align="center">Including the ‘no-diacritic’ class</td>
        <td align="center">Excluding the ‘no-diacritic’</td>
      </tr>
      <tr>
        <td align="center">Systems</td>
        <td align="center"></td>
        <td align="center">class</td>
      </tr>
      <tr>
        <td align="center"></td>
        <td align="center">With case Without case</td>
        <td align="center">With case Without case</td>
      </tr>
      <tr>
        <td align="center"></td>
        <td align="center">ending ending</td>
        <td align="center">ending ending</td>
      </tr>
      <tr>
        <td align="center">Global-attention-based model</td>
        <td align="center">43.90 41.26</td>
        <td align="center">49.27 46.11</td>
      </tr>
      <tr>
        <td align="center">Local-monotonic-attention-based model</td>
        <td align="center">50.10 48.07</td>
        <td align="center">52.85 50.30</td>
      </tr>
      <tr>
        <td align="center">Local-predictive-attention-based model</td>
        <td align="center">26.80 23.94</td>
        <td align="center">31.59 28.17</td>
      </tr>
    </tbody>
  </table></table-wrap>
    <table-wrap id="tab5"><label>Table 5</label><caption><p>Word error rates of the three models</p></caption><table>
    <colgroup>
      <col width="33%" />
      <col width="33%" />
      <col width="33%" />
    </colgroup>
    <thead>
      <tr>
        <th align="center"></th>
        <th align="center"></th>
        <th align="center"><bold>Diacritic Error Rate: WER (%)</bold></th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td align="center"></td>
        <td align="center">Including the ‘no Excluding the ‘no-</td>
        <td align="center"></td>
      </tr>
      <tr>
        <td align="center">Systems</td>
        <td align="center">diacritic’ class diacritic’ class</td>
        <td align="center"></td>
      </tr>
      <tr>
        <td align="center"></td>
        <td align="center">With case</td>
        <td align="center">Without With case Without</td>
      </tr>
      <tr>
        <td align="center"></td>
        <td align="center">ending</td>
        <td align="center">case ending ending case ending</td>
      </tr>
      <tr>
        <td align="center">Global-attention-based model</td>
        <td align="center">73.06</td>
        <td align="center">62.92 72.29 62.38</td>
      </tr>
      <tr>
        <td align="center">Local-monotonic-attention-based model</td>
        <td align="center">73.10</td>
        <td align="center">65.69 72.01 64.73</td>
      </tr>
      <tr>
        <td align="center">Local-predictive-attention-based model</td>
        <td align="center">57.34</td>
        <td align="center">44.60 56.75 44.30</td>
      </tr>
    </tbody>
  </table></table-wrap>
  </sec>
  <sec>
    <title>3.3. Recommendations to ameliorate the systems:</title>
    <p>We suggest the following:</p>
    <disp-quote>
      <p>- Change the size of the networks: The networks do not have a sufficient number of neurons (we tried a smaller size due to hardware limitations) to represent the relationships. That could be the reason for the oscillating loss.</p>
      <p>- Find the right learning rate.</p>
      <p>- Add depth to the network, to allow learning more abstract features.</p>
      <p>- Try some regularization techniques for the models.</p>
      <p>- Modify the output data architecture; we suggest here two ways of representing the output data:</p>
    </disp-quote>
    <p>i. Two different output sequences: one sequence is for the presence of germination diacritic, and the other output sequence contains all diacritics except the germination diacritic. This way the two output sequences are roughly aligned with the input sequence.</p>
    <p>ii. One output sequence: here the output sequence takes into account that the germination is present in a sequence it is combined with the following diacritic (either a short vowel, a nunation, or the empty vowel). This also will make all the input and output data roughly aligned. That rough alignment can make the local-monotonic attention perform better.</p>
  </sec>
</sec>
<sec id="sec4">
  <title>4. CONCLUSION</title>
  <p>Automatic Arabic diacritization is a natural language processing NLP task that aims to restore diacritic marks for Arabic text. It helps novice learners and people with specific learning difficulties to have access to web Arabic web content. It can also be useful for more NLP tasks.</p>
  <p>In this paper, we presented three attention mechanisms[23] applied to that task. As expected, the predictive-attention-based model achieved better results compared to other attention-based models. However, due to the hardware limitation, we chose a small dataset and small network sizes. This led to unstable loss during training which caused bad error rates. We are aiming to ameliorate the three systems and compare them to relevant related work.</p>
</sec>

</body>
<back>
<ref-list><title>References</title><ref id="ref1"><label>1</label><mixed-citation>A. Al-Wabil, P. Zaphiris, and S. Wilson, &quot;Web design for dyslexics: Accessibility of Arabic content,&quot; in <italic>Computers Helping People with Special Needs</italic>, vol. 4061, 2006, pp. 817–822, doi: 10.1007/11788713_119.</mixed-citation></ref><ref id="ref2"><label>2</label><mixed-citation>S. Bishara, &quot;The orthographic depth and promotion of students with learning disabilities,&quot; <italic>Cogent Educ.</italic>, vol. 6, no. 1, 2019, doi: 10.1080/2331186X.2019.1646384.</mixed-citation></ref><ref id="ref3"><label>3</label><mixed-citation>B. Abuali and M.-B. Kurdy, &quot;Full diacritization of the Arabic text to improve screen readers for the visually impaired,&quot; <italic>Adv. Human-Comput. Interact.</italic>, vol. 2022, 2022, doi: 10.1155/2022/1186678.</mixed-citation></ref><ref id="ref4"><label>4</label><mixed-citation>S. Alansary, &quot;Alserag: An automatic diacritization system for Arabic,&quot; in <italic>Intelligent Natural Language Processing: Trends and Applications</italic>, Studies in Computational Intelligence, vol. 740, K. Shaalan, A. E. Hassanien, and F. Tolba, Eds. Springer, 2018, pp. 523–543.</mixed-citation></ref><ref id="ref5"><label>5</label><mixed-citation>Y. Gal, &quot;An HMM approach to vowel restoration in Arabic and Hebrew,&quot; in <italic>Proc. ACL-02 Workshop on Computational Approaches to Semitic Languages</italic>, 2002, pp. 1–7, doi: 10.3115/1118637.1118641.</mixed-citation></ref><ref id="ref6"><label>6</label><mixed-citation>M. Elshafei, H. Al-Muhtaseb, and M. M. Alghamdi, &quot;Statistical methods for automatic diacritization of Arabic text,&quot; in <italic>Proc. 18th National Computer Conf.</italic>, 2006, pp. 301–306. [Online]. Available: http://almuhtaseb.net/Research/StaMetAutDiaArTex.pdf</mixed-citation></ref><ref id="ref7"><label>7</label><mixed-citation>M. H. Ameur, Y. Moulahoum, and A. Guessoum, &quot;Restoration of Arabic diacritics using a multilevel statistical model,&quot; in <italic>Proc. 5th Int. Conf. Computer Science and Its Applications (CIIA)</italic>, 2015, pp. 181–192, doi: 10.1007/978-3-319-19578-0_15.</mixed-citation></ref><ref id="ref8"><label>8</label><mixed-citation>I. Hadjir, M. Abbache, and F. Z. Belkredim, &quot;An approach for Arabic diacritization,&quot; in <italic>Proc. 24th Int. Conf. Applications of Natural Language to Information Systems (NLDB 2019)</italic>, vol. 11608, 2019, pp. 337–344, doi: 10.1007/978-3-030-23281-8_29.</mixed-citation></ref><ref id="ref9"><label>9</label><mixed-citation>M. Rashwan, A. Al Sallab, H. Raafat, and A. Rafea, &quot;Automatic Arabic diacritics restoration based on deep nets,&quot; in <italic>Proc. EMNLP 2014 Workshop on Arabic Natural Language Processing (ANLP)</italic>, 2014, pp. 65–72, doi: 10.3115/v1/W14-3608.</mixed-citation></ref><ref id="ref10"><label>10</label><mixed-citation>Y. Belinkov and J. Glass, &quot;Arabic diacritization with recurrent neural networks,&quot; in <italic>Proc. 2015 Conf. Empirical Methods in Natural Language Processing</italic>, 2015, pp. 2281–2285, doi: 10.18653/v1/D15-1274.</mixed-citation></ref><ref id="ref11"><label>11</label><mixed-citation>G. A. Abandah, A. Graves, B. Al-Shagoor, A. Arabiyat, F. Jamour, and M. Al-Taee, &quot;Automatic diacritization of Arabic text using recurrent neural networks,&quot; <italic>Int. J. Doc. Anal. Recognit.</italic>, vol. 18, no. 2, pp. 183–197, 2015, doi: 10.1007/s10032-015-0242-2.</mixed-citation></ref><ref id="ref12"><label>12</label><mixed-citation>A. S. Metwally and M. A. Rashwan, &quot;A multi-layered approach for Arabic text diacritization,&quot; in <italic>Proc. IEEE Int. Conf. Cloud Computing and Big Data Analysis (ICCCBDA)</italic>, 2016, pp. 389–393, doi: 10.1109/ICCCBDA.2016.7529589.</mixed-citation></ref><ref id="ref13"><label>13</label><mixed-citation>A. A. Zayyan, M. Elmahdy, H. Binti Husni, and J. M. Al Ja'am, &quot;Automatic diacritics restoration for dialectal Arabic text,&quot; <italic>Int. J. Comput. Inf. Sci.</italic>, vol. 12, no. 2, pp. 159–165, 2016, doi: 10.21700/ijcis.2016.119.</mixed-citation></ref><ref id="ref14"><label>14</label><mixed-citation>A. Said, M. El-Sharqwi, A. Chalabi, and E. Kamal, &quot;A hybrid approach for Arabic diacritization,&quot; in <italic>Proc. 18th Int. Conf. Applications of Natural Language to Information Systems (NLDB 2013)</italic>, vol. 7934, 2013, pp. 53–64, doi: 10.1007/978-3-642-38824-8.</mixed-citation></ref><ref id="ref15"><label>15</label><mixed-citation>K. Shaalan, H. M. Abo Bakr, and I. Ziedan, &quot;A hybrid approach for building Arabic diacritizer,&quot; in <italic>Proc. EACL 2009 Workshop on Computational Approaches to Semitic Languages</italic>, 2009, pp. 27–35.</mixed-citation></ref><ref id="ref16"><label>16</label><mixed-citation>A. Shahrour, S. Khalifa, and N. Habash, &quot;Improving Arabic diacritization through syntactic analysis,&quot; in <italic>Proc. 2015 Conf. Empirical Methods in Natural Language Processing</italic>, 2015, pp. 1309–1315, doi: 10.18653/v1/D15-1152.</mixed-citation></ref><ref id="ref17"><label>17</label><mixed-citation>J. Nivre, J. Hall, and J. Nilsson, &quot;MaltParser: A data-driven parser-generator for dependency parsing,&quot; in <italic>Proc. 5th Int. Conf. Language Resources and Evaluation (LREC'06)</italic>, 2006, pp. 2216–2219. [Online]. Available: http://www.lrec-conf.org/proceedings/lrec2006/pdf/162_pdf.pdf</mixed-citation></ref><ref id="ref18"><label>18</label><mixed-citation>A. Chennoufi and A. Mazroui, &quot;Morphological, syntactic and diacritics rules for automatic diacritization of Arabic sentences,&quot; <italic>J. King Saud Univ. – Comput. Inf. Sci.</italic>, vol. 29, no. 2, pp. 156–163, 2017, doi: 10.1016/j.jksuci.2016.06.004.</mixed-citation></ref><ref id="ref19"><label>19</label><mixed-citation>A. Fashwan and S. Alansary, &quot;SHAKKIL: An automatic diacritization system for modern standard Arabic texts,&quot; in <italic>Proc. 3rd Arabic Natural Language Processing Workshop</italic>, 2017, pp. 84–93, doi: 10.18653/v1/W17-1311.</mixed-citation></ref><ref id="ref20"><label>20</label><mixed-citation>K. Darwish, H. Mubarak, and A. Abdelali, &quot;Arabic diacritization: Stats, rules, and hacks,&quot; in <italic>Proc. 3rd Arabic Natural Language Processing Workshop</italic>, 2017, pp. 9–17, doi: 10.18653/v1/W17-1302.</mixed-citation></ref><ref id="ref21"><label>21</label><mixed-citation>S. Alqudah, G. Abandah, and A. Arabiyat, &quot;Investigating hybrid approaches for Arabic text diacritization with recurrent neural networks,&quot; in <italic>Proc. IEEE Jordan Conf. Applied Electrical Engineering and Computing Technologies (AEECT)</italic>, 2017, pp. 1–6, doi: 10.1109/AEECT.2017.8257765.</mixed-citation></ref><ref id="ref22"><label>22</label><mixed-citation>H. Abbad and S. Xiong, &quot;Multi-components system for automatic Arabic diacritization,&quot; in <italic>Proc. 42nd European Conf. Information Retrieval (ECIR 2020)</italic>, vol. 12035, 2020, pp. 341–355, doi: 10.1007/978-3-030-45439-5_23.</mixed-citation></ref><ref id="ref23"><label>23</label><mixed-citation>M.-T. Luong, H. Pham, and C. D. Manning, &quot;Effective approaches to attention-based neural machine translation,&quot; in <italic>Proc. 2015 Conf. Empirical Methods in Natural Language Processing</italic>, 2015, pp. 1412–1421, doi: 10.18653/v1/D15-1166.</mixed-citation></ref><ref id="ref24"><label>24</label><mixed-citation>O. Hamed and T. Zesch, &quot;A survey and comparative study of Arabic diacritization tools,&quot; <italic>J. Lang. Technol. Comput. Linguist.</italic>, vol. 32, no. 1, pp. 27–47, 2017.</mixed-citation></ref><ref id="ref25"><label>25</label><mixed-citation>A. Fadel, I. Tuffaha, B. Al-Jawarneh, and M. Al-Ayyoub, &quot;Arabic text diacritization using deep neural networks,&quot; in <italic>Proc. 2nd Int. Conf. Computer Applications &amp; Information Security (ICCAIS)</italic>, May 2019, pp. 1–7, doi: 10.1109/CAIS.2019.8769512.</mixed-citation></ref></ref-list>
</back>
</article>
