๐ฅซ [ELMo ๋ ผ๋ฌธ ๋ฆฌ๋ทฐ] Deep contextualized word representations
โจ ์ฒ์ ์์ํ๋ ์์ฐ์ด์ฒ๋ฆฌ ๋ ผ๋ฌธ ์ฝ๊ธฐ์ ์ฒซ ๊ธ์ ๋๋ค. ์ด๋ฒ ๊ธ์์ ๋ค๋ฃฐ ๋ ผ๋ฌธ์ 2018๋ ์ ๊ฒ์ฌ๋ Deep Contextualized Word Representations์ ๋๋ค. ELMo๋ผ๋ ์ด๋ฆ์ ๊ฐ์ง ๋ชจ๋ธ์ ๋๋ค.
1. Backgrounds
์ฌ์ ํ์ต๋ word representations์ ์์ฐ์ด ์ฒ๋ฆฌ ์์ ์ ์ฌ์ฉ๋๊ธฐ ์ ๋๊ท๋ชจ ์ฝํผํธ์์ ํ์ตํ ๋จ์ด ์๋ฒ ๋ฉ์ ์ผ์ข ์ด๋ค. ์ด๋ฌํ ํํ์ ๋ง์ neural language ๋ชจ๋ธ์์ ์ค์ํ ๊ตฌ์ฑ ์์์ด๋ค. ๊ทธ๋ฌ๋ ๊ณ ํ์ง์ representation์ ํ์ตํ๋๋ฐ 2๊ฐ์ง ์ด๋ ค์์ด ์๋ค.
- ๊ตฌ๋ฌธ ๋ฐ ์๋ฏธ๋ก ๊ณผ ๊ฐ์ ๋จ์ด ์ฌ์ฉ์ ๋ณต์กํ ํน์ฑ์ ๋ชจ๋ธ๋งํ๋ ๊ฒ
- ๋ค์์ด์ ๊ฐ์ด ๋ฌธ๋งฅ์ ๋ฐ๋ผ ์๋ฏธ๊ฐ ๋ณํํ๋ ๊ฒ
ํ๋์ฉ ์ดํด๋ณด์๋ฉด,
๊ตฌ๋ฌธ ๋ฐ ์๋ฏธ๋ก ์ด๋ ์๋ฏธ๋ก๋ ์์ ๋ฅผ ์๋ก ๋ค ์ ์๋ค. I read a book yesterday.์์ read๋ ์ฝ์๋ค๋ผ๋ ์๋ฏธ์ด๋ค. I will read a book today.์ read๋ ์ฝ์ ๊ฒ์ด๋ค๋ผ๋ ์๋ฏธ์ด๋ค. ์ฐ๋ฆฌ๋ ์ด๋ป๊ฒ ๊ฐ์ ๋จ์ด์ธ๋ฐ read๋ฅผ ๋ค๋ฅด๊ฒ ํด์ํ ๊น? ๋ค์ ์๋ yesterday์ today๋ฅผ ํตํด ์ ์ถํ์ ๊ฒ์ด๋ค.
๋ค์์ด๋ก๋ ๊ฐ์ ๋จ์ด์ด์ง๋ง ์ ํ ๋ค๋ฅธ ์๋ฏธ๋ก ์ฐ์ด๋ ๊ฒฝ์ฐ๋ฅผ ๋งํ๋ค. capital gain์ capital์ ์๋ณธ์ด๋ ์๋ฏธ๋ฅผ ๊ฐ๋๋ค. capital city์ capital์ ์๋์ ์๋ฏธ๋ฅผ ๊ฐ๋๋ค.
์ด๋ ๊ฒ ๊ฐ์ ๋จ์ด๋ผ๋ ๋ค๋ฅด๊ฒ ์ฐ์ด๋ ๊ฒฝ์ฐ๊ฐ ๋ง์ง๋ง word embedding์ ๊ฒฝ์ฐ, ์ด๋ฐ ๋ฌธ์ ๋ฅผ ํด๊ฒฐํด์ฃผ์ง ๋ชปํ๋ค.
2. Related work
ํ์ ๋จ์ด ์ ๋ณด๋ก ๊ฐํํ๊ฑฐ๋ ๊ฐ ๋จ์ด ์๋ฏธ์ ๋ํด ๋ณ๋์ ๋ฒกํฐ๋ฅผ ํ์ตํ๋ ๋ฐฉ๋ฒ์ด ์ ์๋์๋ค. ๋ ๋ค๋ฅธ ์ฐ๊ตฌ๋ก context-dependent representation์ ์ง์คํ context2vec, pivot ๋จ์ด๋ฅผ representation์ ํฌํจํ supervised neural machine translation๊ณผ unsupervised language model๋ค์ด ์๋ค. ELMo ๋ชจ๋ธ์ ์ด ์ฐ๊ตฌ๋ค์ ์ฅ์ ์ ์ต๋ํ ํ์ฉํ๋ฉฐ ์ฝ 30๊ฐ๋ก ๊ตฌ์ฑ๋ corpus์์ biLM์ ํ์ตํ๋ค.
3. ELMo: Embeddings from Language Models
ELMo๋ ๋จ์ด๋ฅผ ๊ณ ์ ๋ฒกํฐ๋ก ํํํ๋ ๊ธฐ์กด ๋จ์ด embedding๊ณผ ๋ค๋ฅด๊ฒ ์ ์ฒด ๋ฌธ์ฅ์ ์ ๋ ฅ์ผ๋ก ๊ณ ๋ คํ๊ณ ๊ตฌ๋ฌธ ๋ฐ ์๋ฏธ๋ก ๊ณผ ๊ฐ์ ๋จ์ด ์ฉ๋์ ๋ณต์กํ ํน์ฑ์ ํฌ์ฐฉํ๋ค. ์ด๋ ๊ธ์์์ค ํฉ์ฑ๊ณฑ์ ํฌํจํ๋ 2๊ณ์ธต biLM์ ๊ธฐ๋ฐ์ผ๋ก ๊ณ์ฐ๋๋ฉฐ, biLM์ ๋ด๋ถ์์๋ ELMo word representation์ ๊ณ์ฐํ๋ ์ ํ ํจ์๋ก ์ฌ์ฉ๋๋ค. ์ด๋ก ์ธํด ์ฝ๊ฒ ๋ค๋ฅธ NLP ๋ชจ๋ธ์ ๋ถ์ด๋ ๊ฒ์ด ๊ฐ๋ฅํ๋ค.
3.1 Bidirectional language models(biLM)
N๊ฐ์ token(\(t_1, t_2, ..., t_N\))์ด ์๋ค๊ณ ํ ๋, Forward Language Model์ \((t_1,t_2, ..., t_{k_1})\)์ด ์ฃผ์ด์ก์ ๋ \(t_k\)๊ฐ ๋์ฌ ํ๋ฅ ์ ๊ณ์ฐํ๋ค.
๋ฌธ์ฅ์ด ์ฃผ์ด์ก์ ๋, ๋จ์ด๋ character ์๋ฒ ๋ฉ์ผ๋ก representation๋ ๋ค, ์ฒซ LSTM ์ ๋ก ์ ๋ ฅ๋๋ค. character ์๋ฒ ๋ฉ์ผ๋ก ์ ํ๋๋ ์ด์ ๋ 2๊ฐ์ง์ด๋ค.
- ์ต์ด ์๋ฒ ๋ฉ์ ๋ฌธ๋งฅ์ ์ํฅ์ ๋ฐ์ง ์์์ผ ํ๋ค.
- ์ ํ ํ์ต๋ ๋จ์ด ์๋ฒ ๋ฉ์ ์ฌ์ฉํ ๋ชจ๋ธ๊ณผ ๋น๊ตํ๊ธฐ ์ํด Glove๋ Word2Vec๊ณผ ๊ฐ์ ๋จ์ด ์๋ฒ ๋ฉ์ ์ฌ์ฉํ์ง ์์๋ค.
์ ๋ ฅ๋จ์์ ๋ฌธ๋งฅ์ ์ํฅ์ ๋ฐ์ง ์์์ง๋ง layer๋ฅผ ์ง๋์น ์๋ก ๋ฌธ๋งฅ์ ์ํฅ์ ๋ฐ๋๋ก ์ค๊ณ๋์๋ค. ์ฒซ LSTM ์ถ๋ ฅ์ char ์๋ฒ ๋ฉ๊ณผ residual connection์ ๊ฐ์ง๊ณ ์๋ค. residual connection์ 2๊ฐ์ง ์ฅ์ ์ ๊ฐ์ง๊ณ ์๋ค.
- ์์ layer๋ค์ด ํ์ layer์ ํน์ง์ ์์ง ์์์ผ ํ๋ค.
- gradient descent๋ฅผ ํตํ gradient vanishing ํ์์ ๊ทน๋ณตํ๋๋ก ๋์์ค๋ค.
L๊ฐ์ layer์ ์ ๋ฌ ํ softmax layer๋ก ๋ค์ token์ ์์ธกํ๋๋ฐ ์ฌ์ฉ๋๋ค.
Backward Language Model์ Forward Language Model๊ณผ ์์ ํํ๋ ๊ฐ์ง๋ง ๋ค์ชฝ token์ ์ฌ์ฉํด ์์ token์ ํ๋ฅ ์ ๊ณ์ฐํ๋ค.
biLM์ ๋ ๋ฐฉํฅ์ log likelyhood๋ฅผ ์ต๋ํ ์ํค๋ ๋ฐฉํฅ์ผ๋ก ํ์ต์ ์งํํ๋ค.
\(\Theta_x\)๋ token representation, \(\Theta_s\)๋ softmax layer๋ก Forward, Backward์์ ํ๋ผ๋ฏธํฐ๋ฅผ ๊ณต์ ํจ์ผ๋ก์จ ๋ชจ๋ธ์ ๋ณต์ก์ฑ์ ์ค์ด๊ณ ํ์ต์ ๊ฐ์ ํ๋ค.
3.2 ELMo
๋ LSTM(Forward, Backward)์ layer representation์ ๊ฒฐํฉ์ด๋ค. ๊ฐ ํ ํฐ \(t_k\)์ ์๋ฒ ๋ฉ ๋ฒกํฐ๋ก L-layer biLM๊ณผ token layer๋ฅผ ์ฌ์ฉํ๊ฒ ๋๋ฉฐ 2L+1๊ฐ์ representation์ผ๋ก ์ด๋ฃจ์ด์ง๋ค.
๋จผ์ , Forward, Backward LM layer๋ฅผ ๊ฐ layer๋ณ๋ก concatenateํ ๋ค์ ๊ฐ์ค์น๋ฅผ ์ค ๋ค ๋ํ ํ scalar parameter \(\gamma^{task}\)๋ก ๋ฒกํฐ์ ํฌ๊ธฐ๋ฅผ ์กฐ์ ํ๋ฉฐ ์ต์ ํ ๊ณผ์ ์์ ์ค์ํ ์ญํ ์ ํ๋ค.
3.3 Using biLMs for supervised NLP tasks
biLM์ ์ฌ์ฉํ์ฌ task model์ ๊ฐ์ ํ๊ธฐ ์ํด์ ์๋์ ๊ฐ์ ๊ณผ์ ์ ์งํํ๋ค.
- ๋ชจ๋ ๋จ์ด์ layer representation์ ๊ธฐ๋กํ๋ค.
- \((t_1, t_2, ..., t_k)\)์ด ์ฃผ์ด์ก์ ๋ ๋จ์ด embedding ๋๋ ์ ํ์ ์ผ๋ก character ๊ธฐ๋ฐ์ representation์ ์ฌ์ฉํ๋ค.๊ทธ๋ฌ๋ฉด context์ ๋ฏผ๊ฐํ representation \(h_k\)๊ฐ ํ์ฑ๋๋ค.
supervised model์ ELMo๋ฅผ ์ถ๊ฐํ๊ธฐ ์ํด์
- biLM์ ๊ฐ์ค์น๋ฅผ ๊ณ ์ ์ํจ๋ค.
- ELMo vector \(ELMo_k^{task}\)์ \(x_k\)๋ฅผ concatenateํ๋ค.
- task RNN์ ์ ๋ฌํ๋ค.
๋ง์ง๋ง์ผ๋ก, ELMo์ ์ ๋นํ ์์ dropout์ ์ถ๊ฐํ๋ ๊ฒ์ด ํจ๊ณผ์ ์ด์์ผ๋ฉฐ ์ผ๋ถ์ ๊ฒฝ์ฐ๋ก๋ loss์ \(\lambda||w||^2_2\)๋ฅผ ์ถ๊ฐํ์ฌ ELMo ๊ฐ์ค์น๋ฅผ ์ ๊ทํํ๋ ๊ฒ์ด ELMo ๊ฐ์ค์น๊ฐ ๋ชจ๋ biLM ๋ ์ด์ด์ ํ๊ท ์ ๊ฐ๊น๋๋ก ์ ๋๋์ด ์ ์ฉํ ๊ฒฐ๊ณผ๋ฅผ ์ป๋๋ค๋ ๊ฒ์ ๋ฐ๊ฒฌํ๋ค.
3.4 Pre-trained bidirectional language model architecture
์ด ๋ ผ๋ฌธ์์ ์ฌ์ฉ๋ pre-trained biLM์ ozefowicz et al. (2016)๊ณผ Kim et al. (2015)์ ์ํคํ ์ฒ์ ์ ์ฌํ์ง๋ง ์๋ฐฉํฅ ํ์ต๊ณผ LSTM layer ๊ฐ์ residual connection์ ์ถ๊ฐํ์๋ค.
character ๊ธฐ๋ฐ ์ ๋ ฅ representation์ ์ ์งํ๋ฉด์ ์ ์ฒด language model์ ๋ณต์ก์ฑ๊ณผ downstream ์์ ์ ๋ํ ๊ณ์ฐ ์๊ตฌ๋์ ๋ง์ถ๊ธฐ ์ํด CNN-BIG-LSTM์ ๋ชจ๋ ์๋ฒ ๋ฉ ๋ฐ hidden dimension์ ์ ๋ฐ์ผ๋ก ์ค์๋ค.
๊ทธ ๊ฒฐ๊ณผ 4096๊ฐ์ unit๊ณผ 512 ์ฐจ์์ projection layer, 1๋ฒ์งธ layer์์ 2๋ฒ์งธ layer๋ก์ residual connection์ ์ฌ์ฉํ์๋ค. ๋ฌธ๋งฅ์ ๋ฌด๊ดํ representation์ 2048๊ฐ์ ๋ฌธ์ n-gram convolution filter๋ฅผ ์ฌ์ฉํ๊ณ ์ด๋ฅผ 2๊ฐ์ highway layer์ 512 representation์ linear projection์ด ์ด์ด์ง๋ค.
๊ทธ ๊ฒฐ๊ณผ, biLM์ ๋ฌธ์ ์ ๋ ฅ์ผ๋ก ์ธํด ํ์ต์ ์ ๋ฒ์ด๋๋ ๊ฒ์ ํฌํจํ 3๊ฐ์ representaion layer๋ฅผ ์ ๊ณตํ๋ค.
์ด๋ฒ ๊ธ์์๋ 2018๋ ์ ๊ฒ์ฌ๋ ELMo ๋ ผ๋ฌธ์ ์ดํด๋ณด์์ต๋๋ค. ๋ฌธ๋งฅ์ ์ดํดํ๋ sentence representation์ ๋ํด ์๋กญ๊ฒ ์๊ฒ ๋์ด ํฅ๋ฏธ๋ก์ ์ต๋๋ค. ๋ค๋ง, ์์ฃผ ๋ฑ์ฅํ์ง ์๋ ๋จ์ด๋ค์ด ๋ฌธ๋งฅ์ ํฌํจํ์ฌ ํ์ตํ ์ ์๋์ง ๊ถ๊ธํด์ง๋ค์. ๊ธด ๊ธ ์ฝ์ด์ฃผ์ ์ ๊ฐ์ฌํฉ๋๋ค!๐ฅ