Albert
Last updated
Was this helpful?
Last updated
Was this helpful?
๊ฐ์ธ study๋ฅผ ์ํ ์๋ฃ์ ๋๋ค. ๊ทธ๋ฌ๋ค๋ณด๋ ๋ด์ฉ์ ์๋ชป๋ ์ ์ด ์์ต๋๋ค.
๋ ผ๋ฌธ์ ์์์ 2018๋ Bert(Bidirectional Encoder Representations from Transformers)์ ๋ฑ์ฅ์ผ๋ก ์์๋, Larger Dataset, Lager Model, Pre-trained, Fine-tuning์ ๋ํ ์ด์ผ๊ธฐ๋ก ์์ํฉ๋๋ค.
Evidence from these improvements reveals that a large network is of crucial importance for achieving state-of-the-art performance (Devlin et al., 2019; Radford et al., 2019). It has become common practice to pre-train large models and distill them down to smaller ones (Sun et al., 2019; Turc et al.,2019) for real applications. Given the importance of model size, we ask: Is having better NLP models as easy as having larger models?
Large Model์ 1). Memory limitations, 2). Training speed ๊ฐ ๋จ์ ์ด ๋ฉ๋๋ค. ์ด 2๊ฐ์ง ์ ์ NLP๋ฅผ ๊ฐ์ธ PC๋จ์์์ ํ์ตํ ๊ฒฝ์ฐ, ์ง๋ฉดํ๋ ๋ฌธ์ ์ ๋๋ค.
์ด๋ฌํ ๋ฌธ์ ๋ฅผ ํ๊ธฐ์ํด์๋ 1) model parallelization, 2) clever memory management ๊ณผ ๊ฐ์ ํ์ ๋ ์์์ ์ ์ฌ์ฉํ๋ ๋ฐฉ๋ฒ์ ์ฌ์ฉํ ์๋ ์์ต๋๋ค. ํ์ง๋ง, ๋ณธ ๋ ผ๋ฌธ ์ฒ๋ผ, model architecture๋ฅผ ์๋ก ๋์์ธํ๋ ๋ฐฉ๋ฒ์ ์ ์ํฉ๋๋ค.
A Lite BERT (ALBERT) ์์ ์ฌ์ฉํ main ๋ฐฉ๋ฒ์ ์๋ 2๊ฐ์ง ์ ๋๋ค.
The first one is a factorized embedding parameterization.
The second technique is cross-layer parameter sharing
์ ๋ ๋ฌธ์ฅ์ ์ค๋ช ํ๊ธฐ ์ํด์๋ ๊ฐ๋จํ BERT์ paramter์๋ฅผ ์ดํด ๋ณผ ํ์๊ฐ ์์ต๋๋ค.[]
Embedding layer = 23M
Transformer layer = 7M * 12 = 85M
Pooler layer = 0.6M
Total = 110M
๋ณธ ๋ ผ๋ฌธ์์ ์ ์ํ๋ ๋ฐฉ๋ฒ์ผ๋ก, ์๋์ ๊ฐ์ด parameter์ ์๋ฅผ ์ฝ 90% ๊ฐ์์ํต๋๋ค.~!
Embedding layer = 4M (factorized embedding)
Transformer layer = 7M (cross-layer parameter sharing)
Pooler layer = 0.6M
Total = 12M
Larger Dataset, Lager Model, Pre-trained, Fine-tuning ์์ large model์ด performance์ ์ค์ํ์ง๋ง, memory limitation๊ณผ training speed์์ ๋ฌธ์ ๊ฐ ์๋ค๊ณ ๋ค์ ์ธ๊ธํฉ๋๋ค.
paramter sharing์ ์ ์ฉํ ์ด์ ๋ ผ๋ฌธ๋ค์ ๋ฐฉ๋ฒ์ ๋ํด์ ์ธ๊ธํฉ๋๋ค.
๋ณธ ๋ ผ๋ฌธ์์ ์ ์ํ๋ 3๋ฒ์งธ element ์ค ํ๋์ธ SENTENCE ORDER PREDICTION (SOP) ์ ๋ํด ์ค๋ช ํฉ๋๋ค. 2 sentence pair ๋ฅผ ํ์ตํ๋ ๋ฐฉ๋ฒ์์, false ์์ ๋ฅผ ๋ง๋ค์ด๋ด๋ ๋ฐฉ์์ ์ฐจ์ด๋ฅผ ๋ก๋๋ค. BERT ๋ ๋ค๋ฅธ ๋ฌธ์์ ๋ฌธ์ฅ์ 2nd sentence๋ก ์ฌ์ฉ(NSP)ํ์ง๋ง, ALBERT์์๋ ์ธ์ ํ ๋ ๋ฌธ์ฅ์ order๋ฅผ swap(SOP)ํฉ๋๋ค. ์์ธํ ๋ด์ฉ์ 3์ฅ์ ๋ค์ ์ธ๊ธ๋ฉ๋๋ค.
ALBERT uses a pretraining loss based on predicting the ordering of two consecutive segments of text.
BERT (Devlin et al.,2019) uses a loss based on predicting whether the second segment in a pair has been swapped with a segment from another document.
ALBERT์ main idea๋ฅผ ์๊ฐํฉ๋๋ค.
BERT์ ๊ทธ ํ์ model๋ค์์, WordPices embedding size $E$
์ hidden layer size $H$
๋ ๊ฐ์ต๋๋ค. ํ์ง๋ง, ์ด๋ modeling์ด๋ ์ค์ ๊ตฌํ ์ธก๋ฉด์์ ์ข์ ์ ํ์ด ์๋๋๋ค.
WordPiece embedding layer์ ๊ฒฝ์ฐ, context-independent ํ ๋ฐฉ์์
๋๋ค. ๊ทธ ์ดํ์ ์์ด๋ Transformer layer๋ context-dependent ํ layer์ด๋ฉฐ, BERT์ ๋ฐ์ด๋ performance๋ ์ด ๋ถ๋ถ์์ ๋์ต๋๋ค. ๋ฐ๋ผ์, E์ H๋ฅผ ๋ถ๋ฆฌํ๊ณ $H >> E$
๊ฐ ๋๋๋ก settingํ๋ ๊ฒ์ด ๋ ํฉ๋ฆฌ์ ์
๋๋ค. ๋ํ vocabulary size $V$
๊ฐ ๋งค์ฐ ํฌ๊ธฐ ๋๋ฌธ์, $E=H$
์ ์ ํ์ ์ฑ๋ฅ ํฅ์์ ์ํด, H๋ฅผ ์ฆ๊ฐ์ํฌ ๊ฒฝ์ฐ, embedding matrix์ size๋ฅผ ๋งค์ฐ ํฌ๊ฒ ๋ง๋ค์ด ๊ตฌํ์ ์ด๋ ต๊ฒ ํฉ๋๋ค.
ALBERT์์๋ ์ด๋ฅผ ์ํด, one hot vector์ธ vocabulary $V$
๋ฅผ embedding size $E$
๋ก mapping ์ํจํ, ์ด๋ฅผ ๋ค์ hidden size $H$
๋ก mappingํ๋ ๋ฐฉ์์ ์ฌ์ฉํฉ๋๋ค. ์ด๋ฅผ ํตํด, embedding layer parameter๋ 83% ๊ฐ์ํฉ๋๋ค.
BERT: $V\times H\ =\ 23M$
ALBERT: $V\times E(128)\ +\ E\times H\ =\ 4M$
Cross-layer parameter sharing์ Transformer layer์์ parameter๋ 92%๊ฐ๋ ์ค์์ต๋๋ค.
BERT: $7M\ \times 12\ layers\ =\ 85M$
ALBERT: $7M = 7M$
Masked Language Modeling(MLM) loss ์ ์ถ๊ฐํ์ฌ, BERT์์๋ Next-Sentence Prediction(NSP) loss๋ฅผ ์ฌ์ฉํฉ๋๋ค. ์ด๋ฌํ NSP๋ NLI์ ๊ฐ์ downstream task์ ์ฑ๋ฅ ํฅ์์ ์ํด ๊ณ ์๋์์ต๋๋ค.
ํ์ง๋ง, ์ดํ ์ฐ๊ตฌ์์, NSP์ ํจ๊ณผ๊ฐ ๋ณ๋ก ์๋ ๊ฒ์ฒ๋ผ ๋์ค๋ ์ฐ๊ตฌ๊ฐ ์์์ต๋๋ค. ์ด๋ฌํ NSP ๋น ํจ์จ์ ๋ํ ์์ธ์ผ๋ก ๋ณธ๋ ผ๋ฌธ์์๋ lack of difficulty ๋ฅผ ๋ค๊ณ ์์ต๋๋ค. ๋ค๋ฅธ document์ sentence๋ฅผ ์ฌ์ฉํ NSP๋, โtopic prediction"๊ณผ โcoherence predictionโ 2 task์ ํฉ์ผ๋ก ๋ณผ ์ ์์ต๋๋ค. โtopic prediction"์ โcoherence prediction"์ ๋นํด ์ฌ์ฐ๋ฉฐ, ์ด ๋๋ค ๋ชจ๋ MLM loss์ ํฌํจ๋๋ค๊ณ ๋์ด ์์ต๋๋ค.
NSP conflates topic prediction and coherence prediction in a single task. However, topic prediction is easier to learn compared to coherence prediction, and also overlaps more with what is learned using the MLM loss.
๋ณธ ๋ ผ๋ฌธ์์๋ inter-sentence modeling์ ์ํด์, Sentence-Order prediction(SOP)๋ฅผ ์ฌ์ฉํฉ๋๋ค. SOP๋ฅผ ํตํด, topic prediction ๋ณด๋ค๋ inter-sentence coherence๋ฅผ ํฌ์ปค์ค๋ฅผ ๋ง์ถ ์ ์์ต๋๋ค. ๊ทธ๋ฆฌ๊ณ ์คํ์ ์ผ๋ก, NSP๋ก SOP ๊ด๋ จ task๋ฅผ ์ ํ์ ์์ง๋ง, SOP๋ก๋ NSP ๊ด๋ จ task๋ฅผ ์ ํ์ ์์์ ๋ณด์ฌ์ค๋๋ค.
BPE(Byte-Pair Encoding): characters ๋จ์์์ ์์ํด์, desired size ๊ฐ ๋์ฌ ๋๊น์ง merge ํฉ๋๋ค. merge์ ๊ธฐ์ค์ ๋์ค๋ ๋น๋์ ์ ๋๋ค.
WordPiece: BPE์ ๋น์ทํ์ง๋ง, merge์ ๊ธฐ์ค์ด likelihood์ ์ต๋ํ ์ ๋๋ค. BERT, DistilBERT์์ ์ฌ์ฉํ์ต๋๋ค.
Unigram: ์์์ด BPE, WordPiece์ ๋ค๋ฅด๊ฒ, corpus์์ ์์ํ์ฌ word๋ฅผ ์ชผ๊ฐ์๋ฉด์ ์งํํฉ๋๋ค. ์ชผ๊ฐ๋ ๊ธฐ์ค์ loss๋ฅผ ์ต์ํ ํ๋ ๊ฒ์ ๋๋ค.
sentencePiece: ์์ ๋ฐฉ๋ฒ๋ค์ ๋ชจ๋ pretokenization์ ์๊ตฌํฉ๋๋ค. ํ์ง๋ง ์ผ๋ถ ์ธ์ด์์๋ space๊ฐ ์์ด pretokenization์ด ์ด๋ ต์ต๋๋ค. sentencePiece์์๋ space๋ ํ๋์ character๋ก ์ธ์งํฉ๋๋ค. ์ด ๋ฐฉ๋ฒ์ de-coding์ด ์ฌ์ ์ฅ์ ์ด ๋๊ธฐ๋ ํฉ๋๋ค. ALBERT, XLNet์์ setencePiece + unigram์ ์ฌ์ฉํ์ต๋๋ค.
ALBERT-xxlarge๊ฐ less parameter๋ก BERT-large ๋ณด๋ค ์ข์ ์ฑ๋ฅ์ ๋ณด์์ง๋ง, structure์ ํฌ๊ธฐ๊ฐ ํฌ๊ธฐ ๋๋ฌธ์ computationally ๋ ๋น์ผ ๋ฐฉ๋ฒ์ ๋๋ค. ์ด์ ๋ฐ๋ผ, training๊ณผ imference speed up์ ๋ค์ ๊ฐ์ ์ ์ค์ ํฌ์ธํธ ์ง์ ํ์ต๋๋ค. ๋ํ SOP๊ฐ language representation์ ์์ด์ ์กฐ๊ธ ๋ ์ข์ ๋ฐฉ๋ฒ์ด๋ผ๋ ๊ฒ์ ์ฆ๋ช ํ์ง๋ง, ๋ ์ข์ ๋ฐฉ๋ฒ์ด ์์ ๊ฑฐ๋ผ๊ณ ์ด์ผ๊ธฐํ๋ฉด์ ๋ ผ๋ฌธ์ ๋๋์ต๋๋ค
์ด๋ฌํ model ์์ถ์ ๋ํด์๋ []์ ์ ์ ๋ฆฌ๋์ด ์์ต๋๋ค.
Parameter sharing์ ๊ฐ์ parameter๋ฅผ ์๋ก ๋ค๋ฅธ ์์น์์ ์ฌ์ฉํ๋ ๋ฐฉ๋ฒ์ ๋๋ค. Parameter sharing์ ์ด๋ ๋ถ๋ถ์ sharing ํ๋์ ๋ฐ๋ผ ๋ค์ํ ๋ฐฉ๋ฒ์ด ์์ง๋ง, ALBERT์์๋ Transformer layer ์ ์ฒด๋ฅผ share ํฉ๋๋ค. ์ด๋ฌํ parameter sharing์ parameter ์ ์์ฒด ๊ฐ์์๋ ์ฅ์ ์ด ์์ง๋ง, network์ ์์ ํ์๋ ๋์์ด ๋๋ค๊ณ ํฉ๋๋ค.
์ table๊ณผ ๊ฐ์ด ๊ฐ์ hyper parameter์์ ALBERT๋ BERT ๋๋น ๋ฐ์ด๋ parameter ๊ฐ์๋ฅผ ๋ณด์ฌ ์ค๋๋ค. ์ดํ 4์ฅ ์คํ์์๋ ์ด๋ฌํ parameter ๊ฐ์๊ฐ performance ๊ฐ์๋ก ์ด์ด์ง์ง ์๋ ์ ์ ๋ณด์ฌ์ค๋๋ค. ๊ฒฐ๊ตญ ALBERT์ parameter efficiency ํฅ์์ ALBERT-xxlarge์ ๊ฐ์ ๋ ๋ฐ์ด๋ performance๋ฅผ ๋ณด์ฌ์ฃผ๋ ๊ฒ๋ ๊ฐ๋ฅํ๊ฒ ํฉ๋๋ค.
BERT์์ ์ฌ์ฉํ ํ๊ฒฝ์ ์ต๋ํ ๋ฐ๋ฆ ๋๋ค. ๊ฐ์ธ์ ์ผ๋ก tokenizer๋ก SentencePiece๋ฅผ ์ฌ์ฉํ ์ ์ ๋๋ค. ๊ฐ๋จํ tokenizer์ ๋ํด์ ์ ๋ฆฌํ๋ฉด ์๋์ ๊ฐ์ต๋๋ค.[]
์ ์ฅ์์ ์ค๋ช ํ parameter efficiency ํฅ์์ผ๋ก, ALBERT-xxlarge๋ 70%์ parameter๋ก BERT-large ๋๋น ์ข์ ์ฑ๋ฅ์ ๋ณด์ ๋๋ค. ๋ํ, ALBERT์ parameter ๊ฐ์๋ training time์์๋ ํฐ speedup์ ๋ณด์ ๋๋ค.
embedding size์ ๋ฐ๋ฅธ ์ํ์์๋, ์์์ ํ ๊ฐ์ค๊ณผ ๊ฐ์ด ํฐ ์ฐจ์ด๊ฐ ์์์ ๋ณด์ ๋๋ค. all-sahred case์์ ๊ฐ์ฅ ์ข์ ์ฑ๋ฅ์ ๋ณด์ธ, 128์ baseline์ผ๋ก ์ค์ ํ์์ต๋๋ค.
all-shared case์์ performance drop์ด ๋ํ๋ฉ๋๋ค. ๋ํ FFN share์ ๊ฒฝ์ฐ, performance drop์ด ํฌ๋ฉฐ, attention share์ ๊ฒฝ์ฐ performance drop์ด ๋ฎ์ต๋๋ค. ์ ์ฒด์ ์ผ๋ก parameter ๊ฐ์์ ๋นํด, performance drop์ด ํฌ์ง ์๋ค๊ณ ํ๋จํ์ฌ, all-shared๋ฅผ default๋ก ์ ํํ์ต๋๋ค.
NSP์ ๊ฒฝ์ฐ, SOP task์์ ๋งค์ฐ ๋ฎ์ ์ ํ๋๋ฅผ ๋ณด์ ๋๋ค.(None ๋ณด๋ค ๋ฎ์ต๋๋ค.) ํ์ง๋ง, SOP์ ๊ฒฝ์ฐ, NSP task์์ ์ ์๋ฏธํ ๊ฒฐ๊ณผ๋ฅผ ๋ณด์ฌ ์ค๋๋ค. ๊ฒฐ์ ์ ์ผ๋ก, downstream task์์ SOP๊ฐ ํ๊ท 1% ์ ๋์ ๋ ์ข์ performance๋ฅผ ๋ณด์ ๋๋ค.