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

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.

  1. The model makes a prediction.
  2. A loss function measures how wrong it was.
  3. The model updates its weights.
  4. 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).

Step 4 — Deploy the Model

Once the model performs well, it is deployed to be used in the real world:

3. Types of Training

A. Supervised Learning

Learning from labeled examples.

Used for: classification, prediction, image recognition, etc.

B. Unsupervised Learning

Learning from unlabeled data. The model finds hidden patterns on its own.

C. Reinforcement Learning

Learning by trial and error, similar to how humans learn skills.

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:

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:

Large models (like modern language models) are trained on huge collections of books, articles, websites, conversations, and code.

6. Overfitting vs. Underfitting

Overfitting

Underfitting

7. Training Requires Big Computing Power

Training modern AI models is computationally expensive. It often uses:

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.

Ethical AI requires careful data selection, filtering harmful examples, monitoring results, and including human oversight.

9. Summary (Student-Friendly Version)

Big Idea: AI models are trained by giving them huge amounts of data, letting them practice making predictions, checking how wrong they are, and adjusting themselves again and again until they get better.

10. Quick Check for Understanding

  1. Why do AI models need lots of data?
  2. What is the difference between supervised and unsupervised learning?
  3. What does the loss function do during training?
  4. Why do we test a model with new (unseen) data?
  5. What is one ethical issue that can appear when training AI models?