<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>ghostwriter19 @ ATE_ABSITA: Zero-Shot and ONNX to Speed up BERT on Sentiment Analysis Tasks at EVALITA 2020</article-title>
      </title-group>
      <abstract>
        <p>1 English. With the arrival of BERT 2 in 2018, NLP research has taken a significant step forward. However, the necessary computing power has grown accordingly. Various distillation and optimization systems have been adopted but are costly in terms of cost-benefit ratio. The most important improvements are obtained by creating increasingly complex models with more layers and parameters. In this research, we will see how, by mixing transfer learning, zero-shot learning, and ONNX runtime3, we can access the power of BERT right now, optimizing time and resources, achieving noticeable results on day one.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>-</title>
      <p>Italiano. Con l'arrivo di BERT nel 2018,
la ricerca nel campo dell'NLP ha fatto un
notevole passo in avanti. La potenza di
calcolo necessaria però è cresciuta di
conseguenza. Diversi sistemi di
distillazione e di ottimizzazione sono stati
adottati ma risultano onerosi in termini di
rapporto costo benefici. I vantaggi di
maggior rilievo si ottengono creando
modelli sempre più complessi con un
maggior numero di layers e di parametri.
In questa ricerca vedremo come mixando
transfer learning, zero-shot learning e
ONNX runtime si può accedere alla
potenza di BERT da subito, ottimizzando
tempo e risorse, raggiungendo risultati
apprezzabili al day one.
1 Copyright ©️ 2020 for this paper by its authors. Use
permitted under Creative Commons License
Attribution 4.0 International (CC BY 4.0).
1</p>
    </sec>
    <sec id="sec-2">
      <title>Introduction</title>
      <p>In a process with data that change very quickly
and the need to resort to complete training in the
shortest possible time, transfer learning
techniques have made possible a fast fine-tuning of
BERT models. The distillation of a model made it
possible to decrease the load and the times without
significantly losing accuracy. These models,
therefore, require, at least, constant fine-tuning
training. In addition, a BERT model specially
designed for the Italian language and with a
vocabulary containing technical terms increases its
effectiveness.</p>
      <p>Constant and multi-disciplinary training requires
specific skills and tailor-made services. In this
research, we will see an effective way to make both
things possible. The idea is to use a way to
exchange AI models between library and
frameworks, the ONNX project, and a runtime, the
ONNX runtime project, to optimize inference for
many platforms, languages and hardware. The
ONNX runtime is still working to optimize the
training directly in the ONNX format.</p>
      <p>
        The second goal is to find a viable alternative with
acceptable performance at the start of a new
project while waiting for a trained BERT model.
The research was carried out for the ATE
ABSITA
        <xref ref-type="bibr" rid="ref5">(de Mattei et al., 2020)</xref>
        task in the
EVALITA 2020
        <xref ref-type="bibr" rid="ref2">(Basile et al., 2020)</xref>
        , using all 3
available sub-tasks.
2
      </p>
    </sec>
    <sec id="sec-3">
      <title>Description of the system</title>
      <p>To start using a sentiment analysis system, we
need several elements. Certainly, a starting dataset
2 https://github.com/google-research/bert
3 https://microsoft.github.io/onnxruntime/
with the related labels. In the tasks of the
challenge, we have the reviews of 23 different
products. Each review has a corresponding rating
assigned by the end-user. For each review, it was
required to extract the aspects contained in it. By
aspect, we mean every opinion word that expresses
a sentiment polarity. Finally, each aspect was
classified as a pair of values: positive or negative,
for 4 possible states.</p>
      <p>Imagine a system that receives an unspecified
number of reviews in real-time with new products
and different categories. We find ourselves in the
situation of always having to fine-tune our
models.</p>
      <p>The complexity of BERT makes training time
difficult for constant alignment. Being able to reduce
the training time, or being able to put in place an
alternative in the meantime, new perspectives
open up, such as:
 Made inference calls before a full trained
model is completed.

</p>
      <sec id="sec-3-1">
        <title>Training of the new model.</title>
      </sec>
      <sec id="sec-3-2">
        <title>Running the BERT model.</title>
        <p> (optional) reclassify recent product reviews
after the model update.</p>
        <p>
          In this perspective, in order to validate my
hypotheses, I used the AlBERTo
          <xref ref-type="bibr" rid="ref7">(Polignano at al., 2019)</xref>
          model, used in the baseline, and Ktrain4, a
wrapper for TensorFlow5, with the autofit option.
The first submission, called ghostwriter19_a, was
obtained training all the models with the Ktrain
framework.
        </p>
        <p>
          The results for the three tasks for the second
submission, called ghostwriter19_b, were obtained in
two different way:
 for the first two tasks, I used the model of
the first submission but exported on ONNX
and ran with the ONNX runtime.
 for the third task, I trained the model with
TensorFlow using a Zero-Shot learner
[ZSL]
          <xref ref-type="bibr" rid="ref4">(Brown et al, 2020)</xref>
          .
        </p>
        <p>To test the models, I used two different machines
with Ubuntu 20.04 LTS:
 6 vCPU on Intel Xeon E5-2690 v4 - 112GB
with P100 (GPU)
 14 cores on Intel Xeon E5-2690 v4 - 32GB
(CPU)
2.1</p>
      </sec>
    </sec>
    <sec id="sec-4">
      <title>Task 1 – ATE: Aspect Term Extraction</title>
      <p>To identify an aspect, the dataset contains a label
for every single word with three possible values:
- B for Begin of an aspect.
- I for Inside an aspect.
- Or for Outside, not in an aspect.</p>
      <p>For example, the review “La borraccia termica
svolge egregiamente il proprio compito di
mantenere la temperatura, calda o fretta che sia.
La costruzione è ottimale e ben rifinita. Acquisto
straconsigliato!” is labeled as:
The model will be evaluated with the F1-score.
The score results from the full matched aspects,
the partial matched ones, and the missed ones.
The preliminary results with the Ktrain model
were encouraging (table 1).</p>
    </sec>
    <sec id="sec-5">
      <title>Model</title>
      <p>ghostwriter19_a</p>
      <sec id="sec-5-1">
        <title>Baseline</title>
        <p>At this point, the model has been exported with
ONNX in maximum compatibility mode. The
model ran with the ONNX runtime optimized for
CPU.</p>
        <p>The performances have remained unchanged, but
the speed of inference has significantly improved
(table 2).
4 https://github.com/amaiya/ktrain
5 https://www.tensorflow.org/
ghostwriter19_a CPU
ghostwriter19_b CPU
with ONNX runtime
ghostwriter19_a GPU
ghostwriter19_b GPU
with ONNX runtime
4
68
124
217</p>
      </sec>
    </sec>
    <sec id="sec-6">
      <title>Query per second</title>
      <p>The improvement is 17x for the CPU version and
1.75x for the GPU version.
For this task, the aspects identified in Task 1
have been used. This implies that an error in
Task 1 will have a decisive impact on Task
number 2.</p>
      <sec id="sec-6-1">
        <title>The aspect can be classified as:</title>
        <p> positive (POS:true,NEG:false)
 negative (POS:false,NEG:true)
 mixed polarity(POS:true, NEG:true)
 neutral polarity (POS:false, NEG:false)
As showed to the image from the challenge
website6:
The results on the DEV test outperform the
baseline (table 3).
Also, for this task, the performance is improved
with the use of ONNX runtime (table 4).
6 http://www.di.uniba.it/~swap/ate_absita/task.html</p>
      </sec>
    </sec>
    <sec id="sec-7">
      <title>Query per second Model</title>
      <p>Task 3 is a classification problem. However, fully
understanding the score is not easy. The
evaluation operation is carried out by different people
and with different styles. A product with a similar
review is rated according to the expectations and
judgment of other users differently.</p>
      <p>
        Furthermore, in order to obviate the long training
time that a constant updating requires, compared
with systems used by the previous version of
EVALITA, such as an ensemble system with Tree
Random Forest and Bi-LSTM
        <xref ref-type="bibr" rid="ref3">(Bennici and
Portocarrero, 2018)</xref>
        or with an SVM system
        <xref ref-type="bibr" rid="ref1">(Barbieri
et al., 2016)</xref>
        , I used a Zero-Shot Learner [ZSL]
        <xref ref-type="bibr" rid="ref9">(Pushp &amp; Srivastava, 2017)</xref>
        . A ZSL is a way to
make predictions without prior training
        <xref ref-type="bibr" rid="ref8">(Petroni,
2019)</xref>
        . ZSL will refer to the embedding of a
previous matrix, AlBERTo in this case, and of the
proposed labels as a possible result
        <xref ref-type="bibr" rid="ref10">(Schick and
Schütze, 2020)</xref>
        .
      </p>
      <p>The proposed labels were the possible numbers
for evaluation, then the numbers from 1 to 5.
The proposed prediction value is a weighted
average of the two values with the highest probability,
if and only if the gap between the two values is
less than 10−3. Otherwise, only the value with the
highest probability will be considered valid.
For this task, I omitted the ONNX runtime test
because a stable converter for the ZSL version is
not available.</p>
      <p>The score for this task is the Root Mean Squared
Error between the polarity predicted and the
polarity assigned by the user.</p>
    </sec>
    <sec id="sec-8">
      <title>Model</title>
      <sec id="sec-8-1">
        <title>Baseline AlBERTo</title>
        <p>The loss in performance is 18%, but the entire
previous training phase is skipped (table 5).
3</p>
      </sec>
    </sec>
    <sec id="sec-9">
      <title>Results</title>
      <p>The results obtained with the DEV dataset are
very positive both in terms of accuracy and
performance. ZSL has proven to be an incredible
technology to invest in. The Ktrain seems to suffer
a heavy overfit.</p>
      <p>The research aims not to have a relevant model
but to prove that a model could be
productionready with fewer resources and time.</p>
      <p>However, in all three tasks, the models
outperformed the baseline with a significant gap
in terms of accuracy/RMSE.
3.1</p>
    </sec>
    <sec id="sec-10">
      <title>Results for Task 1</title>
      <p>The final results with the TEST dataset are:</p>
    </sec>
    <sec id="sec-11">
      <title>Model</title>
      <p>ghostwriter19_a_D
ghostwriter19_a_T</p>
      <sec id="sec-11-1">
        <title>Baseline AlBERTo</title>
      </sec>
    </sec>
    <sec id="sec-12">
      <title>F1 score</title>
      <p>The results are about 12% lower than those
obtained in the research phase (table 6).</p>
      <p>It will be interesting to continue experimenting
with different ONNX options to find a better
combination of compatibility and performance.
3.2</p>
    </sec>
    <sec id="sec-13">
      <title>Results for Task 2</title>
      <p>The final results with the TEST dataset are:
ghostwriter19_a_D
ghostwriter19_b_T</p>
      <sec id="sec-13-1">
        <title>Baseline AlBERTo</title>
        <p>0.6019
0.4994
0.2
The loss from DEV to TEST is about 17% (table
7). However, the percentage of the difference
between the results of Tasks 1 and 2 have been
maintained with the DEV and TEST datasets.
This is in line with expectations, worse model
performance in Task 1 impacted Task 2
proportionally. In return, working on a better model will
improve both tasks.
3.3</p>
      </sec>
    </sec>
    <sec id="sec-14">
      <title>Results for Task 3</title>
      <sec id="sec-14-1">
        <title>For Task 3 we have:</title>
      </sec>
    </sec>
    <sec id="sec-15">
      <title>Model</title>
      <p>ghostwriter19_a_D
ghostwriter19_b_D
ghostwriter19_a_T
ghostwriter19_b_T</p>
      <sec id="sec-15-1">
        <title>Baseline AlBERTo</title>
      </sec>
    </sec>
    <sec id="sec-16">
      <title>RMSE score</title>
      <p>0.6997
0.8526
0.81394
0.83479
1.0806
The difference between the DEV and TEST
datasets is marked here only for trained model, 14%
(table 8). The untrained one performed slightly
better, 2%, with the TEST dataset.</p>
      <p>This result confirms that an underperforming
model has the same performance of a model that
use ZSL, as assumed.</p>
      <p>The price to pay, however, is that the average
inference time for the ZSL is 157x higher than the
pure TensorFlow model obtained with Ktrain.
The results demonstrated that it is possible to
create hybrid systems for training and inference to
make the power of BERT more accessible.
In the time it takes to train a new and optimized
model, an untrained ZSL model can make up for
it in the meantime.</p>
      <p>Optimizing, and in future training, our models to
be intrinsically optimized for the platform and
framework we have chosen to use does not affect
performance and future use.</p>
      <p>
        The improvements obtained in the use of ONNX
runtime for these Italian tasks are in line with what
Microsoft demonstrated, for the English language,
at the beginning of 2020
        <xref ref-type="bibr" rid="ref6">(Ning at al., 2020)</xref>
        .
The next step is to make the ONNX export work
with a Zero-Shot learner [ZSL] in order to
compensate, at least in part, for the more significant
resources that this inevitably introduces.
      </p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          <string-name>
            <surname>Barbieri</surname>
            ,
            <given-names>F.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Basile</surname>
            ,
            <given-names>V.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Croce</surname>
            ,
            <given-names>D.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Nissim</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Novielli</surname>
            ,
            <given-names>N.</given-names>
          </string-name>
          , &amp;
          <string-name>
            <surname>Patti</surname>
            ,
            <given-names>V.</given-names>
          </string-name>
          (
          <year>2016</year>
          ).
          <article-title>Overview of the Evalita 2016 SENTIment POLarity Classification Task</article-title>
          .
          <source>In Proceedings of Third Italian Conference on Computational Linguistics</source>
          (CLiC-it
          <year>2016</year>
          ) &amp;
          <article-title>Fifth Evaluation Campaign of Natural Language Processing and Speech Tools for Italian</article-title>
          .
          <source>Final Workshop (EVALITA</source>
          <year>2016</year>
          ).
          <article-title>CEUR-WS.org</article-title>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          <string-name>
            <surname>Basile</surname>
            ,
            <given-names>V.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Croce</surname>
            ,
            <given-names>D.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Di</surname>
            <given-names>Maro</given-names>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            , &amp;
            <surname>Passaro</surname>
          </string-name>
          ,
          <string-name>
            <surname>L.</surname>
          </string-name>
          (
          <year>2020</year>
          ).
          <article-title>EVALITA 2020: Overview of the 7th Evaluation Campaign of Natural Language Processing and Speech Tools for Italian</article-title>
          .
          <source>In Proceedings of Seventh Evaluation Campaign of Natural Language Processing and Speech Tools for Italian. Final Workshop (EVALITA</source>
          <year>2020</year>
          ),
          <article-title>CEUR-WS.org</article-title>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          <string-name>
            <surname>Bennici</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          , &amp;
          <string-name>
            <surname>Portocarrero</surname>
            ,
            <given-names>X. S.</given-names>
          </string-name>
          (
          <year>2018</year>
          ).
          <article-title>Ensemble for aspect-based sentiment analysis</article-title>
          .
          <source>In Tommaso Caselli</source>
          , Nicole Novielli, Viviana Patti, and Paolo Rosso, editors,
          <source>Proceedings of the 6th evaluation campaign of Natural Language Processing</source>
          and
          <article-title>Speech tools for Italian (EVALITA'18)</article-title>
          . CEURWS.org.
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          <string-name>
            <surname>Brown</surname>
          </string-name>
          , T. B.,
          <string-name>
            <surname>Mann</surname>
            ,
            <given-names>B.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Ryder</surname>
            ,
            <given-names>N.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Subbiah</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Kaplan</surname>
            ,
            <given-names>J.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Dhariwal</surname>
            ,
            <given-names>P.</given-names>
          </string-name>
          , . . .
          <string-name>
            <surname>Amodei</surname>
            ,
            <given-names>D.</given-names>
          </string-name>
          (
          <year>2020</year>
          ,
          <article-title>July 22)</article-title>
          .
          <article-title>Language Models are Few-Shot Learners</article-title>
          . https://arxiv.org/abs/
          <year>2005</year>
          .14165
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          <string-name>
            <surname>de Mattei</surname>
          </string-name>
          , L.,
          <string-name>
            <surname>de Martino</surname>
          </string-name>
          , G.,
          <string-name>
            <surname>Iovine</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Miaschi</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Polignano</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          , &amp;
          <string-name>
            <surname>Rambelli</surname>
            ,
            <given-names>G.</given-names>
          </string-name>
          (
          <year>2020</year>
          ).
          <article-title>Overview of the EVALITA 2020 Aspect Term Extraction and Aspect-based Sentiment Analysis (ATE_ABSITA) Task. In Proceedings of the 7th evaluation campaign of Natural Language Processing and Speech tools for Italian (EVALITA 2020), CEUR-WS.org</article-title>
          .
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          <string-name>
            <surname>Ning</surname>
            ,
            <given-names>E.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Yan</surname>
            ,
            <given-names>N.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Zhu</surname>
            ,
            <given-names>J.</given-names>
          </string-name>
          , &amp;
          <string-name>
            <surname>Li</surname>
            ,
            <given-names>J.</given-names>
          </string-name>
          (
          <year>2020</year>
          , January 31).
          <article-title>Microsoft open sources breakthrough optimizations for transformer inference on GPU and CPU</article-title>
          . https://cloudblogs.microsoft.com/opensource/2020/01/21/microsoft-onnx
          <article-title>-open-sourceoptimizations-transformer-inference-gpu-cpu/</article-title>
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          <string-name>
            <surname>Polignano</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Basile</surname>
            , P., de Gemmis,
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Semeraro</surname>
            ,
            <given-names>G.</given-names>
          </string-name>
          , &amp;
          <string-name>
            <surname>Basile</surname>
            ,
            <given-names>V.</given-names>
          </string-name>
          (
          <year>2019</year>
          ).
          <article-title>Alberto: Italian bert language understanding model for nlp challenging tasks based on tweets</article-title>
          .
          <source>In Proceedings of the Sixth Italian Conference on Computational Linguistics</source>
          (CLiC-it
          <year>2019</year>
          ).
          <article-title>CEUR-WS.org</article-title>
          .
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          <string-name>
            <surname>Petroni</surname>
            ,
            <given-names>F.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Rocktäschel</surname>
            ,
            <given-names>T.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Lewis</surname>
            ,
            <given-names>P.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Bakhtin</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Wu</surname>
            ,
            <given-names>Y.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Miller</surname>
            ,
            <given-names>A. H.</given-names>
          </string-name>
          , &amp;
          <string-name>
            <surname>Riedel</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          (
          <year>2019</year>
          , September 04).
          <article-title>Language Models as Knowledge Bases? https://arxiv</article-title>
          .org/abs/
          <year>1909</year>
          .01066
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          <string-name>
            <surname>Pushp</surname>
            ,
            <given-names>P. K.</given-names>
          </string-name>
          , &amp;
          <string-name>
            <surname>Srivastava</surname>
            ,
            <given-names>M. M.</given-names>
          </string-name>
          (
          <year>2017</year>
          , December 23). Train Once, Test Anywhere:
          <article-title>Zero-Shot Learning for Text Classification</article-title>
          . https://arxiv.org/abs/1712.05972
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          <string-name>
            <surname>Schick</surname>
            ,
            <given-names>T.</given-names>
          </string-name>
          , &amp;
          <string-name>
            <surname>Schütze</surname>
            ,
            <given-names>H.</given-names>
          </string-name>
          (
          <year>2020</year>
          , April 27).
          <article-title>Exploiting Cloze Questions for Few Shot Text Classification and Natural Language Inference</article-title>
          . https://arxiv.org/abs/
          <year>2001</year>
          .07676
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>