CS3 – How Are AI Models Trained?
Class Notes
1. What Does “Training an AI Model” Mean?
Training an AI model means teaching a computer to recognize patterns by showing it many examples. Instead of giving the computer step-by-step rules, we let it learn the rules from data.
Example: To recognize cats, we show the AI thousands of cat photos. The model figures out what patterns make something look like a “cat.”
2. The Machine Learning Pipeline
AI models are usually trained through a four-step cycle:
Step 1 — Collect Data
- Images, text, numbers, audio, sensor readings, etc.
- The more high-quality data, the better the model can learn.
- For supervised learning, data must be clean, organized, and labeled.
Examples of training data: handwritten digits, movie reviews, animal photos, chat logs, documents, and code.
Step 2 — Train the Model (Find Patterns)
During training, the model adjusts its internal settings (called weights) to reduce mistakes.
- The model makes a prediction.
- A loss function measures how wrong it was.
- The model updates its weights.
- This repeats thousands or millions of times.
This optimization process is usually done with an algorithm called gradient descent, which gives the model feedback after every mistake.
Step 3 — Test the Model
We use a separate set of data that the model has never seen before (the test set).
- Checks whether the model actually learned the pattern instead of memorizing.
- Reveals accuracy, bias, and weak areas.
Step 4 — Deploy the Model
Once the model performs well, it is deployed to be used in the real world:
- Chatbots answering questions.
- Self-driving cars detecting signs and lanes.
- Translation apps converting between languages.
- Robots reacting to sensor data.
3. Types of Training
A. Supervised Learning
Learning from labeled examples.
- Photo → label “cat”.
- Email → label “spam” or “not spam”.
- House features → predicted price.
Used for: classification, prediction, image recognition, etc.
B. Unsupervised Learning
Learning from unlabeled data. The model finds hidden patterns on its own.
- Grouping customers by shopping behavior.
- Organizing images by similarity.
- Finding unusual or rare patterns (anomalies).
C. Reinforcement Learning
Learning by trial and error, similar to how humans learn skills.
- The AI takes an action.
- It receives a reward or penalty.
- It adjusts its strategy to increase total reward.
Used in: video game AIs, robotics, self-driving cars, and fine-tuning systems like chatbots.
4. What Are AI “Weights”?
Weights are numerical values inside the model that control how strongly each input affects the output. During training:
- Correct predictions strengthen useful connections.
- Wrong predictions cause weights to be adjusted.
This is similar to how the human brain strengthens neural pathways as we learn.
5. Why Do AI Models Need So Much Data?
AI learns by seeing patterns repeatedly. More data helps with:
- Better accuracy.
- Reducing bias and improving fairness.
- Handling unusual or difficult examples.
- Generalizing to new situations.
Large models (like modern language models) are trained on huge collections of books, articles, websites, conversations, and code.
6. Overfitting vs. Underfitting
Overfitting
- The model memorizes the training data but fails on new data.
- Very high accuracy on the training set, poor accuracy on the test set.
Underfitting
- The model is too simple and does not capture the pattern.
- Poor performance on both training and test data.
7. Training Requires Big Computing Power
Training modern AI models is computationally expensive. It often uses:
- GPUs (Graphics Processing Units).
- TPUs (Tensor Processing Units).
- Large clusters of machines working together.
These systems can perform billions of calculations per second, and large models may take days, weeks, or months to train.
8. Ethics in AI Training
AI models can inherit problems from the data they are trained on.
- Bias and unfair treatment of certain groups.
- Privacy issues when using personal data.
- Exposure to harmful or inappropriate content.
- Environmental impact from high energy use.
Ethical AI requires careful data selection, filtering harmful examples, monitoring results, and including human oversight.
9. Summary (Student-Friendly Version)
10. Quick Check for Understanding
- Why do AI models need lots of data?
- What is the difference between supervised and unsupervised learning?
- What does the loss function do during training?
- Why do we test a model with new (unseen) data?
- What is one ethical issue that can appear when training AI models?