Evolution of ChatGPT and GPT Models
Evolution of ChatGPT and GPT Models
1. GPT-1:
3. GPT-3
GPT-3 was introduced in 2020, marked another significant step up in scale and
performance.
It was composed of multiple transformer layers and Trained on hundreds of
billions of words (a total of 175 billion parameters) from books, web data, and
programming sources.
This model
GPT-3 is the first GPT model widely adopted by the public (via APIs), which is
demonstrated an impressive ability to generate text that closely resembled human
language.
The release of GPT-3 spurred widespread interest in the potential applications of
large language models, as well as discussions about the ethical implications and
challenges of such powerful models.
GPT-3 sparked the global AI boom in conversational agents, prompting
widespread adoption in educational, professional, and commercial domains.
Notable Abilities
o Few-shot learning: GPT-3 could learn a task from only a few examples
o Stronger reasoning and creativity
o Capable of producing human-like text, code, dialogues, and explanations.
4. GPT-3.5
GPT-3.5 introduced in 2022, and made ChatGPT viable for everyday use.
This model powered the first version of ChatGPT, making AI accessible to
millions worldwide.
Notable Abilities
o Better instruction-following
o More stable responses
o Improved safety and alignment
o Optimized for chat interactions
5. GPT-4
GPT-4 was introduced in 2023, and it transformed the GPT family by enabling
multimodal capabilities.
GPT-4 trained on larger and more advanced parameters than GPT-3,
approximately estimated 1Trillion+ parameters via mixture-of-experts (Not
publicly disclosed).
GPT-4 is a revolutionary multimodal language model with capabilities extending
to processing both text and image inputs, describing humor in images, and
summarizing text from screenshots.
GPT-4’s interactions with external interfaces enable tasks beyond text prediction,
making it a transformative tool in natural language processing and various
domains.
GPT-4 set a new industry standard for general-purpose AI models, that used in
ChatGPT+, enterprise, education, and coding tools.
Notable Abilities
o More reliable long-context reasoning
o Multimodal input (text + image),
o Can process text and images
o Better understanding of images and diagrams
o Strong across reasoning, math, coding, and knowledge-intensive tasks,
such as law, medicine, etc.
o Support for safer, more grounded responses
GPT-4.1, GPT-4o, and Variants were introduced in 2024 and these models
expanded GPT-4 into faster and more affordable variants.
They enabled real-time AI assistants, integrated voice interactions, and broader
everyday use.
GPT-4.1: More affordable and faster than GPT-4 with similar intelligence.
GPT-4o (Omni):
o Truly multimodal (text, voice, image, audio)
o Real-time voice interaction
o Efficient and lightweight
o Good for mobile and edge devices
GPT-4o Mini: Optimized for speed and lightweight applications
7. GPT-5 Series
GPT-5 models were introduced in 2025, which presents the advanced reasoning
and autonomy.
GPT-5 models represent the next generation with improved capability and deeper
understanding.
GPT-5 models enable more autonomous workflows, advanced tutoring, smarter
assistants, and precise domain-specific problem solving.
GPT-5:
o Major upgrades in reasoning, planning, and tool-use
o Enhanced long-context processing effortlessly
o Superior reasoning, including step-by-step logical and mathematical
capabilities
o More reliable hallucination control
GPT-5.1 (Current model):
o Even stronger multi-step reasoning
o More stable at following instructions
o Better memory, safer outputs
o Improved multilingual capability
o Rich multimodal interaction across text, images, and audio
o More natural, human-like conversation flow
o Better tool use, enabling high-level automation
Self-attention allows each token to attend to every other token in the sequence.
It computes attention using Query (Q), Key (K), and Value (V) vectors derived
from embeddings.
Self-attention helps the model capture:
o Long-range dependencies
o Contextual relationships
o Semantic similarity
Scaled dot-product attention prevents extremely large scores during softmax by
dividing by √ d k , stabilizing gradients.
Instead of using a single attention head, the Transformer uses multiple heads.
Each head learns different types of relationships (e.g., syntactic vs. semantic).
Allows the model to gather multi-perspective contextual information.
After processing, heads are concatenated and linearly projected.
7. Encoder–Decoder Architecture
Encoder
Decoder
8. Masking Mechanisms
1. Tokenizer
2. Embedding layer
3. Positional encoding
4. Multiple decoder blocks
5. Output Layer
1. Tokenization
At first, the input sequence is broken down into a series of tokens or individual
sequence components.
For instance, if the input is a sentence, the tokens are words.
Before entering the model, text is broken into tokens using Byte-Pair Encoding (BPE)
or SentencePiece.
Example: “ChatGPT is powerful” → ["ChatGPT", " is", " powerful"]
2. Embedding Layer
Each token is converted into a dense vector (learned representation). Two embeddings
are added:
Token embeddings
This stage converts the input sequence into the mathematical domain that
software algorithms understand.
Embedding then transforms the token sequence into a mathematical vector
sequence.
Vectors are visualized as n-dimensional spaces with series of attributes
(coordinates) are represented with numbers.
The vectors carry semantic and syntax information (such as, grammar, meaning,
and use in sentences) about any word.
During the training process, Software can use the numbers to calculate the
relationships between words in mathematical terms and understand the human
language model.
Embeddings provide a way to represent discrete tokens as continuous vectors that
the model can process and learn from.
The sine function is used for even indices of the embedding while the cosine
function is used for odd indices.
These positional encodings (PE) is added to the token embeddings, so the model
can distinguish “dog chases cat” vs “cat chases dog.”
GPT-2 Small 12
GPT-2 Medium 24
GPT-3 (175B) 96
( )
T
QK
Attention ( K , Q ,V ) =softmax V
√ dk
Where, Where dk = dimension of the key vectors (scaling
factor).
Multi-Head Attention
Instead of one attention operation, the model uses multiple heads:
o Multi-head attention is nothing more than several individual
heads stacked on top of one another.
o Each head focuses on a different type of relation (syntax,
semantics, long-range context, etc.)
o The input to all heads is equivalent. However, each head has its
own weights and run attention in parallel
After forwarding the input through all the heads, the output of the
heads is concatenated and passed through a linear layer which brings
the dimensionality back to the dimension of the initial input.
The following figure gives an overview of the operations done in a
head and an overview of how multi-head attention works.
2. Masked Multi-Head Self-Attention (MMHSA)
This mechanism allows the model to generate text one token at a
time while ensuring it cannot “see” future tokens.
The masking mechanism involves applying a triangular mask to
the self-attention matrix, where all elements below the main
diagonal are set to negative infinity (or a very large negative
value).
This effectively masks out the future tokens and allows the token
to only attend to its previous tokens and itself.
Masking Is Needed, because ChatGPT generates text left-to-right.
So when predicting token t, it must not use information from future
tokens, such as t+1, t+2, …
Example:
Let’s consider an example of generating the sentence “I
love natural language processing” using ChatGPT.
During the generation process, when the model is
predicting the word “language,” it should only attend to the
previous tokens “I,” “love,” “natural,” and “language”
itself.
The attention to the word “processing” should be masked
out to maintain causality.
If it could see future tokens, it would “cheat” during
training.
Masking prevents attention to future tokens.
Splits embedding into multiple “heads.”
Each head learns different relations (syntax, meaning, long-range
dependencies).
Output = weighted combination of all previous token embeddings.
Example: For a sequence of 5 tokens: here, future tokens get 0
attention weight.
1 2 3 4 5
1 ✓ 0 0 0 0
2 ✓ ✓ 0 0 0
3 ✓ ✓ ✓ 0 0
4 ✓ ✓ ✓ ✓ 0
5 ✓ ✓ ✓ ✓ ✓
( )
T
QK
Attention ( K , Q ,V ) =softmax +M V
√ dk
Where mask M:
Mij = 0; if j ≤ i
Mij=−∞; if j > i
(xi −μ)
Normalization ( x^ i )=
√ σ 2+ ε
Then scale and shift, hence
LayerNorm ( xi ) =γ x^ i + β
Where:
γ (gamma) = learnable scale
β (beta) = learnable shift
ε = small constant for numerical stability
4. Residual Connections in ChatGPT
Residual connections (also called skip connections) are a critical
architectural component inside every Transformer block of ChatGPT.
They allow information to bypass complex layers, making training deeper
models stable, faster, and more accurate.
Residual connections were introduced in ResNet, but they are even more
important in large-scale language models like GPT.
Residual connections, sometimes referred to as skip connections, allow the
model to retain important information from the previous layers and
provide a mechanism to “skip” some layers by zeroing the weights,
resulting in an over-specified model that can learn sparsity.
A residual connection simply adds the input of a sub-layer directly to its
output:
Output = x + SubLayer(x)
Where,
x = input
SubLayer(x) = output of Self-Attention or Feed-Forward
Network
Output = x + F(x)
Where,
F(x) = SubLayer(x)
This means the network learns a residual function (F(x))
The model learns “just the difference” from the identity mapping.
In Residual Connections in a GPT Decoder Block, Every GPT block has
two residual paths:
Around Masked Multi-Head Self-Attention
x1 = x0 + Attention(LayerNorm(x0))
Around the Feed-Forward Network
x2 = x1 + FFN(LayerNorm(x1))
Residual Connections Are enable ChatGPT to:
Train extremely deep networks
Maintain stable gradients
Preserve original information
Learn meaningful refinements
Scale to billions of parameters
Achieve strong performance on language tasks
Without residual connections, modern Transformers and ChatGPT would
not be trainable at their enormous scale.
5. Feed-Forward Network (FFN / MLP)
In every Transformer decoder block of ChatGPT, after Masked Multi-
Head Self-Attention, the next major component is the Position-wise
Feed-Forward Network (FFN).
GPT models use FFNs to expand and compress representation for deep
feature transformation.
After attention, each token representation passes through a small neural
network (usually two linear layers + non-linear activation), which enabling
the model to learn richer representations.
Where:
x = input vector of size dmodel
W1 expands dimensionality → typically to 4× or 8× the model size.
Example (GPT-3): dmodel =12288, then FFN intermediate
size = 4× 12288 = 49152.
In GPT-style Transformer models, the output layer is the final processing stage
responsible for converting the model’s internal hidden representations into actual text
tokens (words, subwords, or characters).
It is the final step after all decoder blocks have processed the input.
The output layer is extremely important because it transforms the model’s understanding
into predictions.
The output layer in GPT has two main components:
Linear Projection Layer (Fully Connected Layer)
Softmax Layer
∑ ez j
j=1
Where,
P(z i ) is probability for each token.
Exponentiation each logit token such as, e z , is ensured
i
positivity.
n
j=1
Properties of softmax:
Every output is between 0 and 1.
Sum of all outputs is 1.
Larger input values get exponentially higher probabilities.
Softmax transforms unbounded scores into probabilities and ChatGPT
needs to make decisions based on probabilities.
Softmax also creates contrast between tokens due to exponentiation.
Smaller numbers become closer to zero, while higher values
become much more dominant.
This helps the model strongly prefer certain relationships or next-
word predictions.
Softmax supports gradient-based learning (backpropagation), so it
can be trained efficiently.
Softmax determines which token ChatGPT outputs next.
The highest probability token is selected (or sampled, depending
on decoding strategy).
Example of Next Token Prediction using Softmax
Suppose the logits for tokens are:
∑ e z =148.4+7.39+ 2.71=158.5
j
j=1
∑ ez j
j=1
So that,
148.4
P(cat)= ≈ 0.936
158.5
7.39
P(dog)= ≈ 0.046
158.5
2.71
P(car)= ≈ 0.017
158.5
Hence,
P = [0.936, 0.046, 0.017]
The first token has the highest probability; hence ChatGPT is most
likely to generate it.
The output is “cat”.
The training process of ChatGPT is arguably the most crucial aspect responsible for its
remarkable ability to engage in human-like conversations.
Roughly, we can divide the training process into two phases:
Pre-training
Fine-tuning
1. Pre-training
2. Fine-tuning
o Fine-tuning is the stage that transforms a general language model (trained during
pre-training) into a useful, instruction-following, safe, and aligned
conversational assistant.
o It is performed after pre-training and plays a major role in making ChatGPT
respond helpfully.
o Fine-tuning mainly includes two major steps:
Supervised Fine-Tuning (SFT)
Reinforcement Learning from Human Feedback (RLHF)
o Together, this process shapes how ChatGPT behaves, answers questions, and
maintains safety.
a. Supervised Fine-Tuning (SFT)
Supervised Fine-Tuning (SFT) is the first major stage in training
ChatGPT after pre-training.
It teaches the model to follow instructions, produce useful responses, and
behave safely.
Supervised Fine-Tuning (SFT) is the second major phase in the training
pipeline of ChatGPT, performed after pre-training but before
Reinforcement Learning from Human Feedback (RLHF)
It transforms a raw language model—which simply predicts the next token
—into a model that can follow instructions, answer questions, generates
structured responses, and behaves like a helpful assistant.
In this phase, the model is fine-tuned on labelled datasets tailored
to particular applications such as sentiment analysis, question
answering, or text summarization.
For example, in a sentiment analysis task, the model might be
trained on a dataset of movie reviews labelled as positive or
negative. Given a new movie review, the model would learn to
predict the sentiment as either positive or negative based on the
examples it has seen during training.
After pre-training GPT Base model is great at language, but it does not
generate conversational context-driven responses, Thus, the ChatGPT
Base model goes through a Supervised Fine-Tuning process to focus on
learning of prompt-and-response interactions.
Supervised Fine-Tuning is a training stage where the model is fed
prompt–response pairs written by humans, and it learns to imitate these
high-quality outputs.
During Supervised Fine-Tuning process the following steps are taken
place:
Design Human-Created Dialogs:
Human agent creates a set of dialogue scenarios by playing both
the requester and responder roles.
In order to help the model learn how to respond appropriately, it
includes not only the query context (history) but also the expected
response for those queries.
Some hypothetical examples are:
o Prompt: "What is the capital of France?"
o Response: "The capital of France is Paris."
Where,
rchosen = reward for the human-preferred
response
rrejected = reward for the less-preferred response
Loss is the pairwise ranking loss used to train
the Reward Model (RM) in ChatGPT’s RLHF
pipeline.
The loss encourages the model to make:
rchosen > rrejected
σ is the sigmoid function, which maps any value
to a probability between 0 and 1.
1
σ (x)= −x
1+e
In this case, we compute:
σ(rchosen − rrejected)
If, rchosen ≫ rrejected, then σ(rchosen − rrejected) ≈ 1 → good
If, rchosen ≈ rrejected, σ(rchosen − rrejected) ≈ 0.5 → okay
If, rchosen < rrejected , σ(rchosen − rrejected) < 0.5 → bad
The loss penalizes the model when it gives higher
reward to a bad answer.
Interpretation of the Full Formula
Loss = − log (σ(rchosen − rrejected))
Purpose Learn language patterns Teach instruction-following Optimize for human preference
Advantages of ChatGPT:
1. Large Knowledge Base: ChatGPT has been trained on a massive dataset and has access
to a vast amount of information across various domains, which enables it to answer a
wide range of questions accurately.
2. 24/7 Availability: Unlike humans who require breaks and sleep, ChatGPT can operate
around the clock without any downtime. This makes it available to users at any time of
the day, including weekends and holidays.
3. Consistent Quality: ChatGPT can provide consistent and reliable answers to questions
without being influenced by emotions, fatigue, or personal biases. This ensures that users
get accurate and unbiased information every time.
4. Multilingual Support: ChatGPT can communicate in various languages, making it
accessible to a diverse range of users around the world.
5. Fast Response Time: ChatGPT can process and respond to queries quickly, which
makes it ideal for situations that require immediate responses.
6. Scalability: ChatGPT can handle an almost unlimited number of users simultaneously,
making it suitable for large-scale applications.
7. Personalized Experience: With its ability to learn and adapt to user preferences,
ChatGPT can provide a personalized experience, improving user engagement and
satisfaction.
Limitations of ChatGPT
Input Embeddings
Decoder Block 1