Artificial Intelligence
(Part 1)
Artificial Intelligence
Artificial Intelligence (AI) means making computers or machines perform tasks that normally require some form of human intelligence.
Examples:
- perception
- reasoning
- language understanding
- planning
- decision making
- learning
- generation
Machine Learning: In simple terms, it means teaching a computer to learn patterns from examples/data instead of manually writing every rule. Data simply means Information that a computer can use.
Training means the process of giving a machine learning system data and adjusting it so that it becomes better at a task.
For example, we need to sort out emails manually we need to sort each one of them instead we train a model to do that work on the given data so it performs the sorting on its own in the future instead of doing it manually.
100,000 labeled emails
↓
training
↓
ML model
↓
new email
↓
spam probabilityA model is a learned mathematical system that has captured patterns from training data and can use those patterns to make predictions or generate outputs.
Deep Learning
Deep learning is machine learning based primarily on multi-layer neural networks.
A neural network is basically a mathematical system made of many connected units that learns patterns by adjusting numbers inside itself.
Machine Learning
│
▼
Neural Networks
│
▼
Deep Neural Networks
│
▼
Deep LearningModern LLMs are built using deep learning.
Generative AI
Traditional machine-learning systems often answer Which category does this belong to? Generative systems can answer What should I generate? AI systems that can generate new content based on what they have learned.
Examples
Text → text
Text → image
Text → audio
Text → code
Image → text
Document → summaryLarge language models are a form of generative AI focused primarily on language.
Large Language Model
An LLM is a neural-network model trained on enormous amounts of text/data to learn statistical patterns in language and generate or transform text. LLM is not a database
Traditional AI vs Generative AI
Imagine two systems. You give one system a photo. It says DOG. That’s primarily a prediction/classification task. That's traditional AI
To another system, you give it create a picture of a dog astronaut. It creates an image. That’s generative AI.
Training vs Inference
Training is the process of teaching a model using data so that it learns useful patterns.
DATA
↓
TRAINING
↓
LEARNED MODELImagine we start with a model that knows absolutely nothing useful about recognizing dogs. We show it images of dogs. The model makes a prediction:
CAT: 70%
DOG: 20%
HORSE: 10%So we tell the training system No. This was a dog. We show it another example. We repeat the process Millions or billions of times until it produces results like
DOG: 98%
CAT: 1%
HORSE: 1%Now the model has become much better. This is called Training.
┌──────────────┐
│ TRAINING DATA│
└──────┬───────┘
↓
┌──────────────┐
│ MODEL │
└──────┬───────┘
↓
PREDICTION
↓
"WRONG?"
↓
Adjust internal
numbers
↓
Try againInference
Now I give the model a new image it has never seen before. The model processes the input and gives me DOG: 99%. Now we are not training it, instead using it.
Inference is using a trained model to produce an output for new input.
TRAINING = teaching the model
INFERENCE = using the modelWhen you use an LLM API, you’re normally doing Inference with your prompt. The provider’s infrastructure runs the trained model. You’re asking the already-trained model to perform inference.
Training
Imagine training data contains the capital of France is Paris. The model doesn’t necessarily store the sentence like this.
KEY:
capital of France
VALUE:
ParisInstead, training changes the model’s internal parameters so that it learns statistical patterns and relationships.
error
Suppose the correct answer to your question is dog, but you get cat. The training system needs some way to measure how wrong the model was. That measurement is called loss.
Loss is a numerical measurement of how wrong a model’s prediction is during training.
A lower loss generally means the model is performing better on the training objective.
optimization
Optimization is the process of adjusting a model’s parameters to improve its performance according to a chosen objective.
TRAINING
│
▼
Training Data
│
▼
Model
│
▼
Prediction
│
▼
Loss
│
▼
Optimization
│
▼
Adjust Parameters
│
└───────────┐
│
▼
Repeat many
times
│
▼
TRAINED MODEL
│
│
────────┼────────
│
▼
INFERENCE
│
▼
New Input
│
▼
OutputModels, Parameters & Weights
Imagine a little brain made of knobs. Imagine a machine with millions of tiny knobs. Each knob can have a different number
Knob 1 → 0.23
Knob 2 → -1.72
Knob 3 → 0.004
Knob 4 → 2.91
...During training, the machine keeps adjusting these numbers. At first BAD SETTINGS. After lots and lots of learning, BETTER SETTINGS. We call those learned numbers parameters.
A parameter is a learned number inside a model that helps determine what the model does.
A model is the complete mathematical system that takes input and produces an output.
MODEL
┌───────────────┐
│ │
Input → │ Parameters │ → Output
│ │
└───────────────┘The parameters are part of what makes the model behave the way it does.
Parameters
A parameter is simply a value that influences the behavior of a mathematical system. Imagine this tiny equation
y = 2xThe 2 determines how strongly x affects y. If we change it:
y = 10xthe behavior changes dramatically. That 2 or 10 is functioning like a parameter.
Real neural networks have huge numbers of parameters, and they interact with each other.
Weights
A weight is a learned numerical value that controls how strongly one piece of information influences another inside a neural network.
The model has 7 billion parameters. Those parameters are largely represented by learned weights (and, depending on the architecture, other learned values such as biases). In simple terms
parameters ≈ learned numbers
weights ≈ important learned numbers controlling connectionsImagine
Input
│
▼
○──────○
\ /
\ /
○
│
▼
OutputThe connections between the units have numbers associated with them. For example
Input ──(0.7)──> Neuron
Input ──(-0.2)─> NeuronThose numbers influence what happens. If training discovers that one connection should matter more, its learned value can change.
Maybe 0.7 → 1.4 Or -0.2 → -0.8 The model’s behavior changes.
During training, the learning algorithm repeatedly adjusts the model’s parameters so that the model becomes better at its training objective.
Parameters
├── Weights
└── Other learned parametersSo all weights are parameters, but not every parameter is necessarily a weight.
DATA
↓
Model makes prediction
↓
Measure error
↓
Adjust parameters
↓
Try again
↓
Adjust parameters
↓
Try again
↓
...Suppose we train a model on millions of examples of English. At the beginning, its parameters are not useful enough. After training, the parameters have been adjusted so the model has learned many patterns.
Get Shubham Gupta’s stories in your inbox
Join Medium for free to get updates from this writer.
For example, it can learn relationships involving:
words
grammar
syntax
meaning
code
facts
patterns
relationshipsNot because someone manually entered
"cat" → "animal"
"Paris" → "France"into a traditional database. Rather, training modifies the model’s parameters.
Again, neural networks are not brains, but this analogy gives us an intuition:
Training
↓
Parameter changes
↓
Future predictions changeTraining
Suppose our model sees
"The cat sat on the ___"The correct next word might be mat. The model produces probabilities. For example
mat 10%
floor 5%
chair 3%
dog 1%
...That output is not right, so the training process calculates how wrong the prediction was. Then it adjusts parameters. Later
mat 65%
floor 8%
chair 4%
...It keeps doing this across enormous amounts of training data.
The parameters are not the training data
Let’s say we have some data
TRAINING DATA
"The cat sat on the mat."
"The dog ran across the street."
...After training
MODEL
├── Parameters
├── Architecture
└── Other model configurationThe model isn’t simply A giant text file containing everything it read.
The training process has transformed information through optimization into learned numerical parameters.
Parameters quantity
No, parameter quantity does not make a model better, model quality depends on many things
Architecture
+
Training data
+
Data quality
+
Training method
+
Parameter count
+
Post-training
+
Inference method
+
Context handling
...A smaller model can sometimes be better for a particular task. And smaller models can have major advantages
Lower cost
Lower latency
Less memory
Easier deploymentParameters vs hyperparameters
Hyperparameter
A hyperparameter is a setting chosen by the people designing/training the model rather than something the model learns directly from training.
For example:
Learning rate
Batch size
Number of layers
Training settingsParameter
MODEL LEARNS IT
Hyperparameter
HUMAN/ENGINEER CHOOSES ITSuppose we’re training a neural network. We choose
Learning rate = 0.001The model doesn’t normally discover that number as part of its learned parameters. We choose it as a training configuration.
Learning rate: A setting that controls how big a change the training process makes to the model's learned numbers at each update.
Meanwhile,
Weight #1 = 0.238
Weight #2 = -0.918
Weight #3 = 1.284are learned during training.
Model checkpoint
It generally means obtaining the learned numerical values produced by training.
A checkpoint is a saved state of a model, including its learned parameters, so the model can later be restored or used.
Model size
A rough way of describing how many learned parameters a model contains.
Foundation Model
In the past, there could be multiple systems that are designed specifically for certain tasks.
However, it was found that rather than building an independent model for each task, we could train a single, very large model on a huge volume of diverse data, and it would pick up generic features and then adapt to specific tasks.
This is the basic idea behind a Foundation Model
A foundation model is a large model trained on broad amounts of data that can serve as a starting point for many different AI applications and tasks.
Imagine we have a model that has been exposed during training to
Books
Articles
Code
Web pages
Conversations
Documentation
Mathematical textIt has learned many patterns from this broad data. We can then use it for
Question answering
Summarization
Translation
Writing
Coding
Classification
Information extractionWe don’t necessarily need to build a completely separate model from scratch for each one. That’s the power of the foundation-model approach.
Foundation models aren’t only language models
A foundation model can be designed around different kinds of data, and there can be models that work with multiple modalities.
Foundation Models
│
┌─────┼────────┐
↓ ↓ ↓
Text Image AudioModality
A type or form of information that an AI system can process. Multimodal means the model can work with more than one type of information, such as text and images.
LLM
A language-focused foundation model can learn from enormous amounts of text/code and then become useful for many language-related tasks.
Foundation Model
│
├── Language-focused
│ ↓
│ LLM
│
├── Vision-focused
│ ↓
│ Vision model
│
└── Multimodal
↓
Text + Image + ...Pretraining
The large initial training stage where a model learns general patterns from a huge and broad dataset before being adapted for particular uses.
Huge diverse data
↓
PRETRAINING
↓
General-purpose model
↓
Adaptation
↓
Specific applicationsPretraining exposes the model to much broader information.
SPECIALIZED TRAINING
100% focused on ONE job
PRETRAINING
Broad exposure to MANY patternsSo it is better not to train the model for one task.
Adaptation
Once we have a foundation model, we can adapt it for particular uses.
Changing or guiding a general-purpose model so it becomes more useful for a particular task, behavior, or application.
There are multiple ways to do this. For example
Foundation Model
│
├── Prompting
│
├── Fine-tuning
│
├── RAG
│
└── Tool useFoundation model vs Traditional ML model
Traditional specialized model
You might build:
Training data:
customer transactionsGoal:
fraud detection
Output:
fraud / not fraudFoundation model
Training data is much broader:
Text
Code
Documents
Books
Other dataThe resulting model can support many applications.
FOUNDATION MODEL
/ | \
/ | \
Chat Coding Search
| | |
Summary Analysis ExtractionA badly trained giant model can perform worse than a smaller, better-designed model for a specific task.
DATA
↓
PRETRAINING
↓
FOUNDATION MODEL
↓
┌─────────────┬─────────────┐
↓ ↓ ↓
Prompting Fine-tuning RAG
↓ ↓ ↓
└─────────────┼─────────────┘
↓
AI APPLICATION
↓
USERLLMs Vs Generative AI
AI
│
└── Machine Learning
│
└── Deep Learning
│
└── Neural Networks
│
└── Transformers
│
└── Large Language Models
│
└── Generative AI appsLLMs are one important type of generative AI system. Generative AI can generate
Text
Images
Audio
Video
CodeAn LLM is primarily focused on language-related data.
Generative AI
│
├── Text generation
│ └── LLMs
│
├── Image generation
│
├── Audio generation
│
├── Video generation
│
└── Other generative systems








