Date 2/24; Topic: 正确认识 ChatGPT -《MACHINE LEARNING (HUNG-YI LEE)》学习笔记
(MACHINE LEARNING 2023 SPRING)
Date 2/24; Topic: 正确认识 ChatGPT
Class Material
机器学习2023规则说明
略
ChatGPT 原理剖析 (1/3) —— 对 ChatGPT 的常见误解
ChatGPT 真正在做的事是“文字接龙”。
ChatGPT 原理剖析 (2/3) —— 预训练 (Pre-train)
预训练(自监督式学习)
ChatGPT 原理剖析 (3/3) —— ChatGPT所带来的研究问题
- 如何精确提出需求
- 如何更正错误
- 侦测 AI 生成的物件
- 避免泄露秘密
用 ChatGPT 和 Midjourney 来玩文字冒险游戏
略
Extra Material
ChatGPT (可能)是怎么炼成的
GPT = Generative Pre-trained Transformer
- 学习文字接龙
- 人类老师引导文字接龙的方向
- 模仿人类老师的喜好
- 用增强式学习向模拟老师学习
- (1) 想说什么就说什么
- (2 - 4) 引导 GPT 说人类要他说的
Optional Material
Regression (Case Study: Predicting Pokémon CP)
-
Step 1: Model
-
y = b + ∑(w_i \times x_i) -
-
-
Step 2: Goodness of Function
- Loss Function: Input a function and output how bad it is.
-
Step 3: Best Function
-
f^* = arg\ min L(f)
-
-
Gradient Descent(梯度下降法):
- Consider loss function L(w) with one parameter w:
- (Randomly) Pick an initial value w^0
- Compute
\dfrac{dL}{dw} \mid_{w=w^0} ;w^0 - η\dfrac{dL}{dw} \mid_{w=w^0} \rightarrow w^1 - Compute
\dfrac{dL}{dw} \mid_{w=w^1} ;w^1 - η\dfrac{dL}{dw}| \mid_{w=w^1} \rightarrow w^2 - ...Many iteration
How about two parameters?
-
w^*, b^* = arg\ min_{w,b} L(w, b) - (Randomly) Pick an initial value
w^0, b^0 - Compute
\dfrac{∂L}{∂w} \mid_{w=w^0,b=b^0}$,$\dfrac{∂L}{∂w} \mid_{w=w^0,b=b^0}
- more...
Gradient:
- ▽
L = [\dfrac{∂L}{∂w},\ \dfrac{∂L}{∂b}]
In linear regression, the loss function
Model Selection
- 一个更复杂的模型并不总会在测试集上产生更好的结果;
- Overfitting(过拟合);
- 选择合适的模型。
Back to step 1: Redesign the Model
- if
x_s = Pidgey :y = b_1 + w_1 \times x_cp - if
x_s = Weedle :y = b_2 + w_2 \times x_cp - more...
equal:
-
y = b_1 \times δ(x_s = Pidgey) + w_1 \times δ(x_s = Pidgey)x_cp + b_2 \times δ(x_s = Weedle) + w_2 \times δ(w_s == Weedle)x_cp + ... -
δ(x_s = Pidgey) = x_s == Pidgey\ ?\ 1\ :\ 0
Back to step 2: Regularization(正则化)
- 重新设计
loss 函数 - Training: larger λ, considering the training error less
- 我们倾向于更平滑的函数,但不要太平滑
- How smooth? Select λ obtaining the best model.
Classification (Case Study: Pokemon classification)
How to do Classification
- Training data for Classification
Ideal Alternatives
- Function (Model)
- Loss function
- Find the best function
- Example: Perceptron, SVM
Generative Model(生成模型)
Gaussian Distribution(正态分布)
- Input: vector x, output: probability of sampling x The shape of the function determines by mean μ and covariance matrix ∑
Maximum Likelihood(极大似然估计)
- Likelihood of a Gaussian with mean μ and covariance matrix ∑ = the probability of the Gaussian samples
We assume samples generate from the Gaussian (μ*, ∑*) with the maximum likelihood
Logistic Regression
Step 1: Function Set
-
f_{w,b}(x) = P_{w,b}(C_1|x) - Including all different
w andb
Step 2: Goodness of a Function
- Training Data:
-
x^1\ x^2\ x^3\ ...\ x^N -
C_1\ C_1\ C_2\ ...\ C_1
-
- Assume the data is generated based on
f_{w,b}(x) = P_{w,b}(C_1|x) -
L(w,b) = f_{w,b}(x^1)f_{w,b}(x^2)(1 - f_{w,b}(x^3))...f_{w,b}(x^N) - The most likely
w^* andb^* is the one with the largestL(w,b) . -
w^*, b^* = arg\ max_{w,b}\ L(w,b) -
w^*, b^* = arg\ min_{w,b}\ -lnL(w,b)
Step 3: Find the best function
- 分类问题,都用 one-hot + Cross-entropy
Generative v.s. Discriminative
- Benefit of gneerative model
- 在假设概率分布的情况下,需要的训练数据更少
- 在假设概率分布的情况下,对噪声的鲁棒性更强
- 先验概率和类相关概率可以从不同的来源进行估计
Multi-class Classification
- Softmax
级联逻辑回归模型
- Feature Transformation + Classification