LLM์ ์ญ์ฌ | A History of Large Language Models
๐ Distributed Representation์์ Transformer, RLHF๊น์ง ํ์ฌ์ LLM์ ๋ง๋ ์ฐ๊ตฌ๋ค์ ์์๋๋ก ์ดํด๋ด ๋๋ค.
KEYWORDS
LLM, LLM ์ญ์ฌ, LLM์ด๋, LLM ์ธ๊ณต์ง๋ฅ ๋ป, ๋๊ท๋ชจ ์ธ์ด ๋ชจ๋ธ, Language Model, ๋ถ์ฐ ํํ, Word Embedding, Word2Vec, Attention, Transformer, Attention is all you need, RLHF, Bengio 2003, ์ดํ ์ ์ด๋, ํธ๋์คํฌ๋จธ ๋ ผ๋ฌธ๋ฆฌ๋ทฐ
Introduction
- ๋๊ท๋ชจ ์ธ์ด ๋ชจ๋ธ(Large Language Model, LLM)์ ์ด๋ ๋ ๊ฐ์๊ธฐ ๋ฑ์ฅํ ๊ธฐ์ ์ด ์๋๋ผ, 1980๋
๋ ๋ถ์ฐ ํํ ์ฐ๊ตฌ๋ถํฐ ์ด์ด์ง 40์ฌ ๋
์ ์ฐ๊ตฌ ๊ฒฐ๊ณผ๋ฌผ์
๋๋ค 1.
- LLM์ ์ดํดํ๋ ค๋ฉด ์ค๋๋ ์ GPT, Claude๊ฐ ๋ฌด์์ ํ๋๊ฐ๊ฐ ์๋๋ผ, ์ด๋ค ์์ด๋์ด๋ค์ด ์์ฐจ์ ์ผ๋ก ์ฐ๊ฒฐ๋์ด ์ง๊ธ์ ๋ชจ๋ธ์ ๋ง๋ค์๋๊ฐ๋ฅผ ์ดํดํ๋ ๊ฒ์ด ์ข์ต๋๋ค.
๋ณธ ๊ธ์ LLM์ ๊ตฌ์ฑํ๋ ํต์ฌ ์์ด๋์ด๋ค์ ํ๋ฆ์ ์๊ฐ์์ผ๋ก ์ ๋ฆฌํ์ต๋๋ค.
๋ถ์ฐ ํํ(Distributed Representation) ใ ฃ Bengio 2003
- ์๊ธฐํ๊ท ํ๋ ์์ํฌ(Autoregressive Framework)
- Word2Vec๊ณผ ์ธ์ด ๊ท์น์ฑ(Linguistic Regularities)
- Seq2Seq ๋ชจ๋ธ๊ณผ ์ ์์ ๋ฌธ๋งฅ(Adaptive Context)
- Attention ๋ฉ์ปค๋์ฆ์ ๋ถํ
- Transformer (Attention is all you need, 2017)
- ์์ฑ์ ์ฌ์ ํ์ต(Generative Pre-training)๊ณผ ์ ๋ ฌ(Alignment, RLHF)
๋ถ์ฐ ํํ Distributed Representation
- ํต์ฌ ์ง๋ฌธ ใ
ฃ ์ฌ๋์ ์ธ์ด๋ฅผ ์ด๋ป๊ฒ ์ปดํจํฐ๋ก ๋ชจ๋ธ๋งํ ๊ฒ์ธ๊ฐ?
- 1980๋ ๋๊น์ง ์์ฐ์ด ์ฒ๋ฆฌ(Natural Language Processing, NLP)๋ ์์์ ์ผ๋ก ์ค๊ณ๋ ๊ท์น๊ณผ ํน์ฑ(Feature) ๊ธฐ๋ฐ์ด์์ต๋๋ค.
- 1990๋ ๋ ์ด๋ถํฐ ํต๊ณ์ ๊ธฐ๊ณํ์ต ๋ฐฉ๋ฒ์ด ๋์ ๋๊ธฐ ์์ํ์ต๋๋ค 2.
- ํต๊ณ์ NLP์ ํต์ฌ์ ์ธ์ด๋ฅผ ๊ฐ๋ฅํ ๋ชจ๋ ์ํ์ค์ ๋ํ ํ๋ฅ ๋ถํฌ๋ก ๋ชจ๋ธ๋งํ๋ ๊ฒ์
๋๋ค.
- ์ด ๋ถํฌ๋ ๋ณดํต ๊ฐ ๋จ์ด๊ฐ ์์ ๋ชจ๋ ๋จ์ด์ ์์กดํ๋๋ก ๋ถํด๋ฉ๋๋ค:
- ์ข์ ์ธ์ด ๋ชจ๋ธ \(p(w_{1:T})\)๊ฐ ์์ผ๋ฉด ์ํ์ค์ ๊ฐ๋ฅ๋ ๋น๊ต, ๋ฒ์ญ, ์กฐ๊ฑด๋ถ ์์ฑ ๋ฑ ๋ค์ํ ์์ ์ด ๊ฐ๋ฅํฉ๋๋ค.
์ฐจ์์ ์ ์ฃผ Curse of Dimensionality
- ์ ํ๋ฅ ์ ์ถ์ ํ๋ ์ผ์ ๋งค์ฐ ์ด๋ ต์ต๋๋ค.
- ์์ด ์ดํ๋ ๋๋ต ๋ฐฑ๋ง ๋จ์ด ์์ค์ด๋ฉฐ, ๋ฒ์ญ์ฒ๋ผ ์กฐ๊ฑด๋ถ ํ๋ฅ ์ด ๋ง์ ์์ ์์๋ ๋ชจ๋ ์กฐํฉ์ ๊ด์ธกํ ์ ์์ต๋๋ค.
- ๋ฐ์ดํฐ ํฌ์์ฑ(Data Sparsity) ๋ฌธ์ ๋ก, ์ค์ ํ๋ฅ ์ ์ถ์ ํ๋ ๊ฒ์ด ์ฌ์ค์ ๋ถ๊ฐ๋ฅํด์ง๋๋ค.
- ๊ฐ์ฅ ์ค๋๋ ์ ๊ทผ์ Markov ๊ฐ์ ์ผ๋ก, ์ด๋ ๊ฐ ์กฐ๊ฑด๋ถ ํ๋ฅ ์ด ์ง์ \(N\)๊ฐ ๋จ์ด์๋ง ์์กดํ๋ค๊ณ ๋จ์ํํ๋ ๋ฐฉ์์ ๋๋ค 3:
- ์ด๊ฒ์ด ์ ๋ช
ํ N-gram ๋ชจ๋ธ์
๋๋ค.
- \(N=2\) (bigram), \(N=3\) (trigram) ์ ๋์์๋ ์ถ์ ์ด ๊ฐ๋ฅํ๋, Markov ๊ฐ์ ์ ๋ฌธ๋งฅ(Context)์ ํ๊ดดํ๊ธฐ ๋๋ฌธ์ ์์ฐ์ด์ ๋ณต์ก๋, ๋์์ค๋ฅผ ์ฌํํ๊ธฐ ์ด๋ ต์ต๋๋ค.
- 2000๋ ๋ฌด๋ ต๊น์ง ์ด๊ฒ์ด NLP์ ํ์ค์ด์์ต๋๋ค.
์ ๊ฒฝ๋ง ์ธ์ด ๋ชจ๋ธ
- 2003๋
Bengio์ ์ฐ๊ตฌ์ง์ ๋ถ์ฐ ํํ์ ์ด์ฉํ ์ ๊ฒฝ ํ๋ฅ ์ ์ธ์ด ๋ชจ๋ธ์ ์ ์ํ์ต๋๋ค 4.
- ์ด ๋ชจ๋ธ์ ์๋์ ์ธ๊ฐ์ง ์์ด๋์ด๋ฅผ ํฌํจํฉ๋๋ค:
- ๋จ์ด๋ฅผ ์ค์ ๋ฒกํฐ(embedding)๋ก ํํ
- ํ๋ฅ ํจ์๋ฅผ ํด๋น ์๋ฒ ๋ฉ์ ํจ์๋ก ํํ
- ์ ๊ฒฝ๋ง์ ํตํด ์๋ฒ ๋ฉ๊ณผ ํ๋ฅ ํจ์์ ํ๋ผ๋ฏธํฐ๋ฅผ ๋์์ ํ์ต(Back-propagation)
- ์ด ๋ชจ๋ธ์ ์๋์ ์ธ๊ฐ์ง ์์ด๋์ด๋ฅผ ํฌํจํฉ๋๋ค:
- ์ดํ \(V = \{1, 2, \ldots, V\}\)์ ๊ฐ ๋จ์ด๋ฅผ \(D\)์ฐจ์ ๋ฒกํฐ๋ก ํํํ๋ฉด, ์ ์ฒด ์ดํ๋ ํ๋ ฌ๋ก ๋ํ๋ผ ์ ์์ต๋๋ค:
- \(i\)๋ฒ์งธ ํ \(c_i\)๋ \(i\)๋ฒ์งธ ๋จ์ด์ ๋จ์ด ์๋ฒ ๋ฉ(Word Embedding)์ ๋๋ค.
๋ถ์ฐ ํํ ํ๋ ฌ \(C\)์ ๊ตฌ์กฐ. ๊ฐ ํ์ด ํ ๋จ์ด์ \(D\)์ฐจ์ ์๋ฒ ๋ฉ์ด๋ค 4.
- ํ๋ฅ ํจ์๋ฅผ feed-forward ์ ๊ฒฝ๋ง์ผ๋ก ๊ตฌํํ์ต๋๋ค:
- ํ์ต ํ๋ผ๋ฏธํฐ ์งํฉ์ ๋จ์ด ์๋ฒ ๋ฉ \(C\)์ ์ ๊ฒฝ๋ง ํ๋ผ๋ฏธํฐ \(\theta\)์ ๋๋ค:
๋ชจ๋ธ ์๋ ๋ฐฉ์
- ์ ๋
ผ๋ฌธ์ ํต์ฌ ๋
ผ์ฆ์ ์ผ๋ฐํ(Generalization) ๊ฐ๋ฅ์ฑ์ ์์ต๋๋ค.
- ์๋ฏธ, ๋ฌธ๋ฒ์ ์ผ๋ก ์ ์ฌํ ๋จ์ด๋ ๋น์ทํ ์๋ฒ ๋ฉ์ ๊ฐ์ง๋ฉฐ, ํ๋ฅ ํจ์๋ ์ด ์๋ฒ ๋ฉ์ ๋งค๋๋ฌ์ด(Smooth) ํจ์์ ๋๋ค.
- ๋ฐ๋ผ์ ์๋ฒ ๋ฉ์ด ์กฐ๊ธ ๋ณํ๋ฉด ํ๋ฅ ๋ ์กฐ๊ธ ๋ณํ๋ฉฐ, ํ์ต ๋ฐ์ดํฐ์ ํ ๋ฌธ์ฅ๋ง ์์ด๋ ๊ทธ ๋ฌธ์ฅ์ ์๋ฒ ๋ฉ ๊ณต๊ฐ ์ด์ ๋ฌธ์ฅ๋ค์ ๋ํด ํ๋ฅ ์ด ๋์์ ์ฌ๋ผ๊ฐ๋๋ค.
- ex. โdogโ๊ณผ โcatโ์ ์๋ฒ ๋ฉ์ด ๊ฐ๊น๋ค๋ฉด,
The cat is walking on the sidewalk๊ณผThe dog is walking on the sidewalk์ ๋น์ทํ ํ๋ฅ ์ ๊ฐ์ง๋๋ค.- ํ์ต ๋ฐ์ดํฐ์ ํ ๋ฌธ์ฅ๋ง ์์ด๋ ๋ค๋ฅธ ๋ฌธ์ฅ์ผ๋ก ์ผ๋ฐํ ๊ฐ๋ฅํ๋ค๋ ์๋ฏธ์ ๋๋ค.
์๊ธฐํ๊ท ํ๋ ์์ํฌ Autoregressive Framework
- ํต์ฌ ์ง๋ฌธ ใ
ฃ Bengio ๋ชจ๋ธ์ ์ด๋ป๊ฒ ํ์ตํ๊ณ , ์ ๋ฌธ์ฅ์ ์ด๋ป๊ฒ ์์ฑํ๋๊ฐ?
- ์ด ํ๋ ์์ํฌ๋ ํ์ฌ์ LLM๊ณผ ๊ฐ๋ ์ ์ผ๋ก ๋์ผํ ํ์ต ๋ฐฉ์์ ๋๋ค.
- ex. Virginia Woolf์ ๋ฌธ์ฅ
"Intellectual freedom depends upon material things."์ ํ์ตํ๋ค๊ณ ํ ๋:- Context window \(N=2\)๋ก ๋๋ฉด, ์ฒซ ๋ฒ์งธ Non-zero ์ ๋ ฅ์ โintellectualโ ๋จ์ด์ ์๋ฒ ๋ฉ \(c_{I(\text{intellectual})}\)์ ๋๋ค.
- ๋ชจ๋ธ์ \(V\)์ฐจ์ ํ๋ฅ ๋ถํฌ \(p(w_2 \mid w_1)\)๋ฅผ ์ถ๋ ฅํฉ๋๋ค.
- ์ ๋ต ๋จ์ด โfreedomโ์ ๋์๋๋ One-hot ๋ฒกํฐ์ ๊ต์ฐจ ์ํธ๋กํผ(Cross-Entropy) ์์ค์ ๊ณ์ฐํฉ๋๋ค.
- ํ ๋จ์ด์ฉ shiftํ๋ฉฐ ๋ฐ๋ณตํฉ๋๋ค. \(N=2\) ์ ์ฝ ๋๋ฌธ์ ์ธ ๋ฒ์งธ ์
๋ ฅ์์๋ โintellectualโ์ด ๋ฌธ๋งฅ์ ๋ฒ์ด๋ ์์ค๋ฉ๋๋ค.
- ์ด๊ฒ์ด Context Window์ ๊ทผ๋ณธ์ ํ๊ณ์ด๋ฉฐ, ์ดํ ์ฐ๊ตฌ๋ค์ ํต์ฌ ๋๊ธฐ๊ฐ ๋ฉ๋๋ค.
๋ชฉ์ ํจ์์ ์์ฑ
- ๊ต์ฐจ ์ํธ๋กํผ ์ต์ํ๋ ๋ก๊ทธ ์ฐ๋ ์ต๋ํ์ ๋์น์ด๋ฏ๋ก, ํ์ต์ ๋ค์์ ํธ๋ ๋ฌธ์ ๋ก ์ผ๋ฐํ๋ฉ๋๋ค:
Back-propagation๊ณผ ๊ฒฝ์ฌ ํ๊ฐ๋ฒ(Gradient Descent)์ผ๋ก ํ๋ผ๋ฏธํฐ \(\Theta\)๋ฅผ ์ถ์ ํฉ๋๋ค.
- ํ์ต์ด ๋๋ ํ ๋ฌธ์ฅ ์์ฑ์ ๋ค์๊ณผ ๊ฐ์ด ์ด๋ฃจ์ด์ง๋๋ค:
- ์ฒซ ๋จ์ด \(w_1\)์ ์ดํ์์ ์ํ๋ง
- ๋ ๋ฒ์งธ ๋จ์ด๋ฅผ \(p(w_2 \mid w_1)\)์์ ์ํ๋ง
- ์ธ ๋ฒ์งธ ๋จ์ด๋ฅผ \(p(w_3 \mid w_{1:2})\)์์ ์ํ๋ง
- ์ข ๋ฃ ํ ํฐ์ ๋๋ฌํ ๋๊น์ง ๋ฐ๋ณต
LLM์ด ์์ฐ์ด๋ฅผ ์ดํดํ๋ ๋์์ ์์ฑํ๋ ์ด์ ๊ฐ ์ฌ๊ธฐ์ ์์ต๋๋ค. ์ธ์ด ๋ชจ๋ธ์ ๊ธฐ์ ์ ๋ชจ๋ธ(descriptive)์ธ ๋์์ ์์ฑ์ (generative) ๋ชจ๋ธ์ ๋๋ค.
- ์ด๋ฐ ๋ฐฉ์์ผ๋ก ํ์ต๋ ๋ชจ๋ธ์ ์๊ธฐํ๊ท ๋ชจ๋ธ(Autoregressive Model)์ด๋ผ ๋ถ๋ฆ
๋๋ค.
- ํต๊ณํ์์ ์๊ธฐํ๊ท๋ ๋ณ์๊ฐ ์์ ์ ์ด์ ๊ฐ์ผ๋ก ์์ธก๋๋ ๋ชจ๋ธ์ ์๋ฏธํฉ๋๋ค.
๋ณํ
- ํต์ฌ ์ง๋ฌธ ใ
ฃ Bengio 2003์ด ๋๋๋งํฌ๋ผ๋ฉด์, ์ ๊ทธ ํ 10๋
๊ฐ๊น์ด ์ค์ ๋ก๋ N-gram์ด ์ฃผ๋ฅ์๋๊ฐ?
- ๋ต์ ๊ฐ๋จํฉ๋๋ค. ์ ๊ฒฝ๋ง์ ํ์ตํ๋ ์ผ์ด ๋น์์ ๋๋ฌด ์ด๋ ค์ ์ต๋๋ค.
- Bengio ๋ชจ๋ธ์ CPU ์์์, ์๋ ๋ฏธ๋ถ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ ์์ด ํ๋ จ๋์์ต๋๋ค.
AlexNet
- 2012๋
ImageNet ๋ํ์ ๋ฑ์ฅํ AlexNet 5์ ์ปดํจํฐ ๋น์ ์ ํธ๋ ๋๋ฅผ ํฌ๊ฒ ๋ฐ๊พธ์์ต๋๋ค.
- ILSVRC-2012 top-5 Test Error 15.3% (2๋ฑ 26.2%). ์๋์ ์ค๋ฅ์จ ๊ธฐ์ค 40% ๊ฐ์.
- GPU ์์์ ๋๊ท๋ชจ ๋ฐ์ดํฐ์ (ImageNet)์ผ๋ก end-to-end ํ์ต๋ ์ต์ด์ deep CNN.
- โ2003๋
Bengio๋ ๊ฐ๋
์ ๋ฌด๋๋ฅผ ๋์๊ณ , 2012๋
Krizhevsky๋ ๊ธฐ์ ์ ๋ฌด๋๋ฅผ ๋์๋ค.โ
- ์ดํ NLP ์ฐ๊ตฌ์๋ค์ด ์ ๊ฒฝ๋ง์ ๊ท๋ชจ ์๊ฒ ํ์ตํ๋ ค๋ ์๋๋ฅผ ๋ณธ๊ฒฉํํฉ๋๋ค.
Word2Vec
Mikolov ๋ฑ์ 2013๋ ์ ๋ ํธ์ ๋ ผ๋ฌธ์ ๋ฐํํ๋ฉฐ ๋ถ์ฐ ํํ์ ํ์ฅ์ฑ ๋ฌธ์ ๋ฅผ ํด๊ฒฐํฉ๋๋ค 6 7.
Bengio ๋ชจ๋ธ์ ๊ณ์ฐ ๋น์ฉ์ ์ดํด๋ด ์๋ค. Bengio ๋ชจ๋ธ์ ๋จ์ผ ๋จ์ด ์์ธก ๋ณต์ก๋๋ ๋๋ต ๋ค์๊ณผ ๊ฐ์ด ๊ณ์ฐ๋ฉ๋๋ค:
\(V\)๋ ์ดํ ํฌ๊ธฐ, \(N\)์ Context Window, \(D\)๋ Embedding ์ฐจ์, \(H\)๋ Hidden ์ฐจ์.
- ์ดํ \(V\)๊ฐ ๋งค์ฐ ํฌ๊ธฐ ๋๋ฌธ์ \(VH\)๊ฐ ์ง๋ฐฐ์ ์ด๋ฉฐ, ๊ฑฐ๊ธฐ์ Softmax ์ ๊ทํ๊น์ง ๋ํด์ ธ ํ์ต์ด ๋งค์ฐ ๋๋ ธ์ต๋๋ค.
- Mikolov ๋ฑ์ด ์ด ๋ ๊ฐ์ง ๊ธฐ๋ฒ:
- Hierarchical Softmax ใ ฃ ์ด์ง ํธ๋ฆฌ ๊ธฐ๋ฐ ์ ๊ทํ. ๋ณต์ก๋๋ฅผ \(\mathcal{O}(V)\)์์ \(\mathcal{O}(\log_2 V)\)๋ก ์ถ์.
- Negative Sampling ใ ฃ ๋ ธ์ด์ฆ ๋ถํฌ์์ \(K\)๊ฐ ์ํ์ ๋ฝ์ ๊ด์ธก์ ๋ ธ์ด์ฆ์ ๊ตฌ๋ถํ๋๋ก ํ์ต. ์ ๊ทํ ์์๋ฅผ ๋ช ์์ ์ผ๋ก ๊ณ์ฐํ์ง ์์.
- ๋ชจ๋ธ ๊ตฌ์กฐ๋ ๊ทน๋จ์ ์ผ๋ก ๋จ์ํํฉ๋๋ค. Bengio์ ๋น์ ํ Hidden Layer๋ฅผ ์ ๊ฑฐํ๊ณ ๋ก๊ทธ-์ ํ(Log-linear) ๋ชจ๋ธ๋ง ๋จ๊น๋๋ค.
CBOW์ Skip-gram
CBOW(์ผ์ชฝ)์ Skip-gram(์ค๋ฅธ์ชฝ). ๋ชจ๋ ์์ ๋ก๊ทธ-์ ํ ๋ชจ๋ธ์ด๋ค 6.
- CBOW(Continuous Bag-of-Words) ใ ฃ ์ฃผ๋ณ ๋จ์ด๋ค์ด ์ค์ฌ ๋จ์ด๋ฅผ ์์ธก
Skip-gram ใ ฃ ์ค์ฌ ๋จ์ด๊ฐ ์ฃผ๋ณ ๋จ์ด๋ค์ ์์ธก
- Skip-gram์ ๋ชฉ์ ํจ์ (window \(N=2C\)):
- ์กฐ๊ฑด๋ถ ํ๋ฅ ์ ๋ก๊ทธ-์ ํ์ผ๋ก ๋ชจ๋ธ๋ง๋ฉ๋๋ค:
- ๋ก๊ทธ๋ฅผ ์ทจํ๋ฉด ์ ํ ํํ๊ฐ ๋๋ฌ๋ฉ๋๋ค:
\(Z\)๋ ์ ๊ทํ ์์์ด๋ฉฐ, Negative Sampling์ ์ฐ๋ฉด ๋ช ์์ ๊ณ์ฐ์ด ๋ถํ์ํฉ๋๋ค.
์ค์ํ subtlety ใ ฃ CBOW/Skip-gram์ ์์ ํ ์ธ์ด ๋ชจ๋ธ์ด ์๋๋๋ค. ์ข์ ๋จ์ด ์๋ฒ ๋ฉ์ ํ์ตํ๊ธฐ ์ํ ๋ณด์กฐ ๋ชฉ์ ์ผ ๋ฟ์ ๋๋ค.
- ๊ทธ๋ฌ๋ ์ด ์์ ๋ชจ๋ธ๋ค์ ๋๊ท๋ชจ ํ์ต์ด ๊ฐ๋ฅํ๊ณ , ๊ฒฐ๊ณผ๋ ๋๋ผ์ ์ต๋๋ค.
์ธ์ด ๊ท์น์ฑ์ ๋ฐํ Emergent Linguistic Regularities
ํต์ฌ ์ง๋ฌธ ใ ฃ ๋จ์ํ ์ ํ ๋ชจ๋ธ์ด ์ ์๋ฏธยท๋ฌธ๋ฒ ๊ตฌ์กฐ๋ฅผ ํฌ์ฐฉํ๋๊ฐ?
- Mikolov ๋ฑ์ ๋จ์ด ์๋ฒ ๋ฉ์์ ์ ์๋ฏธํ ์ ํ ์คํ์
์ด ๊ด์ฐฐ๋จ์ ๋ณด์์ต๋๋ค 8.
- ์ฆ, ๋ง์ ์๋ฏธยท๋ฌธ๋ฒ ๊ด๊ณ๊ฐ ์๋ฒ ๋ฉ ๊ณต๊ฐ์์ ๊ฑฐ์ ์ผ์ ํ ๋ฒกํฐ ์ฐจ์ด๋ก ํํ๋ฉ๋๋ค.
- ex. โking is to queen as man is to womanโ:
๊ณ ์ฐจ์ ๋จ์ด ์๋ฒ ๋ฉ ๊ณต๊ฐ์์๋ ํ๋์ ๋จ์ด๊ฐ ์ฑ๋ณ, ๋จ์ยท๋ณต์ ๋ฑ ์ฌ๋ฌ ์๋ฏธ ๊ด๊ณ๋ฅผ ๋์์ ๋ฒกํฐ ๋ฐฉํฅ์ผ๋ก ํํํ ์ ์๋ค 8.
- ex:
- ๋จ์ด๋ ์ด์ฐ์ (Discrete) ๊ฐ์ฒด์ด๋ฉฐ, ๋จ์ด์ ์์ ๋ณํ๋ ์ง๊ด์ ์ผ ๋ฟ ์ํ์ ์ผ๋ก ์ ์๋์ง ์์ต๋๋ค.
- ์๋ฒ ๋ฉ ๊ณต๊ฐ์ ์ด ์ง๊ด์ ๊ตฌ์ฒดํํฉ๋๋ค. ์๋ฏธ๊ฐ ๊ฐ๊น์ด ๋จ์ด๋ผ๋ฆฌ ๊ฐ๊น์ด ๋ฒกํฐ๋ฅผ ๊ฐ์ง๋ค๋ ๊ฒ์, ์ฐ์์ ์ธ ๋ฒกํฐ ๊ณต๊ฐ์์ ์ด์ฐ์ ์๋ฏธ ๊ตฌ์กฐ๊ฐ ๊ฑฐ์ ์ ํ์ ์ผ๋ก ์ ์ง๋จ์ ๋ปํฉ๋๋ค.
- ์ดํ ๋ฌธ๋งฅ ์์กด ์๋ฒ ๋ฉ(Contextualized Embedding) ๊ณ์ด์ด ๋ฑ์ฅํฉ๋๋ค.
- Peters ๋ฑ 2018์ ELMO๋ Bidirectional LSTM์ Hidden State๋ฅผ ๋ฌธ๋งฅ ์์กด ์๋ฒ ๋ฉ์ผ๋ก ์ฌ์ฉํฉ๋๋ค 9.
- ์ฌ์ ํ์ต ์๋ฒ ๋ฉ๊ณผ ์ง๋ํ์ต Fine-tuning์ ๊ฒฐํฉํ๋ ๋ฐฉํฅ์ ๋ฏธ๋ฆฌ ๋ณด์ฌ์ค ์์ ์ ๋๋ค.
์ ์์ ๋ฌธ๋งฅ Adaptive Context
ํต์ฌ ์ง๋ฌธ ใ ฃ ๊ณ ์ ํฌ๊ธฐ Context Window๋ฅผ ๋์ด ์์ ๊ธธ์ด ์ํ์ค๋ฅผ ์ด๋ป๊ฒ ๋ค๋ฃฐ ๊ฒ์ธ๊ฐ?
2013๋ ๊ฒฝ๊น์ง ์๋ฒ ๋ฉ์ ์ ์๋ํ์ง๋ง, ์ฌ์ ํ ๊ณ ์ Window ์์์๋ง ์ ํจํ์ต๋๋ค.
- ์ด ํ๊ณ๋ฅผ ๊ทน๋ณตํ ๋ชจ๋ธ์ด Sequence-to-Sequence(Seq2Seq) ๋ชจ๋ธ์ ๋๋ค.
RNN ์ธ์ฝ๋-๋์ฝ๋
- Seq2Seq ๋ชจ๋ธ์ ๊ตฌ์กฐ:
- Encoder ใ ฃ ๊ฐ๋ณ ๊ธธ์ด ์ ๋ ฅ ์ํ์ค๋ฅผ ๊ณ ์ ๊ธธ์ด ๋ฒกํฐ๋ก ์์ถ
- Decoder ใ ฃ ์ด ๋ฒกํฐ๋ฅผ ๋ค์ ๊ฐ๋ณ ๊ธธ์ด ์ถ๋ ฅ ์ํ์ค๋ก ๋ณต์
- ๋ํ ๋
ผ๋ฌธ 3ํธ์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค 10 11 12:
- Kalchbrenner & Blunsom (2013) ใ ฃ CSM ์ธ์ฝ๋ + RNN ๋์ฝ๋
- Cho et al. (2014) ใ ฃ ๋ ๊ฐ RNN ๊ตฌ์กฐ (encoder-decoder ๋ชจ๋ RNN)
- Sutskever et al. (2014) ใ ฃ LSTM ๊ธฐ๋ฐ encoder-decoder, vanishing gradient ๋ฌธ์ ์ํ
RNN ์ธ์ฝ๋-๋์ฝ๋ ๊ตฌ์กฐ. ์ธ์ฝ๋์ Hidden States \(H\)๊ฐ ๊ณ ์ ๊ธธ์ด Context Vector \(c\)๋ก ์์ถ๋ ๋ค ๋์ฝ๋๋ก ์ ๋ฌ๋๋ค 11.
RNN ์ํ ์์
- ๊ฐ๋ณ ๊ธธ์ด ์ ๋ ฅ \(X = \{x_1, x_2, \ldots, x_{T_x}\}\), ์ถ๋ ฅ \(Y = \{y_1, y_2, \ldots, y_{T_y}\}\)๋ฅผ ์ ์ํฉ๋๋ค.
- ์ธ์ฝ๋์ Hidden State๋ ์ฌ๊ท์ ์ผ๋ก ๊ณ์ฐ๋ฉ๋๋ค:
- ๊ฐ๋จํ RNN ์ ๋์ ๋ค์๊ณผ ๊ฐ์ ๋น์ ํ ํจ์๋ก ๊ตฌ์ฒดํ๋ฉ๋๋ค:
- Context Vector \(c\)๋ Hidden State๋ค์ ํจ์๋ก ์ ์๋ฉ๋๋ค:
๊ฐ์ฅ ๋จ์ํ ์ ํ์ \(c = h_{T_x}\)๋ก, ๋ง์ง๋ง Hidden State๋ฅผ ๊ทธ๋๋ก ์ฌ์ฉํ๋ ๊ฒ์ ๋๋ค.
๋์ฝ๋๋ ์ฌ๊ท ๊ด๊ณ๋ฅผ ๊ฐ์ต๋๋ค:
- ํ์ต ๋ชฉ์ ์ ๋ก๊ทธ ์ฐ๋ ์ต๋ํ์ ๋๋ค:
๊ณ ์ ๋ฒกํฐ์ ๋ณ๋ชฉ
- RNN Encoder-decoder ํ๋ ์์ํฌ๋ ๊ฐ๋ ฅํ์ง๋ง, ํฐ ํ๊ณ๊ฐ ์์์ต๋๋ค.
- ๋ฌธ์ฅ์ด ๊ธธ์ด์ง์๋ก ๊ณ ์ ํฌ๊ธฐ Context Vector \(c\)์ ์ ๋ณด๋ฅผ ์์ถํด์ผ ํ๊ณ , ์ฅ๊ฑฐ๋ฆฌ ์์กด์ฑ์ด ์์ค๋์ต๋๋ค.
- Cho ๋ฑ(2014)์ BLEU ์ ์๊ฐ ๋ฌธ์ฅ ๊ธธ์ด์ ๋ฐ๋ผ ๊ธ๊ฒฉํ ์ดํ๋จ์ ์คํ์ผ๋ก ํ์ธํ์ต๋๋ค.
- ์ด ๋ณ๋ชฉ์ ๊นจ๋ ๋ต์ด Attention ๋ฉ์ปค๋์ฆ์ด์์ต๋๋ค.
Attention
- ํต์ฌ ์ง๋ฌธ ใ ฃ ๊ณ ์ ๋ฒกํฐ๋ก ์์ถํ์ง ์๊ณ , ๋์ฝ๋๊ฐ ํ์ํ ๋๋ง๋ค ์ธ์ฝ๋์ ํน์ ๋ถ๋ถ์ ์ฐธ์กฐํ ์๋ ์์๊น?
NMT์์์ Attention ๋ฑ์ฅ
- Bahdanau et al. (2014)์
Neural Machine Translation by jointly learning to align and translate์์ ๋ฏธ๋ถ ๊ฐ๋ฅํ Attention ๋ ์ด์ด๋ฅผ NMT์ ์ต์ด๋ก ์ฑ๊ณต์ ์ผ๋ก ์ ์ฉํ์ต๋๋ค 13.- ์๋ฌธ ํํ: โparts of a source sentence that are relevant to predicting a target wordโ๋ฅผ ์๋์ผ๋ก (Soft) ํ์.
- ๊ฐ ๋์ฝ๋ Hidden State \(s_i\)๊ฐ ์์ ๋ง์ Context Vector \(c_i\)๋ฅผ ๊ฐ์ง๋๋ค. ์ด \(c_i\)๋ ๋ชจ๋ ์ธ์ฝ๋ Hidden State์ ๊ฐ์ค ํฉ์ ๋๋ค:
- Attention ๊ฐ์ค์น \(\alpha_{ij}\)๋ Softmax ์ ๊ทํ๋ ์ ๋ ฌ(Alignment) ์ ์์ ๋๋ค:
- \(\alpha_i\)๋ ์ ๋ ฌ ๋ฒกํฐ(Alignment Vector)๋ก, ๋์ฝ๋๊ฐ ์ธ์ฝ๋์ ์ด๋ ๋ถ๋ถ์ ์ผ๋ง๋ ์ฐธ์กฐํ ์ง ๊ฒฐ์ ํฉ๋๋ค.
- ๋ชจ๋ธ ํ๋ผ๋ฏธํฐ \(v_a, W_a, U_a\)๋ End-to-End ๋ก ํ์ต๋ฉ๋๋ค.
Attention์ ์ฐจ์ ์ ๋ฆฌ
- Luong et al. (2015)์ Bahdanau์ ์์ด๋์ด๋ฅผ ๋จ์ํํ๋ฉฐ Attention์ ์ฌ๋ฌ ํํ๋ฅผ ์ฒด๊ณํํ์ต๋๋ค 14.
Attention ์ ํ 1. Global โ ๋ชจ๋ ์์ค ์ํ ์ฐธ์กฐ 14
Attention ์ ํ 2. Local โ ์ผ๋ถ ์ํ๋ง ์ฐธ์กฐ 14
- ์ฐจ์ 1: ๋ฒ์ โ Global vs Local Attention
- Global ใ ฃ ๋ชจ๋ ์ธ์ฝ๋ Hidden State๋ฅผ ์ฐธ์กฐ (\(a=1, b=T_x\))
- Local ใ ฃ ์ผ์ ์๋์ฐ๋ง ์ฐธ์กฐ
- ์ฐจ์ 2: ์ ์ ํจ์ โ Alignment Score Function
- ์ธ ๊ฐ์ง ์ฃผ์ ์ ์ ํจ์:
์ดํ Transformer๊ฐ ์ ํํ๋ ํํ๋ Dot-product Attention์ ๋๋ค. ๋ ๋ฒกํฐ์ ๋ด์ ์ ์ ์ฌ๋(Similarity)์ ์์ฐ์ค๋ฌ์ด ์ฒ๋์ด๊ธฐ ๋๋ฌธ์ ๋๋ค.
- ์ฐจ์ 3: ๊ด์ฌ ๋ณ์์ ์ถ์ฒ โ Cross vs Self Attention
- Query(Q), Key(K), Value(V) ๋ ์ ๋ณด ๊ฒ์(Information Retrieval)์์ ์ฐจ์ฉ๋ ๊ฐ๋
์
๋๋ค:
- Query ใ ฃ ์ฌ์ฉ์๊ฐ ์ฐพ๋ ๊ฒ
- Key ใ ฃ ๊ฒ์ ๋์์ ๋ฉํ๋ฐ์ดํฐ
- Value ใ ฃ ์ค์ ๋ก ๋ฐํ๋๋ ๋ด์ฉ
- Cross-Attention ใ ฃ Query๋ ํ ์งํฉ์์, KeyยทValue๋ ๋ค๋ฅธ ์งํฉ์์ (Bahdanau์ ๋์ผ)
- Self-Attention ใ ฃ Query, Key, Value ๋ชจ๋ ๊ฐ์ ์งํฉ์์
- Query(Q), Key(K), Value(V) ๋ ์ ๋ณด ๊ฒ์(Information Retrieval)์์ ์ฐจ์ฉ๋ ๊ฐ๋
์
๋๋ค:
- Self-Attention์ NLP์ ์ต์ด๋ก ์ ์ฉํ ๊ฒ์ Cheng et al. (2016)์ โLSTM-Networks for Machine Readingโ์ผ๋ก ์๋ ค์ ธ ์์ต๋๋ค 15.
- ์ํ์ค๊ฐ ์๊ธฐ ์์ ์ ์ด๋ ๋ถ๋ถ์ ์ฃผ๋ชฉํ ์ง๋ฅผ ๊ฒฐ์ ํ ์ ์๊ฒ ๋์์ต๋๋ค.
Transformer
ํต์ฌ ์ง๋ฌธ ใ ฃ ์ฌ๊ท ์ฐ์ฐ(RNN)์ ์์ ํ ์ ๊ฑฐํ๊ณ Attention๋ง์ผ๋ก ์ํ์ค ๋ชจ๋ธ๋ง์ ํ ์ ์์๊น?
- 2017๋
Vaswani et al.์ Attention is all you need์์ ์ ํํ ์ด ์ ์์ ํฉ๋๋ค 16.
- ์๋ฌธ ๊ทธ๋๋ก: โWe propose a new simple network architecture, the Transformer, based solely on attention mechanisms, dispensing with recurrence and convolutions entirely.โ
- ์ ์ข์ ์์ด๋์ด์ธ๊ฐ?
- RNN์ ์์ฐจ์ ์ฑ์ง์ ํ์ต ๋ณ๋ ฌํ๋ฅผ ๋ง๋๋ค๋ ํ๊ณ๊ฐ ์์์ต๋๋ค.
- Attention์ ๋ณ๋ ฌ ์ฒ๋ฆฌ๊ฐ ๊ฐ๋ฅํฉ๋๋ค. ๊ท๋ชจ ํ์ฅ์ด ๊ฐ๋ฅํ๋ค๋ฉด, ์ถฉ๋ถํ ์ข์์ง ์ ์๋ค๋ ์ ์ ์ ๋๋ค.
- ์ค์ ๋ก 8๊ฐ์ P100 GPU๋ก 12์๊ฐ ํ์ตํ ๊ฒฐ๊ณผ๊ฐ ๋น์ ์ต์ฒจ๋จ ๋ฒ์ญ ํ์ง์ ๋๋ฌํ์ต๋๋ค.
์ํคํ ์ฒ
Transformer ์ํคํ
์ฒ. Encoder์ Decoder ๋ชจ๋ Positional Encoding๊ณผ Multi-head Self-attention์ ์ฌ์ฉํ๋ค 16.
- Transformer๋ Encoder-decoder ๊ตฌ์กฐ๋ฅผ ์ ์งํ๋, ๋ด๋ถ๋ฅผ ๋ชจ๋ Attention์ผ๋ก ๋์ฒดํฉ๋๋ค:
- Positional Encoding ใ ฃ Attention ์์ฒด์ ์์ ์ ๋ณด๊ฐ ์์ผ๋ฏ๋ก, ์ ๋ ฅ ๋ฒกํฐ์ ์์น ์์กด์ ์ ๋ณด๋ฅผ ๋ํจ
- Multi-Head Self-Attention (Encoder) ใ ฃ ์ ๋ ฅ ์ํ์ค ๋ด๋ถ์ ์์กด์ฑ ํฌ์ฐฉ
- Masked Multi-Head Self-Attention (Decoder) ใ ฃ ๋์ฝ๋ฉ ์ ๋ฏธ๋ ํ ํฐ์ ๊ฐ๋ ค Autoregressive ๊ตฌ์กฐ ์ ์ง
- Cross-Attention (EncoderโDecoder) ใ ฃ Bahdanau ์คํ์ผ๋ก ์ธ์ฝ๋ ์ถ๋ ฅ์ ๋์ฝ๋์์ ์ฐธ์กฐ
- Layer Normalization + Residual Connection ใ ฃ ๊ธฐ์กด ๊ธฐ๋ฒ์ ๊ทธ๋๋ก ์ฐจ์ฉ
Scaled Dot-Product Attention
- Transformer์ ํต์ฌ ์ฐ์ฐ์ Scaled dot-product Attention์
๋๋ค.
- Query ํ๋ ฌ \(Q \in \mathbb{R}^{M \times D_k}\), Key ํ๋ ฌ \(K \in \mathbb{R}^{N \times D_k}\), Value ํ๋ ฌ \(V \in \mathbb{R}^{N \times D_v}\)์ ๋ํด:
- ์ด ์์ Luong์ Dot-product Attention์ ์ค์ผ์ผ๋ง ๊ณ์ \(\sqrt{D_k}\) ๋ง ์ถ๊ฐํ ๋ค ํ๋ ฌ ํํ๋ก ํจํค์งํ ๊ฒ์
๋๋ค.
- ๋์ผํ ์ฐ์ฐ์ ์ฌ๋ฌ ์ํ์ ๋ํด ํ ๋ฒ์ ๋ณ๋ ฌ ๊ณ์ฐํ ์ ์๋๋ก ํด์ค๋๋ค.
- Transformer์์์ Q/K/V ํด์:
- Encoder Self-attention ใ ฃ Q, K, V ๋ชจ๋ ๊ฐ์ ์ ๋ ฅ ์ํ์ค์์ ์ ๋
- Decoder Self-attention ใ ฃ Q, K, V ๋ชจ๋ ์ถ๋ ฅ ์ํ์ค์์ ์ ๋
- EncoderโDecoder Attention ใ ฃ Q๋ ๋์ฝ๋ ์ํ, KยทV๋ ์ธ์ฝ๋ ์ถ๋ ฅ
Multi-Head Attention
- ๋จ์ผ Attention ๋์ ์ฌ๋ฌ ๊ฐ Attention์ ๋ณ๋ ฌ๋ก ์ํํฉ๋๋ค.
- ๊ฐ Head๊ฐ ์๋ก ๋ค๋ฅธ ํ๋ผ๋ฏธํฐ ์งํฉ \(\{W_a, U_a, v_a\}_{a=1, \ldots, A}\)๋ฅผ ๊ฐ์ง๋๋ค.
- ๊ฐ Head๋ ์ธ์ด์ ์๋ก ๋ค๋ฅธ ์ธก๋ฉด์ ํ์ตํฉ๋๋ค (๊ฒฝํ์ ์ผ๋ก).
- ์ฑ๋ฅ ๋ฐ ํจ์จ
- ๊ธฐ์กด ConvS2S Ensemble์ ์์ดโํ๋์ค์ด ํ์ต์ ์ฝ \(1.2 \times 10^{21}\) FLOPs๊ฐ ํ์ํ์ต๋๋ค.
- Transformer๋ \(3.3 \times 10^{18}\) FLOPs๋ก ๋์ผ ์์ค์ BLEU๋ฅผ ๋ฌ์ฑํ์ต๋๋ค.
- ์ฝ 360๋ฐฐ ๊ณ์ฐ ์ ๊ฐ. ๋จ์ํ ์ฑ๋ฅ์ด ์ข์์ง ๊ฒ์ด ์๋๋ผ, ๋ชจ๋ธ๋ง ์ ํ๋์ ํ์ฅ์ฑ์ ํ๋ ํ ๊ฒฝ๊ณ๋ฅผ ์ฎ๊ฒผ๋ค๋ ๋ฐ์ ์์๊ฐ ์์ต๋๋ค.
์์ฑ์ ์ฌ์ ํ์ต Generative Pre-training
- Transformer ์ํคํ
์ฒ๋ง์ผ๋ก๋ ์ค๋์ LLM์ด ์์ฑ๋์ง ์์์ต๋๋ค.
- ์ Transformer๋ ์ต๋ 2.13M ํ๋ผ๋ฏธํฐ, WMT 2014 ๋ฐ์ดํฐ์ (์ฝ 3,600๋ง ๋ฌธ์ฅ) ๊ท๋ชจ์์ต๋๋ค.
- ํ์ต ๋ฐฉ์์ ์งํ๊ฐ ์์ด์ผ ์ค๋๋ ์ฌ๋๋ค์ด ๋ง๋๋ LLM์ด ๊ฐ๋ฅํ์ต๋๋ค.
- OpenAI๊ฐ GPT ์๋ฆฌ์ฆ๋ฅผ ํตํด ์ ์ํ ์ธ ๋จ๊ณ ํ๋ จ ํ์ดํ๋ผ์ธ์ด ๋ํ์ ์
๋๋ค:
- Generative Pre-training ใ ฃ ๋๋ Unlabeled ๋ฐ์ดํฐ์ ๋ํ Next-word Prediction
- Discriminative Fine-tuning ใ ฃ ํน์ Task์ ๋ํ ์ง๋ ํ์ต
- RLHF ใ ฃ ์ธ๊ฐ ํผ๋๋ฐฑ ๊ธฐ๋ฐ ๊ฐํ ํ์ต
GPT | ์ฌ์ ํ์ต + ํ์ธํ๋
- 2018๋
OpenAI๋ Improving Language Understanding by Generative Pre-Training์ ๋ฐํํฉ๋๋ค 17.
- Transformer๋ฅผ ๊ฐ๋ฅํ ํ ๋ง์ Unlabeled ๋ฐ์ดํฐ๋ก ์ฌ์ ํ์ตํ ๋ค, ์๋์ Labeled ๋ฐ์ดํฐ๋ก Task์ ๋ง๊ฒ Fine-tune.
- ์ฌ์ ํ์ต ๋ชฉ์ ํจ์ (์๊ธฐํ๊ท ํ๋ ์์ํฌ ๊ทธ๋๋ก)
- ๋ผ๋ฒจ์ด ๋ถํ์ํ๋ฏ๋ก ๋ฐฉ๋ํ ๋ฐ์ดํฐ๋ก ํ์ต ๊ฐ๋ฅํฉ๋๋ค.
BERT | Masked Language Model
- GPT๋ ์ขโ์ฐ ์๊ธฐํ๊ท ๋ฐฉ์์ด๋ผ ์๋ฐฉํฅ ๋ฌธ๋งฅ์ด ํ์ํ Downstream Task์ ์ฝ์ ์ด ์์ต๋๋ค.
- 2019๋
Google AI๋ BERT๋ฅผ ์ ์ํ์ต๋๋ค 18. ํต์ฌ์ Masked Language Model(MLM) ๋ชฉ์ ํจ์์
๋๋ค.
- ์ ๋ ฅ \(w_{1:T}\)์ ์์น ์งํฉ \(M \subset \{1, \ldots, T\}\)์ ๋ฌด์์๋ก ๊ฐ๋ฆฌ๊ณ , ๊ฐ๋ ค์ง์ง ์์ ํ ํฐ \(w_{\neg M}\)์ ๋ณด๊ณ ๊ฐ๋ ค์ง ํ ํฐ์ ์์ธก:
- ์ข์ฐ ์๋ฐฉํฅ Context๋ฅผ ๋์์ ํ์ฉํ ์ ์๊ฒ ๋ฉ๋๋ค.
Discriminative Fine-tuning
- ์ฌ์ ํ์ต๋ง์ผ๋ก๋ ๋ชจ๋ธ์ ์ค์ ์ฌ๋ก์ ์ ์ฉํ๊ธฐ์ ์ถฉ๋ถํ์ง ์์ต๋๋ค.
- ex. โI am having trouble getting a date. Any advice?โ๋ผ๋ ์ง๋ฌธ์ next-word ์์ธก๋ง ํ๋ ๋ชจ๋ธ์ โYouโll never find true love!โ ๊ฐ์ ์ด์ํ ๋ต์ ๋ผ ์ ์์ต๋๋ค.
- ๋ฐ๋ผ์ Task ํนํ ๋ฐ์ดํฐ๋ก ์ง๋ํ์ต Fine-tuning์ ์ด์ด์ ์ํํฉ๋๋ค:
- ์ฌ์ ํ์ต๋ ์ง์์ ์์ง ์๋๋ก ๋ ๋ชฉ์ ์ ๊ฐ์ค ๊ฒฐํฉํ๊ธฐ๋ ํฉ๋๋ค:
- ๋จ, GPT-2, GPT-3 ์ดํ๋ก๋ Fine-tuning ์์ด๋ Zero-shotยทFew-shot ์ฑ๋ฅ์ด ๋์ค๊ธฐ ์์ํ๋ฉฐ, ์ฌ์ ํ์ต ์์ฒด์ ๊ท๋ชจ๊ฐ ํจ์ฌ ๋ ์ค์ํด์ง๋๋ค.
์ ๋ ฌ Alignment
๊ฑฐ์ง๋ง์ ํ์ง ์๊ฑฐ๋, ์ธ์ข ์ฐจ๋ณ์ ๋๋ด์ ํ์ง ์๊ฑฐ๋, ์ฑ์ ์ธ ๋ฐ์ธ์ ํ์ง ์๋ ๊ฒ
์๊ธฐํ๊ท ํ๋ ์์ํฌ์ ์ด๋ฐ ์ ์ฝ์ด ๋ด์ฌ๋์ด ์์ง ์์ต๋๋ค.
์ผ๋ถ ์์ฑ์ Fine-Tuning์ฉ ๋ฐ์ดํฐ์ (ETHICS, RealToxicityPrompts ๋ฑ)์ผ๋ก ๋ค๋ฃฐ ์ ์์ง๋ง, ์๋น์ ๊ฐ์น๋ ์ ์ ์์ฒด๊ฐ ์ด๋ ค์ ๋ฐ์ดํฐ์ ์ ์์ด ์ด๋ ต์ต๋๋ค.
๊ทธ ํด๋ต์ผ๋ก ๋ฑ์ฅํ ๊ฒ์ด RLHF(Reinforcement Learning from Human Feedback)์ ๋๋ค.
- ์๋๋ ๋ณด์ ํจ์๋ฅผ ๋ช ์ธํ๊ธฐ ์ด๋ ค์ด RL ๋ฌธ์ ๋ฅผ ์ํ ๋ฐฉ๋ฒ์ด์์ต๋๋ค 19.
RLHF
- RLHF์ 3๋จ๊ณ
- (1) ์ ํธ ๋ฐ์ดํฐ ์์ง ใ ฃ ์ฌ๋ฌ ํ๋ณด ์๋ต์ ์์ฑํ๊ณ , ์ฌ๋์ด ์ ํธ๋ฅผ ์์๋ก ๋ผ๋ฒจ๋ง
- (2) ๋ณด์ ๋ชจ๋ธ ํ์ต ใ ฃ ์ด๋ค ์๋ต์ ์ฌ๋์ด ์ ํธํ๋์ง๋ฅผ ์์ธกํ๋ ๋ณด์ ํจ์๋ฅผ ํ์ต
- (3) RL ์ ์ฑ Fine-Tuning ใ ฃ ๋ณด์ ๋ชจ๋ธ์ ์ ํธ๋ฅผ ๋ฐํ์ผ๋ก PPO(Proximal Policy Optimization) 20 ๊ฐ์ ํ์ค RL ์๊ณ ๋ฆฌ์ฆ์ผ๋ก LLM์ Fine-tune
- ์ ์ฉ
- GPT-2 ใ ฃ โFine-tuning language models from human preferencesโ
- GPT-3 ใ ฃ โTraining language models to follow instructions with human feedbackโ
- GPT-4 ใ ฃ ๊ณต์ whitepaper์์๋ RLHF ์ฌ์ฉ ๋ช ์
- Anthropic๋ โhelpful, honest, harmlessโ๋ผ๋ HHH ๊ธฐ์ค์ ์ธ์ฐ๊ณ imitation learning, binary discrimination, ranked preference modeling ๋ฑ ๋ค์ํ ์ ๋ ฌ ๊ธฐ๋ฒ์ ํ๊ตฌํ๊ณ ์์ต๋๋ค.
- ๋ค๋ง ์ ๋ ฌ์ ์ฌ์ ํ ์ด๋ฆฐ ๋ฌธ์ ์ ๋๋ค.
Bitter Lesson | ๊ท๋ชจ๊ฐ ์ด๊ธด๋ค 21:
- Richard Sutton์ ์ ๋ช ํ ๋ธ๋ก๊ทธ ๊ธ Bitter Lesson์์ AI ์ญ์ฌ๋ ์ผ๋ฐ์ ยท๊ณ์ฐ ํจ์จ์ ยทํ์ฅ ๊ฐ๋ฅํ ๋ฐฉ๋ฒ์ด ๋๋ฉ์ธ ์ง์์ ์ด๊ธด๋ค๋ ๊ฒ์ ๋ฐ๋ณต์ ์ผ๋ก ๋ณด์ฌ์ค๋๋ค.
- Chain-of-Thought ์ถ๋ก ์กฐ์ฐจ 100B ์ด์ ๋ชจ๋ธ์์๋ง ํจ๊ณผ๊ฐ ๋ํ๋ฉ๋๋ค 22.
์ด๋ ์ ๋ฌธ๊ฐ์ ๋๋ฉ์ธ ์ง์ยท์์์ Feature๊ฐ ์์ ๊ณ์ฐ๊ณผ ํ์ต๋ ํํ์ ๋ฐ๋ฆฐ๋ค๋ ๊ฒฝํ์ ๊ด์ฐฐ์ ๋๋ค.
- ๊ทธ๋ ๋ค๊ณ ๋ชจ๋ ์ ๋ฌธ์ฑ์ด ๋ฌด์๋ฏธํ ๊ฒ์ ์๋๋๋ค.
- AlphaFold 23 ๋ Blackbox Deep Learning๊ณผ ์๋ฌผํ ์ฌ์ ์ง์(์งํ์ ์ผ๋ก ๊ฐ๊น์ด ์์ด, ๋์กฑ ๋จ๋ฐฑ์ง์ 3D ์ขํ)์ ๊ฒฐํฉํด ๋จ๋ฐฑ์ง ๊ตฌ์กฐ ์์ธก์์ ๊ฑฐ์ ์คํ ์์ค ์ ํ๋๋ฅผ ๋ฌ์ฑํ์ต๋๋ค.
- ๊ฐ๋ ฅํ ๋จธ์ ๋ฌ๋๊ณผ ๋๋ฉ์ธ ์ ๋ฌธ์ฑ์ ๊ฒฐํฉ์ด ์์ง๋ ํฉ๋นํ ์ ๋ต์ ๋๋ค.
- Hinton์ 2024 BBC ์ธํฐ๋ทฐ์์ LLM์ด ์ค์ ๋ก ์์ฐ์ด๋ฅผ ์ดํดํ๋ค๊ณ ์ฃผ์ฅํฉ๋๋ค.
- ๊ทธ์ ๊ด์ ์์ LLM์ ๋๊ฐ ์ธ์ด๋ฅผ ์ดํดํ๋ ๋ฐฉ์์ ๋ํ ํ์ฌ ์ฐ๋ฆฌ์ ์ต์ ์ ์ด๋ก ์ด๊ธฐ๋ ํฉ๋๋ค.
Summary
- 40์ฌ ๋
์ ํ์ ์ ๊ณ๋ณด๋ฅผ ํ ์ค๋ก ์์ฝํ๋ฉด ๋ค์๊ณผ ๊ฐ์ต๋๋ค:
- 1980s ใ ฃ ๋ถ์ฐ ํํยท์ญ์ ํ(Rumelhart, Hinton)
- 2003 ใ ฃ Bengio โ ๋ถ์ฐ ํํ ๊ธฐ๋ฐ ์ ๊ฒฝ ํ๋ฅ ์ ์ธ์ด ๋ชจ๋ธ
- 2012 ใ ฃ AlexNet โ ๋๊ท๋ชจ ์ ๊ฒฝ๋ง ํ์ต์ ๊ฐ๋ง
- 2013 ใ ฃ Word2Vec โ ํ์ฅ ๊ฐ๋ฅํ ์๋ฒ ๋ฉ ํ์ต
- 2014 ใ ฃ Seq2Seq, RNN encoder-decoder
- 2014 ใ ฃ Bahdanau โ NMT์์์ Attention
- 2015 ใ ฃ Luong โ Attention์ ํํ ์ ๋ฆฌ
- 2017 ใ ฃ Transformer โ โAttention is all you needโ
- 2018 ใ ฃ GPT โ ์์ฑ์ ์ฌ์ ํ์ต
- 2019 ใ ฃ BERT โ ์๋ฐฉํฅ Masked Language Model
- 2017~ ใ ฃ RLHF โ ์ธ๊ฐ ์ ํธ ๊ธฐ๋ฐ ์ ๋ ฌ
- ํ์ฌ์ LLM
- OpenAI GPT ๊ณ์ด (GPT-1 ~ GPT-4)
- Google Gemini, PaLM, LaMDA, Gopher, BERT
- Anthropic Claude (Haiku, Sonnet, Opus)
- Meta LLaMA
- Open-weight: DeepSeek-R1 ๋ฑ
- ๋ณธ์ง์ ๋ชจ๋ ๋๊ท๋ชจ๋ก ์ฌ์ ํ์ต๋ Transformer ๊ณ์ด, next-word prediction ๊ธฐ๋ฐ
- ํฌ๊ธฐ/๊ท๋ชจ ๋ณํ
- GPT-1 ใ ฃ ~117M ํ๋ผ๋ฏธํฐ
- GPT-2 ใ ฃ ~1.5B
- GPT-3 ใ ฃ ~175B
- Gopher (2021) ใ ฃ 280B
- PaLM (2022) ใ ฃ 540B
- ํ์ฌ์ ๋ชจ๋ธ์ trillion ๊ท๋ชจ์ ๋๋ฌํ ๊ฒ์ผ๋ก ์ถ์ ๋ฉ๋๋ค.
Conclusion
- LLM์ ํ๋์ ํ์ ์ด ์๋๋ผ 40์ฌ ๋
๊ฐ์ ์ฐ๊ตฌ๋ค์ด ๋์ ๋ ๊ฒฐ๊ณผ์
๋๋ค.
- ๊ฐ ๋จ๊ณ๋ ์ ๋จ๊ณ์ ํ๊ณ๋ฅผ ํ๊ธฐ ์ํ ์ต์ ๋ณ๊ฒฝ์ ๊ฐ๊น์ ๊ณ , ๊ท๋ชจ(scale)์ ํ์ด ๊ฒฐํฉ๋๋ฉฐ ํ์ฌ์ ์ฑ๋ฅ์ ๋ง๋ค์ด๋์ต๋๋ค.
- LLM์ ๋ ๊ฐ์ง ์๋ฆฌ:
- Attention ใ ฃ ๋ฌธ๋งฅ ์๋์ฐ์ ํ๊ณ๋ฅผ ํธ๋ ๋ฐฉ๋ฒ์ ์งํ โ ๊ณ ์ ๋ฒกํฐ(RNN) โ ๊ฐ์คํฉ(Bahdanau) โ ๋ณ๋ ฌํ ๊ฐ๋ฅํ dot-product(Transformer)
- Bitter Lesson ใ ฃ ๋จ์ํ ์์ด๋์ด๋ฅผ ๊ท๋ชจ๋ก ํ์ตํ ๋ ์ด๊ธด๋ค
- ํ์ฌ์ LLM์ ๋ค์ ๋ฐ๋ผ๋ณด๋ฉด:
- ์๊ธฐํ๊ท ํ๋ ์์ํฌ๋ Bengio 2003 ๊ทธ๋๋ก์ ๋๋ค.
- ๋ค๋ฅธ ์ ์ ์ค์ผ์ผ, ๋ฐ์ดํฐ, ์ฌ์ ํ์ต ์ ์ฐจ, ๊ทธ๋ฆฌ๊ณ ์ ๋ ฌ(RLHF)์ ๋๋ค.
- ๋จ์ ๊ณผ์ ๋ค๋ ์ฌ์ ํ ๋ง์ต๋๋ค:
- ์ ์ค์ผ์ผ์ด ์๋ํ๋๊ฐ? ๋ช ํํ ์ด๋ก ์ ์ค๋ช ์ ์์ต๋๋ค.
- ์ ๋ ฌ์ ์ด๋ป๊ฒ ์ผ๋ฐํ๋๋๊ฐ? ์ด๋ฆฐ ๋ฌธ์ ์ ๋๋ค.
- ์ด๋ ์ง์ ์์ ๋ค์ ํจ๋ฌ๋ค์์ด ํ์ํ ๊น? ์ ์ ์์ต๋๋ค.
References
Brown, Peter F., et al. โA statistical approach to machine translation.โ Computational Linguistics 16.2 (1990): 79-85.ย ↩︎
Markov, Andrey. โExample of a statistical investigation of the text Eugene Onegin concerning the connection of samples in chains.โ (1913).ย ↩︎
Bengio, Yoshua, et al. โA neural probabilistic language model.โ Journal of Machine Learning Research 3 (2003): 1137-1155.ย ↩︎ย ↩︎2
Krizhevsky, Alex, Ilya Sutskever, and Geoffrey E. Hinton. โImageNet classification with deep convolutional neural networks.โ Advances in Neural Information Processing Systems 25 (2012).ย ↩︎
Mikolov, Tomas, et al. โEfficient estimation of word representations in vector space.โ arXiv preprint arXiv:1301.3781 (2013).ย ↩︎ย ↩︎2
Mikolov, Tomas, et al. โDistributed representations of words and phrases and their compositionality.โ Advances in Neural Information Processing Systems 26 (2013).ย ↩︎
Mikolov, Tomas, Wen-tau Yih, and Geoffrey Zweig. โLinguistic regularities in continuous space word representations.โ NAACL-HLT (2013).ย ↩︎ย ↩︎2
Peters, Matthew E., et al. โDeep contextualized word representations.โ NAACL-HLT (2018).ย ↩︎
Kalchbrenner, Nal, and Phil Blunsom. โRecurrent continuous translation models.โ EMNLP (2013).ย ↩︎
Cho, Kyunghyun, et al. โLearning phrase representations using RNN encoderโdecoder for statistical machine translation.โ EMNLP (2014).ย ↩︎ย ↩︎2
Sutskever, Ilya, Oriol Vinyals, and Quoc V. Le. โSequence to sequence learning with neural networks.โ NeurIPS (2014).ย ↩︎
Bahdanau, Dzmitry, Kyunghyun Cho, and Yoshua Bengio. โNeural machine translation by jointly learning to align and translate.โ arXiv preprint arXiv:1409.0473 (2014).ย ↩︎
Luong, Minh-Thang, Hieu Pham, and Christopher D. Manning. โEffective approaches to attention-based neural machine translation.โ arXiv preprint arXiv:1508.04025 (2015).ย ↩︎ย ↩︎2ย ↩︎3
Cheng, Jianpeng, Li Dong, and Mirella Lapata. โLong short-term memory-networks for machine reading.โ EMNLP (2016).ย ↩︎
Vaswani, Ashish, et al. โAttention is all you need.โ Advances in Neural Information Processing Systems 30 (2017).ย ↩︎ย ↩︎2
Radford, Alec, et al. โImproving language understanding by generative pre-training.โ (2018).ย ↩︎
Devlin, Jacob, et al. โBERT: Pre-training of deep bidirectional transformers for language understanding.โ NAACL-HLT (2019).ย ↩︎
Christiano, Paul F., et al. โDeep reinforcement learning from human preferences.โ Advances in Neural Information Processing Systems 30 (2017).ย ↩︎
Schulman, John, et al. โProximal policy optimization algorithms.โ arXiv preprint arXiv:1707.06347 (2017).ย ↩︎
Wei, Jason, et al. โChain-of-thought prompting elicits reasoning in large language models.โ Advances in Neural Information Processing Systems 35 (2022).ย ↩︎
Jumper, John, et al. โHighly accurate protein structure prediction with AlphaFold.โ Nature 596.7873 (2021): 583-589.ย ↩︎