Fine-tuning is a way to adapt an AI model that has already learned general patterns from a large amount of data. Instead of training a model from the very beginning, engineers start with a pretrained model and teach it a more specific task. This matters because it can save time, data, and computing power while improving performance for a particular use.
Examples include adapting a language model to answer science questions, summarize medical notes, or recognize objects in school lab photos.
During fine-tuning, the model sees labeled examples that match the new goal, makes predictions, and compares them with the correct answers. A loss function measures how wrong the predictions are, and an optimization method makes small changes to the model's weights. The learning rate controls how large those changes are, like a slider that adjusts how quickly the model updates.
Good fine-tuning uses clean data, careful testing, and safeguards to avoid memorizing examples or copying harmful patterns.
Key Facts
- Fine-tuning starts with a pretrained model and updates it for a more specific task.
- Training from scratch learns general patterns first, while fine-tuning adjusts existing patterns.
- Loss measures prediction error, often written as loss = error(prediction, label).
- A simple weight update can be written as new weight = old weight - learning rate × gradient.
- Smaller learning rates usually make slower but safer updates during fine-tuning.
- A validation set checks whether the fine-tuned model works on examples it did not train on.
Vocabulary
- Pretrained model
- A model that has already learned broad patterns from a large dataset before being adapted to a new task.
- Fine-tuning
- The process of training a pretrained model on a smaller, task-specific dataset to improve its performance for that task.
- Training data
- Examples used to teach a model, often including inputs and the correct outputs or labels.
- Loss function
- A mathematical rule that measures how far a model's prediction is from the correct answer.
- Overfitting
- A problem where a model performs well on training examples but poorly on new examples because it memorized details instead of learning general patterns.
Common Mistakes to Avoid
- Thinking fine-tuning creates a model from nothing is wrong because it usually begins with a model that has already learned general patterns.
- Using too little or low-quality data is a mistake because the model may learn errors, bias, or random noise from the examples.
- Setting the learning rate too high is wrong because large updates can damage useful knowledge already stored in the pretrained model.
- Judging success only on the training set is a mistake because high training accuracy can hide overfitting and poor performance on new data.
Practice Questions
- 1 A pretrained model is fine-tuned on 800 labeled examples. If 640 examples are used for training and the rest are used for validation, what percent of the dataset is used for validation?
- 2 A model makes 50 predictions on a validation set and gets 42 correct. What is its validation accuracy as a percent?
- 3 A student fine-tunes a chatbot on only 20 examples from one person's writing style, and it performs poorly on other students' questions. Explain the likely problem and one way to improve the fine-tuning process.