[유튜브 강의 정리] 안드레 카파시 - Deep Dive into LLMs like ChatGPT

Introduction

Pre-Training

Step 1: Download and preprocess the internet

Step 2: Tokenization

Step 3: Neural network training

Step 4: Inference

Base model

Post-Training: Supervised Finetuning

Conversations

Hallucinations

Knowledge of Self

Models need tokens to think

Things the model cannot do well

Post-Training: Reinforcement Learning

Reinforcement learning

DeepSeek-R1

AlphaGo

Reinforcement learning from human feedback (RLHF)

Preview of things to come

Keeping track of LLMs

Where to find LLMs

Step 3: Neural network training

1. 신경망의 입력 (Neural Network Input)

입력 데이터: 토큰 시퀀스

  • 모델은 텍스트가 아닌 숫자(Token ID 시퀀스)를 입력으로 받음.

  • 예제: "Hello world" → ["Hello", " world"] → [15339, 1917] (토큰 ID)

  • 윈도우 길이: 모델은 입력된 문장을 고정된 길이의 토큰 시퀀스(윈도우)로 분할하여 처리함. (위 예시 사진의 경우 윈도우 크기 4)


2. 신경망의 출력 (Neural Network Output)

출력 데이터: 다음 토큰 확률 분포

  • 모델은 모든 가능한 토큰에 대한 확률(Probability Distribution)을 예측함.

  • 가장 확률이 높은 토큰을 선택하여 문장을 완성(Greedy Decoding)

  • 또는 일정 확률에 따라 샘플링하여 다양한 문장을 생성(Temperature Sampling).


3. 훈련 과정 (Training Process)

💡 모델이 훈련되는 방식은 "다음 토큰 예측"을 반복하는 과정!

  1. 입력: 윈도우(Window) 크기의 토큰 시퀀스 제공

  2. 출력: 다음 토큰의 확률 분포 예측

  3. 정답(실제 다음 토큰)과 비교하여 손실(Loss) 계산

  4. 손실을 줄이도록 신경망 가중치(Weights) 업데이트

📌 예제

입력: ["The", "quick", "brown", "fox"]
출력: 확률 분포 {"jumps": 85%, "runs": 10%, "flies": 5%}
정답: "jumps"
손실 계산: 1 - 0.85 = 0.15
가중치 업데이트: 정답 확률을 높이는 방향으로 조정

➡️ 이 과정을 수십억 개의 문장에 대해 반복하여 모델이 언어 패턴을 학습함.