LLM Learning Roadmap
✨ Awesome-Anything
🖼️ Digital Image Processing
🍃 LLM Components
🌱 LLM Pre-training
☘️ LLM Post-Training
🍀 LLM Popular Models
🪴 LLM Applications
🌿 LLM Optimization
🌾 LLM Compression
🌵 LLM Hands-on Practice
🌴 LLM Must-read Papers
🌳 LLM Q&A
🐝 VLM Image Encoders
📝 MISC.
10.6 Why LLM training rarely adopts Dropout?
The reason for not using Dropout during LLM training is not about LLM, but it’s about regression tasks. Let’s start with analyzing what the Dropout is doing.
1. Dropout Formula
Here we analyze how dropout affects the statistical properties of a neuron's output. We focus on the common implementation known as
"Inverted Dropout".Let
h be the original output of a neuron. Let p be the dropout probability (the probability of setting the output to zero).With inverted dropout, the output
h′ after dropout is defined as:The scaling by
1−p is a step that ensures the expected value of the output remains the same, which helps keep the network's behavior consistent between training and inference.To analyze this, we can model the process using a Bernoulli random variable
d, where:Then, the output
h′ can be written as:2. Dropout Mean
Let's find the expected value of the output
h′, denoted as E[h′]. We assume that the dropout mask d and the neuron's output h are independent. Let .Leveraging the independence of
d and h:The expected value of the Bernoulli variable
d is . Substituting this in:Clearly, The mean of the neuron's output does not change after applying the inverted dropout.
3. Dropout Variance
Now, let's compute the variance of
h′, denoted as Var(h′). Let .The formula for variance is . So we have
We already know , so . Next, we compute :
Still assuming independence, . Then for a Bernoulli variable
d, (since and ). Therefore, . We also know that , which means .Substituting these results back into the equation for :
Finally, we can calculate the variance of
h′:We can simplify this expression as:
Therefore, the variance of the output increases. The new variance depends on the original variance , the original mean , and the dropout probability
p.4. Why Dropout May Hurt Performance in Regression Tasks
After the Dropout layer, the output is passed through a non-linear layer (e.g., Linear + ReLU). Non-linear layers transform the input distribution. For example, ReLU sets all values below 0 to 0.
This transformation means that the output mean of the non-linear layer becomes a function of both the mean and variance of the Dropout output.
Although Dropout preserves the mean during inference (by scaling), it changes the variance. This variance shift causes the output mean of the non-linear layer to shift, leading to biased final predictions.
Impact on different tasks
- In regression tasks, this output shift can significantly affect performance since the model outputs absolute values.
- In classification tasks, the model outputs logits (e.g., 0 or 1), so it's more robust to such variance-induced shifts.
In Conclusion, when we use Dropout, we are basically balancing between the pros of preventing overfitting brought by Dropout and the cons of distribution shifts brought still by Dropout.
It’s just because the classification tasks are more robust to such cons, so the pros win, and we get what we want, but we don’t get the same on regression tasks because of the nature of
“regression”.Is LLM Training a Regression Task?
Let’s take pre-training as an example, where a teacher-forcing strategy is applied. In this case, we are using cross-entropy loss and softmax, which makes it look like a classification task in each step, i.e., based on previous tokens, choosing the next token.
But unlike traditional classification tasks, the autoregressive nature of LLM makes it a multi-step, multi-class, multi-label classification task. The overall objective is much more complex than a simple classification task.
- Multi-step:
- predict token 1 based on token 0
- predict token 2 based on tokens 0, 1
- predict token 3 based on tokens 0, 1, 2
- ...
- Multi-class:
- There are around
100,000classes (tokens)
- Multi-label:
- For the same input, the output is not unique, for example:
- Input:
“I love” - Output:
Dog,Cat,LLM, ...
Therefore, in essence, it’s not really predicting an absolutely correct answer like in traditional classification tasks like Cat&Dog classification. It’s more like
scoring or ranking.In a given context, some words or tokens have a higher probability of occurring, though not necessarily a probability of 1, while others have a lower probability, but not zero.
When the context changes, the probability distribution shifts accordingly. However, no token is ever guaranteed to be the next one, nor is any token ever completely ruled out.
Therefore, the task that LLMs are trying to solve is a regression task.
Prev
10.5 What is QK-Norm?
Next
10.7 Dropout and DropPath
Loading...