๐ GPT๋?
GPT๋ "Generative Pre-trained Transformer"์ ์ฝ์์ ๋๋ค.
| ๋จ์ด | ์๋ฏธ |
| Generative | ๋ฌธ์ฅ์ ์์ฑํ๋ ๋ชจ๋ธ |
| Pre-trained | ๋ฏธ๋ฆฌ ๋๊ท๋ชจ ๋ฐ์ดํฐ๋ก ํ์ตํ ํ ๋ค์ํ ์์ ์ ์ฌ์ฉ |
| Transformer | ํธ๋์คํฌ๋จธ๋ผ๋ ๋ฅ๋ฌ๋ ์ํคํ ์ฒ๋ฅผ ๊ธฐ๋ฐ์ผ๋ก ํจ (ํนํ ๋์ฝ๋ ๊ตฌ์กฐ๋ง ์ฌ์ฉ) |
๐ง GPT์ ๊ตฌ์กฐ: ๋์ฝ๋๋ง ์ฌ์ฉํ๋ ํธ๋์คํฌ๋จธ
GPT๋ ํธ๋์คํฌ๋จธ(Transformer) ๊ตฌ์กฐ ์ค ๋์ฝ๋๋ง ์ฌ์ฉํฉ๋๋ค.
์ด๋ ๋ค์๊ณผ ๊ฐ์ ๊ตฌ์ฑ ์์๋ก ์ด๋ฃจ์ด์ ธ ์์ด์:
๐ GPT ๋์ฝ๋์ ๊ตฌ์ฑ ์์
- Input Tokens: ์ ๋ ฅ ๋ฌธ์ฅ์ ํ ํฐํํ์ฌ ์ซ์ ์ํ์ค๋ก ๋ณํํฉ๋๋ค.
- Token Embedding: ๊ฐ ํ ํฐ์ ๊ณ ์ฐจ์ ๋ฒกํฐ๋ก ๋งคํํ์ฌ ์๋ฏธ๋ฅผ ๋ถ์ฌํฉ๋๋ค.
- Positional Encoding: ํ ํฐ์ ์์ ์ ๋ณด๋ฅผ ์ถ๊ฐํ์ฌ ๋ฌธ๋งฅ์ ์ดํดํ ์ ์๊ฒ ํฉ๋๋ค.
- Transformer Decoder Blocks: ๋ค์์ ๋์ฝ๋ ๋ธ๋ก์ผ๋ก ๊ตฌ์ฑ๋๋ฉฐ, ๊ฐ ๋ธ๋ก์ ๋ค์์ ํฌํจํฉ๋๋ค:
- Masked Multi-Head Self-Attention: ํ์ฌ ์์น์ ํ ํฐ์ด ์ด์ ํ ํฐ๋ค๋ง์ ์ฐธ์กฐํ๋๋ก ๋ง์คํนํ์ฌ ์๊ธฐ ์ฃผ์ ๋ฉ์ปค๋์ฆ์ ์ ์ฉํฉ๋๋ค.
- Feed Forward Network (FFN): ๊ฐ ํ ํฐ ์์น์์ ๋ ๋ฆฝ์ ์ผ๋ก ์๋ํ๋ ์์ ์ฐ๊ฒฐ ์ ๊ฒฝ๋ง์ ๋๋ค.
- Residual Connections & Layer Normalization: ํ์ต ์์ ์ฑ๊ณผ ์ฑ๋ฅ ํฅ์์ ์ํด ์์ฐจ ์ฐ๊ฒฐ๊ณผ ์ธต ์ ๊ทํ๋ฅผ ์ฌ์ฉํฉ๋๋ค.
- Linear Layer: ๋์ฝ๋ ๋ธ๋ก์ ์ถ๋ ฅ์ ์ดํ ํฌ๊ธฐ๋งํผ์ ์ฐจ์์ผ๋ก ๋ณํํฉ๋๋ค.
- Softmax: ๊ฐ ๋จ์ด์ ๋ํ ํ๋ฅ ๋ถํฌ๋ฅผ ๊ณ์ฐํ์ฌ ๋ค์์ ์ฌ ๋จ์ด๋ฅผ ์์ธกํฉ๋๋ค.
- Output Probabilities: ๊ฐ ๋จ์ด๊ฐ ๋ค์์ ์ฌ ํ๋ฅ ์ ๋ํ๋ด๋ฉฐ, ๊ฐ์ฅ ๋์ ํ๋ฅ ์ ๊ฐ์ง ๋จ์ด๊ฐ ์ ํ๋ฉ๋๋ค.
๐ ์ด ๊ตฌ์กฐ๋ ์ฌ๋ฌ ์ธต์ผ๋ก ๋ฐ๋ณต (์: GPT-2๋ 12์ธต, GPT-3๋ 96์ธต)
๐ GPT๋ ์ด๋ป๊ฒ ์๋ํ๋?
๐ง ํ์ต ๋ฐฉ์: ์ธ์ด ๋ชจ๋ธ๋ง (Language Modeling)
GPT๋ “์์ ๋์จ ๋จ์ด๋ค์ ๋ณด๊ณ , ๋ค์ ๋จ์ด๋ฅผ ์์ธกํ๋ ๊ฒ”์ ๋ชฉํ๋ก ํ์ตํฉ๋๋ค.
graph TD
A[Input Tokens] --> B[Token Embedding]
B --> C[Positional Encoding]
C --> D[Transformer Decoder Blocks]
D --> E[Linear Layer]
E --> F[Softmax]
F --> G[Output Probabilities]
์์:
์ด๋ฌํ ์์ผ๋ก ์๋ง์ ํ
์คํธ๋ฅผ ํ์ตํ๋ฉด์
๋จ์ด์ ์๋ฏธ, ๋ฌธ๋ฒ, ๋ฌธ์ฅ ๊ตฌ์กฐ, ๋ฌธ๋งฅ๊น์ง ์์ฐ์ค๋ฝ๊ฒ ํ์ตํ๊ฒ ๋ฉ๋๋ค.
๐งช GPT์ ํ๋ จ ๊ณผ์
1. Pre-training (์ฌ์ ํ์ต)
- ์ธํฐ๋ท, ์ํค๋ฐฑ๊ณผ, ๋ด์ค ๋ฑ ๋ฐฉ๋ํ ํ ์คํธ๋ก ํ์ต
- ๋ชฉํ: ๋ค์ ๋จ์ด ์์ธก
2. Fine-tuning (๋ฏธ์ธ ์กฐ์ )
- ํน์ ์์ (์: ๋ฒ์ญ, ์์ฝ, ๋ํ ๋ฑ)์ ๋ง๊ฒ ์ถ๊ฐ ํ์ต
- ์: ChatGPT๋ ๋ํ์ ํนํ๋๋๋ก ํ๋๋จ
3. Reinforcement Learning from Human Feedback (RLHF)
(GPT-3.5 ์ดํ)
- ์ฌ๋์ด ํ๊ฐํ ๊ฒฐ๊ณผ๋ฅผ ํตํด ๋ชจ๋ธ์ ์ถ๋ ฅ์ ๋ "์ฌ๋๋ต๊ฒ" ๋ค๋ฌ์
๐ GPT ์๋ฆฌ์ฆ ๋ฐ์
| ๋ฒ์ | ์ฐ๋ | ํน์ง |
| GPT-1 | 2018 | ๊ฐ๋ ์ฆ๋ช , 117M ํ๋ผ๋ฏธํฐ |
| GPT-2 | 2019 | ์ธ์ด ์์ฑ ๋ฅ๋ ฅ ํฅ์, 1.5B ํ๋ผ๋ฏธํฐ |
| GPT-3 | 2020 | 175B ํ๋ผ๋ฏธํฐ, ๋ฉํฐํ์คํฌ ์ํ |
| GPT-3.5 | 2022 | ChatGPT์ ์ฌ์ฉ, ๋ํ ์ต์ ํ |
| GPT-4 | 2023 | ์ถ๋ก ๋ ฅ ์ฆ๊ฐ, ๋ฉํฐ๋ชจ๋ฌ ์ง์ (์ด๋ฏธ์ง ํฌํจ) |
| GPT-4o | 2024 | Omni ๋ชจ๋ธ, ์ค์๊ฐ ์ค๋์ค/๋น์ /ํ ์คํธ ํตํฉ ๊ฐ๋ฅ |
๐งฉ GPT vs BERT vs T5
| ํญ๋ชฉ | GPT | BERT | T5 |
| ๊ตฌ์กฐ | ๋์ฝ๋ | ์ธ์ฝ๋ | ์ธ์ฝ๋ + ๋์ฝ๋ |
| ๋ฐฉํฅ์ฑ | ๋จ๋ฐฉํฅ (์ผ→์ค) | ์๋ฐฉํฅ | ์๋ฐฉํฅ |
| ๋ชฉ์ | ์์ฑ | ์ดํด | ๋ณํ (์ ๋ ฅ→์ถ๋ ฅ) |
| ์ | ์๋ฌธ, ๋ํ, ์์ฝ | ๋ถ๋ฅ, QA | ๋ฒ์ญ, ์์ฝ |
๐ GPT์ ํ์ฉ ๋ถ์ผ
| ๋ถ์ผ | ์ ์ฉ ์์ |
| ๋ฌธ์ ์์ฑ | ๊ธ์ฐ๊ธฐ, ๋ณด๊ณ ์ ์์ฑ, ์์ค ์ฐ๊ธฐ |
| ์ฝ๋ ์์ฑ | Copilot, ์ฝ๋ ์๋์์ฑ |
| ๋ํ AI | ChatGPT, AI ์๋ด์ฌ |
| ๊ฒ์/์์ฝ | ๊ธด ๊ธ ์์ฝ, ๋ฌธ์ ๊ฒ์ ์์ฝ |
| ์ฐฝ์ ์์ | ์, ๊ด๊ณ ๋ฌธ๊ตฌ, ์์ด๋์ด ๋์ถ |
โ ์ ๋ฆฌ ์์ฝ
| ํญ๋ชฉ | ์ค๋ช |
| GPT๋? | ํ ์คํธ๋ฅผ ์์ฑํ๋ ํธ๋์คํฌ๋จธ ๊ธฐ๋ฐ ์ธ์ด ๋ชจ๋ธ |
| ๊ตฌ์กฐ | ํธ๋์คํฌ๋จธ ๋์ฝ๋๋ง ์ฌ์ฉ, Masked Attention ๊ตฌ์กฐ |
| ์๋ ๋ฐฉ์ | ์ ๋จ์ด๋ฅผ ๋ณด๊ณ ๋ค์ ๋จ์ด ์์ธก (์ธ์ด ๋ชจ๋ธ๋ง) |
| ๊ฐ์ | ์์ฐ์ค๋ฌ์ด ๋ฌธ์ฅ ์์ฑ, ๋ฌธ๋งฅ ํ์ , ๋ค์ํ ์์ ์ ์ฉ |
| ์ฌ์ฉ ์ | ๋ํ, ์๋ฌธ, ์์ฝ, ๊ฒ์, ์ฝ๋ฉ ๋ฑ |
์ฐธ๊ณ : https://jalammar.github.io/illustrated-gpt2/
The Illustrated GPT-2 (Visualizing Transformer Language Models)
Discussions: Hacker News (64 points, 3 comments), Reddit r/MachineLearning (219 points, 18 comments) Translations: Simplified Chinese, French, Korean, Russian, Turkish This year, we saw a dazzling application of machine learning. The OpenAI GPT-2 exhibited
jalammar.github.io
https://dugas.ch/artificial_curiosity/GPT_architecture.html
The GPT-3 Architecture, on a Napkin
HOW DEEP IS THE MACHINE? The Artificial Curiosity Series The GPT-3 Architecture, on a Napkin There are so many brilliant posts on GPT-3, demonstrating what it can do, pondering its consequences, vizualizing how it works. With all these out there, it still
dugas.ch
'์ธ๊ณต์ง๋ฅ' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
| ๐ RAG๋? (0) | 2025.05.26 |
|---|---|
| ๐ง LangChain์ด๋? (0) | 2025.05.26 |
| ๋์ฝ๋๋ง ์ฌ์ฉํ๋ GPT (0) | 2025.05.26 |
| Variational Encoder (๋ณ๋ถ ์ธ์ฝ๋)๋? (1) | 2025.05.26 |
| ์ธ์ฝ๋๋ง ์ฌ์ฉํ๋ BERT (0) | 2025.05.26 |