Getting Started with Fine-Tuning
Click the Run Fine-Tuning
button in the practice environment to start fine-tuning based on the uploaded training data and the configured hyperparameters.
Once fine-tuning is complete, you can interact with the tuned model (a fifty-year-old woman speaking in a Southern dialect) on the right side of the practice environment.
Note: As mentioned in previous lessons, due to policy/technical issues, the fine-tuned model experienced in the practice environment uses a model fine-tuned by CodeFriends.
What Happens During Training?
During fine-tuning, the weights and biases of the AI model are updated according to the set hyperparameters.
-
Weights: Determine how important specific features of input data are.
-
Bias: A value that adjusts the model’s output to prevent it from being skewed in a particular direction, controlling the activation function of the neural network.
To metaphorically describe weights and biases, consider the following:
-
Weights are like adjusting the amount of each ingredient when making bread. For example, controlling the amount of sugar affects the sweetness.
-
Bias is like the default flavor — deciding how much sugar to add as a basic addition to the bread.
-
Training Process involves periodically tasting and gradually adjusting ingredient amounts to find the optimal taste.
The Fine-Tuning Process
1. Initialization
When starting AI model training, weights and biases are initially set randomly.
For fine-tuning, the weights and biases from the previous model are used as initial values.
2. Forward Propagation
Input data is passed through the model. Each input value is multiplied by the weight and added to the bias to calculate the output value.
For example, in y = wx + b
, y
is the output, w
is the weight, x
is the input, and b
is the bias.
3. Loss Calculation
Calculate the loss value by measuring the difference between the model's predicted value (output) and the actual value (truth). Loss indicates how incorrect the model's prediction is.
For instance, if the predicted value is 5 and the actual value is 3, the loss is the difference between the two. (For example, using the mean squared error function, (5-3)^2 = 4)
4. Backpropagation
Determine how to adjust the weights and biases to reduce the loss value.
To achieve this, calculate how much each weight and bias contributes to the loss value. This process involves using differentiation to obtain the gradient.
5. Updating Weights and Biases
Use the calculated gradient to update the weights and biases. Adjustments are made in the direction of reducing the loss value.
Want to learn more?
Join CodeFriends Plus membership or enroll in a course to start your journey.