Hidden Pitfalls of Cosine Similarity Loss

  Рет қаралды 1,569

Tunadorable

Tunadorable

Күн бұрын

Пікірлер: 6
@tclf90
@tclf90 3 ай бұрын
this growing norm stuff happens pretty much across all linear layers during training... it is interesting that someone brings this up
@timeless8
@timeless8 3 ай бұрын
I love geometric intuitions and analogies.
@Lolleka
@Lolleka 3 ай бұрын
Fascinating. So using the combo of norm layer and gradient descent is sub-optimal in terms of computational efficiency? The more you know.
@beagle989
@beagle989 3 ай бұрын
good video, I'm tired too 😴 you're a good explainer, keep it up!
@tiagotiagot
@tiagotiagot 2 ай бұрын
i not sure if this is just going over my head or if I'm onto something. If the issue is the steps are moving away from the surface of the unit hyphersphere, what if instead of doing the steps in a Cartesian-like space, you handled it like a generalization of quaternion-like rotations in whatever dimensionality you are dealing with?
@mordokai597
@mordokai597 3 ай бұрын
gpt4 Input: "explain the procedure of using dynamic learning with optimized cosine scheduler, warm up steps, and PPO gradient clipping, please" Output: "Dynamic learning with an optimized cosine scheduler, warm-up steps, and Proximal Policy Optimization (PPO) gradient clipping is a sophisticated approach used primarily in reinforcement learning (RL) to improve the performance and stability of training. Here’s a detailed explanation of the procedure: ### 1. Dynamic Learning with Optimized Cosine Scheduler **Cosine Annealing Scheduler:** - This scheduler adjusts the learning rate following a cosine curve, starting from a maximum value and gradually decreasing to a minimum value, then potentially resetting. The advantage of this approach is that it can help the model converge more smoothly and avoid overshooting minima in the loss landscape. - **Formula:** \[ \eta_t = \eta_{\text{min}} + \frac{1}{2} (\eta_{\text{max}} - \eta_{\text{min}}) \left(1 + \cos\left(\frac{t \pi}{T} ight) ight) \] where \(\eta_t\) is the learning rate at time \(t\), \(\eta_{\text{max}}\) is the initial learning rate, \(\eta_{\text{min}}\) is the minimum learning rate, and \(T\) is the total number of training steps in one cycle. ### 2. Warm-up Steps **Warm-up Period:** - Warm-up steps gradually increase the learning rate from a very low value to the initial maximum learning rate over a predefined number of iterations. This helps to stabilize the training in the initial phases, especially when starting with large gradients. - **Procedure:** 1. **Initial Phase:** For the first \(N_{\text{warmup}}\) steps, linearly increase the learning rate from \(\eta_{\text{start}}\) to \(\eta_{\text{max}}\). \[ \eta_t = \eta_{\text{start}} + t \cdot \frac{(\eta_{\text{max}} - \eta_{\text{start}})}{N_{\text{warmup}}} \] 2. **Post Warm-up:** After the warm-up period, switch to the cosine annealing scheduler for the rest of the training steps. ### 3. PPO Gradient Clipping **Proximal Policy Optimization (PPO):** - PPO is an RL algorithm designed to maintain a balance between exploration and exploitation while ensuring stable training by limiting the extent to which the policy can change at each training step. - **Gradient Clipping:** - Gradient clipping is used to prevent the gradients from becoming too large, which can cause instability during training. This is typically implemented by clipping the gradients to a maximum norm. - **Formula:** \[ \text{clipped\_gradient} = \text{clip}(g, -\epsilon, \epsilon) \] where \(g\) is the gradient and \(\epsilon\) is the clipping threshold. ### Combined Procedure 1. **Initialization:** - Set the initial learning rate \(\eta_{\text{start}}\), maximum learning rate \(\eta_{\text{max}}\), minimum learning rate \(\eta_{\text{min}}\), warm-up steps \(N_{\text{warmup}}\), total training steps \(T\), and gradient clipping threshold \(\epsilon\). 2. **Warm-up Phase:** - For \(t\) in range \(0\) to \(N_{\text{warmup}}\): \[ \eta_t = \eta_{\text{start}} + t \cdot \frac{(\eta_{\text{max}} - \eta_{\text{start}})}{N_{\text{warmup}}} \] 3. **Cosine Annealing Phase:** - For \(t\) in range \(N_{\text{warmup}}\) to \(T\): \[ \eta_t = \eta_{\text{min}} + \frac{1}{2} (\eta_{\text{max}} - \eta_{\text{min}}) \left(1 + \cos\left(\frac{(t - N_{\text{warmup}}) \pi}{T - N_{\text{warmup}}} ight) ight) \] 4. **Gradient Clipping in PPO:** - During the training updates, compute the gradients \(g\) and apply clipping: \[ g_{\text{clipped}} = \text{clip}(g, -\epsilon, \epsilon) \] - Use \(g_{\text{clipped}}\) for updating the policy parameters. ### Summary By integrating these components, the training process benefits from a smooth start with warm-up steps, stable convergence with the cosine annealing scheduler, and robustness against gradient explosion with gradient clipping in PPO. This combination enhances the efficiency and effectiveness of the learning process in RL tasks."
Can LLMs Learn by Teaching Other LLMs?
28:56
Tunadorable
Рет қаралды 1,5 М.
Every attention head explained
33:05
Tunadorable
Рет қаралды 2,5 М.
the balloon deflated while it was flying #tiktok
00:19
Анастасия Тарасова
Рет қаралды 33 МЛН
Всё пошло не по плану 😮
00:36
Miracle
Рет қаралды 4,3 МЛН
When mom gets home, but you're in rollerblades.
00:40
Daniel LaBelle
Рет қаралды 78 МЛН
Simple changes can MASSIVELY improve transformers
19:28
Tunadorable
Рет қаралды 3,3 М.
Every Unsolved Math Problem Solved
13:41
ThoughtThrill
Рет қаралды 256 М.
Hardest Exam Question | Only 8% of students got this math question correct
11:28
01L - Gradient descent and the backpropagation algorithm
1:51:04
Alfredo Canziani (冷在)
Рет қаралды 57 М.
A guide to our alphabet
20:08
RobWords
Рет қаралды 165 М.
Principles of Beautiful Figures for Research Papers
1:01:14
ChuScience
Рет қаралды 72 М.
the balloon deflated while it was flying #tiktok
00:19
Анастасия Тарасова
Рет қаралды 33 МЛН