BERT model optimization methods for inference : a comparative study of five alternative BERT-model implementations
Buuri, Marko (2022)
Diplomityö
Buuri, Marko
2022
School of Engineering Science, Tuotantotalous
Kaikki oikeudet pidätetään.
Julkaisun pysyvä osoite on
https://urn.fi/URN:NBN:fi-fe2022121270782
https://urn.fi/URN:NBN:fi-fe2022121270782
Tiivistelmä
Previous years have seen the rise of Transfer Learning approaches in Natural Language Processing (NLP) with large-scale pre-trained language models becoming a basic tool in many NLP tasks. Even though larger models generally lead to significant improvements, they often have several million parameters which can raise concerns.
BERT models are natural language processing models base on Transformer-architecture, which have been proven effective. The aim of this master thesis is to introduce different BERT base named entity recognition model inference optimization methods, which can be implemented to reduce the model’s size and improve its throughput without compromising its accuracy. In literature review best possible methods from previous studies are find out, which have been used to increase models’ computational efficiency and not reducing their accuracies.
In implementation five different BERT models were tested with CoNLL-2003 data and results show that part of these models were able to have better performance. Models we compared with each other especially concentrating on their F1-scores and total time used in inference. As a base model BERT-base was used. Results partly showed that the models’ performance and accuracies for Distill RoBERTa achieved to perform better with F1-score of 96.74 % compared to the BERT-base with F1-score of 95.98 % and used half of time compared to the initial BERT-base model. Improvements can be seen by evaluating F1-scores and time used inference, but some of the models did not perform better like DistillBERT, compared to the base model as expected base on the literature. Aiempina vuosina on nähty Transfer Learning -lähestymistapojen nousu luonnollisen kielen käsittelyssä (NLP) ja laajamittaisista esikoulutetuista kielimalleista on tullut perustyökalu monissa NLP-tehtävissä. Vaikka suuret mallit johtavat yleensä merkittäviin parannuksiin, niissä on usein useita miljoonia parametreja, jotka voivat tuottaa haasteita.
BERT-mallit ovat Transformer-arkkitehtuurilla toteutettu kielenmallinnusjärjestelmiä, jotka ovat osoittautuneet tehokkaiksi kielimalleiksi. Tässä diplomityössä esitetään keinoja, jolla voidaan parantaa BERT-mallein nimetty kohteen tunnistamisen inferenssiä. Näillä menetelmillä voidaan hyödyntää pienetäkseen mallien kokoa ja parantaa niiden suoritustehoa pienentämättä merkittävästi mallin tarkkuutta. Kirjallisuuskatsauksessa selvitetään aikaisemmista tutkimuksista parhaita mahdollisia menetelmiä, joita on hyödynnetty mallin laskentatehokkuuden parantamiseen pienentämättä kuitenkaan niiden tarkkuutta.
Toteutuksessa viiden erilaisen BERT-mallin toimivuutta on testattuja CoNLL-2003 datalla. Mallien toimivuuksien tuloksia, etenkin F1-tulosta, joka mittaa mallin tarkkuutta, ja malleihin käytettyä aikaa on verrattu toisiinsa. Alkuperäisenä mallina käytettiin BERT-base mallia. Tulokset osoittavat testatuista BERT-malleista, että Distill RoBERTa onnistui suoriutumaan paremmin saavuttamalla F1-tuloksen 96.74 % ja puolet vähemmällä ajalla kuin alkuperäinen malli BERT-base F1-tuloksella 95.98 %. Parannuksia voidaan huomata tarkastelemalla F1-tuloksia ja käytettyä aikaa inferenssissä. mutta osa malleista, kuten DistillBERT, eivät tuottaneet parannuksia tarkkuudessa eikä ajassa lähtökohtaan kuten kirjallisuuskatsauksen perusteella oli odotettavissa.
BERT models are natural language processing models base on Transformer-architecture, which have been proven effective. The aim of this master thesis is to introduce different BERT base named entity recognition model inference optimization methods, which can be implemented to reduce the model’s size and improve its throughput without compromising its accuracy. In literature review best possible methods from previous studies are find out, which have been used to increase models’ computational efficiency and not reducing their accuracies.
In implementation five different BERT models were tested with CoNLL-2003 data and results show that part of these models were able to have better performance. Models we compared with each other especially concentrating on their F1-scores and total time used in inference. As a base model BERT-base was used. Results partly showed that the models’ performance and accuracies for Distill RoBERTa achieved to perform better with F1-score of 96.74 % compared to the BERT-base with F1-score of 95.98 % and used half of time compared to the initial BERT-base model. Improvements can be seen by evaluating F1-scores and time used inference, but some of the models did not perform better like DistillBERT, compared to the base model as expected base on the literature.
BERT-mallit ovat Transformer-arkkitehtuurilla toteutettu kielenmallinnusjärjestelmiä, jotka ovat osoittautuneet tehokkaiksi kielimalleiksi. Tässä diplomityössä esitetään keinoja, jolla voidaan parantaa BERT-mallein nimetty kohteen tunnistamisen inferenssiä. Näillä menetelmillä voidaan hyödyntää pienetäkseen mallien kokoa ja parantaa niiden suoritustehoa pienentämättä merkittävästi mallin tarkkuutta. Kirjallisuuskatsauksessa selvitetään aikaisemmista tutkimuksista parhaita mahdollisia menetelmiä, joita on hyödynnetty mallin laskentatehokkuuden parantamiseen pienentämättä kuitenkaan niiden tarkkuutta.
Toteutuksessa viiden erilaisen BERT-mallin toimivuutta on testattuja CoNLL-2003 datalla. Mallien toimivuuksien tuloksia, etenkin F1-tulosta, joka mittaa mallin tarkkuutta, ja malleihin käytettyä aikaa on verrattu toisiinsa. Alkuperäisenä mallina käytettiin BERT-base mallia. Tulokset osoittavat testatuista BERT-malleista, että Distill RoBERTa onnistui suoriutumaan paremmin saavuttamalla F1-tuloksen 96.74 % ja puolet vähemmällä ajalla kuin alkuperäinen malli BERT-base F1-tuloksella 95.98 %. Parannuksia voidaan huomata tarkastelemalla F1-tuloksia ja käytettyä aikaa inferenssissä. mutta osa malleista, kuten DistillBERT, eivät tuottaneet parannuksia tarkkuudessa eikä ajassa lähtökohtaan kuten kirjallisuuskatsauksen perusteella oli odotettavissa.