ChatGPT สร้างขึ้นมาได้อย่างไร และจะนำไปใช้กับงานในอาชีพสาย Digital ได้อย่างไร
ดร. กอบกฤตย์ วิริยะยุทธกร
นายกสมาคม ผู้ประกอบการปัญญาประดิษฐ์ประเทศไทย (AIEAT)
บริษัท ไอแอพพ์เทคโนโลยี จำกัด (iApp)
https://aieat.or.th | https://iapp.co.th
ChatGPT Development Steps
https://lifearchitect.ai/chatgpt/
GPT-3 Pretraining
Decoder-only�Transformers Architecture
Large Language�Corpus (~600 Billion tokens)
WebText2
Large Language Model�(LLM)
Pretraining
My name is Julien and I like to
My name is Julien and I like to use C#, which is all I really know. In the C# universe, I have two C# friends, Dan and Kevin. I have two boys. Dan is obsessed with C# and when
Gen
Instruct GPT Finetuning
Large Language Model�(LLM)
Fine Tuned LLM that can�follow instruction.
InstructGPT
13K Training Set Prompts
Why is it important to eat socks after meditating?
Gen
There is no clear answer to this question, but there are many theories and ideas that may explain the apparent need to eat socks after meditating. …
Finetuning
https://arxiv.org/abs/2203.02155
Reward Model (RM)
RM dataset has 33k training prompts
Classifier
RM Model
Classify
Training
https://arxiv.org/abs/2203.02155
Reinforcement Learning from Human Feedback (RLHF)
InstructGPT
RM Model�(Learned from Human Feedback)
Reinforcement Learning:�Proximal Policy
Optimization (PPO)
Adjust Gradient
Prompt�Input
Prompt�Output
31K Prompt for PPO�Training
Generated�Human Feedback
Quality Score : 1.0��Finetuning
Inference
Inference
https://arxiv.org/abs/2203.02155
https://arxiv.org/abs/2203.02155
Deep Dive into Transformers
Transformer: Overview
Transformer: Overview
Nx
Nx
Transformer: Overview
Nx
Nx
Transformer: Overview
Attention is all You Need. https://arxiv.org/pdf/1706.03762.pdf
Transformer: Overview
Attention is all You Need. https://arxiv.org/pdf/1706.03762.pdf
Inputs Embedding & Positional Encoding
ช่วย | เขียน | จดหมาย | ให้ | ฉัน | หน่อย | นะ |
Input Text
<eos> | ช่วย | เขีย | น | จด | หมา | ย | ให้ | ฉัน | หน่อ | ย | นะ |
Byte Pair Encoding
Input Ids
[[ 8867, 358, 271, 385, 624, 284, 20436, 450, 274, 923, 278, 1488, 271, 406, 4746]]
Padding�max_legth=256
[[ 8867, 358, 271, 385, 624, 284, 20436, 450, 274, 923, 278, 1488, 271, 406, 4746, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, …, 0]]
Input Embedding
512 dim
0.56
-0.23
0.50
0.11
-0.45
….
0.30
-0.12
0.10
0.51
-0.25
….
0.56
-0.23
0.50
0.11
-0.45
….
0.30
-0.12
0.10
0.51
-0.25
….
0.56
-0.23
0.50
0.11
-0.45
….
0.30
-0.12
0.10
0.51
-0.25
….
512�(d)
256 (n)
0
0
0
0
0
….
0
0
0
0
0
….
0
0
0
0
0
….
…
Word Embedding
512 dim
0
1
0
1
..
0.30
-0.12
0.10
0.51
-0.25
….
0.56
-0.23
0.50
0.11
-0.45
….
0.30
-0.12
0.10
0.51
-0.25
….
0.56
-0.23
0.50
0.11
-0.45
….
0.30
-0.12
0.10
0.51
-0.25
….
512 (d)
256(n)
0
0
0
0
0
….
0
0
0
0
0
….
0
0
0
0
0
….
…
Positional�Encoding
0.56
-0.23
0.50
0.11
-0.45
….
0.8414
0.5403
0.8218
0.5696
…
+
+
Input Layer�Before Enter Encoder
0.56
0.77
0.50
1.11
..
1.1414
0.4203
0.9218
0.3196
..
=
=
...
...�...
...�...
Transformer: Softmax
Attention is all You Need. https://arxiv.org/pdf/1706.03762.pdf
Softmax and Output Probabilities
512 Dim x 256 Length
30,000 words �(Dictionary Size)
Words | Prob |
la | 0.1222 |
le | 0.9513 |
lu | 0.0211 |
…. | … |
30,000�words
Softmax and Output Probabilities
Softmax and Output Probabilities
Loop until reaching�<eos> or max_length
Transformer: Encoder Block
Attention is all You Need. https://arxiv.org/pdf/1706.03762.pdf
Encoder Block Internal: Self-Attention
Q K V
W1
W2
Weight แปลง Text → Query ปรับให้ it เข้าใกล้ animal
Weight แปลง Text → Key ให้ animal ปรับให้เข้าใกล้ it
For example:
“The animal didn’t …..”
The animal
Weight Value ปรับให้การเชื่อมโยงให้เด่นชัดหาก Concept Q,K ใกล้กัน
https://jalammar.github.io/illustrated-transformer/
Ref: Secrets of ChatGPT (Prachya Boonkwan)
Ref: Secrets of ChatGPT (Prachya Boonkwan)
Ref: Secrets of ChatGPT (Prachya Boonkwan)
Encoder Block Internal:�Self-Attention
https://storrs.io/multihead-attention/#:~:text=Multi%2Dhead%20attention%20allows%20for,quite%20simple.
Ref: Secrets of ChatGPT (Prachya Boonkwan)
Ref: Secrets of ChatGPT (Prachya Boonkwan)
Ref: Secrets of ChatGPT (Prachya Boonkwan)
Transformer: Encoder Block
Attention is all You Need. https://arxiv.org/pdf/1706.03762.pdf
Ref: Secrets of ChatGPT (Prachya Boonkwan)
Ref: Secrets of ChatGPT (Prachya Boonkwan)
Ref: Secrets of ChatGPT (Prachya Boonkwan)
Ref: Secrets of ChatGPT (Prachya Boonkwan)
Ref: Secrets of ChatGPT (Prachya Boonkwan)
Softmax and Output Probabilities (Revisited)
Loop until reaching�<eos> or max_length
Three Types of Transformer Architectures
BERT
Masked Language Model�
GPT
Casual Language Model
BART
Neural Machine Translation
Ref: Secrets of ChatGPT (Prachya Boonkwan)
BERT
https://arxiv.org/abs/1810.04805
GPT-3
https://dzlab.github.io/ml/2020/07/25/gpt3-overview/
InstructGPT
InstructGPT
https://arxiv.org/abs/2203.02155
InstructGPT
https://arxiv.org/abs/2203.02155
InstructGPT
https://arxiv.org/abs/2203.02155
InstructGPT
https://arxiv.org/abs/2203.02155
InstructGPT
https://arxiv.org/abs/2203.02155
Reward Model Training
https://arxiv.org/abs/2203.02155
สายอาชีพ Digital ใช้ยังไง?
ให้ช่วยเราให้เร็วที่สุด
Project Manager / Software Analyst : JSON → Table
Customer Service: Bullet → Email
Customer Service: Code Refactoring
Customer Service: Fixing Bugs
Write down Stable Diffusion Prompt
Prompt: “Beautiful car”
Prompt: “Generate an image of a beautiful car in a mid-journey setting that looks realistic and evokes a sense of adventure and freedom. The car should be moving on a scenic road, with a natural environment and beautiful landscapes in the background. The lighting and weather conditions should be appropriate for the location and time of day, creating a …”
https://ai.iapp.co.th/product/image_generation
Open Thai ChatGPT?
Q/A
ดร. กอบกฤตย์ วิริยะยุทธกร
kobkrit@iapp.co.th / kobkrit@aieat.or.th
นายกสมาคม ผู้ประกอบการปัญญาประดิษฐ์ประเทศไทย
บริษัท ไอแอพพ์เทคโนโลยี จำกัด