會進行�「深度思考」的�大型語言模型
等等,這裡會不會有什麼陷阱? …… 讓我想想,有沒有什麼情況下1+1不等於2?在二進位中,1+1等於10
使用者只是寫了「1+1=」,沒有提供額外資訊。他們可能是在測試我會不會想得太複雜。
ChatGPT o1/o3/o4、DeepSeek r1、Gemini 2 Flash Thinking、Claude 3.7 Sonnet (Extended Thinking) ……
「深度思考」 語言模型的特色
問題
給一個「思考」過程
答案
<think>
</think>
Verification
“Let me check the answer …”
Planning
“Let’s first try to ……”
Explore
“Let’s try a different approach …”
……
(「Inference」字面翻譯類似,但意思完全不同)
Test-Time Compute
第一堂課:“深度不夠,長度來湊”
「推理」(Reasoning)
https://www.nature.com/articles/nature16961
AlphaGo
Training
Time
Testing
Time
Test-Time Compute
「思考」越多結果越好
https://arxiv.org/abs/2104.03113
Scaling Scaling Laws with Board Games
Test-Time Scaling
打造「推理」語言模型的方法
更強的思維鏈 (Chain-of-Thought, CoT)
給模型推論工作流程
教模型推理過程 (Imitation Learning)
以結果為導向學習推理 (Reinforcement Learning, RL)
不用微調參數
需要微調參數
打造「推理」語言模型的方法
更強的思維鏈 (Chain-of-Thought, CoT)
給模型推論工作流程
教模型推理過程 (Imitation Learning)
以結果為導向學習推理 (Reinforcement Learning, RL)
Chain-of-Though �(CoT)
https://arxiv.org/abs/2201.11903
Few-shot CoT
Zero-shot CoT
https://arxiv.org/abs/2205.11916
推理模型在做的事情叫做 “Long CoT”
https://arxiv.org/abs/2503.09567
“Short CoT”
gpt-4o
Supervised CoT
https://arxiv.org/abs/2410.14198
不是所有模型都有能力根據複雜指令做 Long CoT
打造「推理」語言模型的方法
更強的思維鏈 (Chain-of-Thought, CoT)
給模型推論工作流程
教模型推理過程 (Imitation Learning)
以結果為導向學習推理 (Reinforcement Learning, RL)
如何 Explore?同一個問題多試幾次
input
output 1
output 2
output 3
“Large Language Monkeys”
https://arxiv.org/abs/2407.21787
如何 Explore?同一個問題多試幾次
input
output 1
output 2
output 3
Majority Vote
(Self-consistency)
https://arxiv.org/abs/2203.11171
Confidence
(used in CoT decoding)
https://arxiv.org/abs/2402.10200
把答案放到 <answer></answer>
如何選出正確答案來?
如何 Explore?同一個問題多試幾次
https://huggingface.co/spaces/HuggingFaceH4/blogpost-scaling-test-time-compute
加上 Verification
input
output 1
output 2
output 3
Verifier
output
score
Verifier
0.1
Verifier
0.9
Verifier
0.2
Best-of-N
https://arxiv.org/abs/2110.14168
也是語言模型
加上 Verification
input
output 1
output 2
output 3
ground truth
Verifier
1.0
output 1
Verifier
1.0
output 3
Verifier
0.0
output 2
input
Training Data:
Parallel vs. Sequential
input
output 1
output 2
output 3
input
output 2
output 3
output 1
Parallel
Sequential
Parallel vs. Sequential
input
output 1-1
output 2-1
output 3-1
Parallel + Sequential
output 1-2
output 2-2
output 3-2
https://arxiv.org/abs/2408.03314
Scaling LLM Test-Time Compute Optimally can be More Effective than Scaling Model Parameters
會對中間的步驟進行驗證
planning
Verification (for a step)
123 x 456 =?
input
step 1
step 1
step 1
Process
Verifier
score
step 1
Let's Verify Step by Step
https://arxiv.org/abs/2305.20050
input
step 1
step 1
step 1
Process
Verifier
score
step 1
Let's Verify Step by Step
https://arxiv.org/abs/2305.20050
</step>
</step>
</step>
input
step 1
step 2
step 3
ans
step 2
step 3
ans
step 2
step 3
step 4
ans
2/3
input
step 1
step 2
step 3
ans
step 3
ans
ans
1/3
step 3
ground truth
input
Training Data:
input
step 1
2/3
input
step 1
step 2
1/3
Process
Verifier
Process
Verifier
2/3
1/3
Math-Shepherd: Verify and Reinforce LLMs Step-by-step without Human Annotations
https://arxiv.org/abs/2312.08935
</step>
</step>
</step>
</step>
</step>
</step>
input
step 1
step 1
step 1
</step>
</step>
</step>
Process
Verifier
score
step 1
step 2
step 2
step 2
step 2
step 2
step 2
step 2
Beam Search
https://arxiv.org/abs/2305.00633
https://arxiv.org/abs/2401.17686
每次保留 N 條路徑
https://huggingface.co/spaces/HuggingFaceH4/blogpost-scaling-test-time-compute
Heuristic Search Algorithm
ReST-MCTS*: LLM Self-Training via Process Reward Guided Tree Search
https://arxiv.org/abs/2406.03816
Source of image: Wikipedia
Monte Carlo Tree Search Boosts Reasoning via Iterative Preference Learning
https://arxiv.org/abs/2405.00451
Mutual Reasoning Makes Smaller LLMs Stronger Problem-Solvers
https://arxiv.org/abs/2408.06195
e.g. Monte Carlo Tree Search (MCTS)
打造「推理」語言模型的方法
更強的思維鏈 (Chain-of-Thought, CoT)
給模型推論工作流程
教模型推理過程 (Imitation Learning)
以結果為導向學習推理 (Reinforcement Learning, RL)
需要微調參數
(Foundation Model)
Post-Training
LLM without Reasoning
Learn to Reasoning
(Fine-tuned Model)
LLM with
Reasoning
打造「推理」語言模型的方法
更強的思維鏈 (Chain-of-Thought, CoT)
給模型推論工作流程
教模型推理過程 (Imitation Learning)
以結果為導向學習推理 (Reinforcement Learning, RL)
教模型推理過程
reasoning process
Input
ground truth
Training data:
Input
???
哪裡來?
想辦法生成推論過程的訓練資料
input
Verifier
Verifier
Verifier
reasoning process
reasoning process
reasoning process
ans
ans
ans
Training data
ground truth
input
Training Data:
CoT
怎麼確保推理過程都是對的?
input
step 1
step 1
step 1
step 2
step 2
step 2
step 2
step 3
ans
step 3
step 3
step 3
ans
https://arxiv.org/abs/2501.04519
rStar-Math
input
step 1
step 2
step 3
ans
Training data:
Reasoning Processing
input
step 1
step 1
step 1
step 2
step 2
step 2
step 2
step 3
ans
step 3
step 3
step 3
ans
input
step 1
step 1
input
step 1
step 2
step 3
step 1
step 2
step 3
https://arxiv.org/abs/2501.04519
rStar-Math
找找自己的問題!
(正確答案為 9)
推理過程需要每一步都是對的嗎?
只要最後答案正確就好
input
step 1
step 1
step 1
step 2
step 2
step 2
step 2
step 3
ans
step 3
step 3
step 3
ans
input
step 1
step 2
step 3
ans
Training data:
Reasoning Processing
推理過程全是正確的,不知道找找自己的問題!
Stream of search (SoS)
https://arxiv.org/abs/2404.03683
input
step 1
step 1
step 1
step 2
step 2
step 2
step 2
step 3
ans
step 3
step 3
step 3
ans
input
step 1
step 2
step 2
step 1
step 1
step 2
step 3
ans
[插入 Verifier 的回饋]
[插入 Verifier 的回饋]
[插入 Verifier 的回饋]
“重新來過”
https://arxiv.org/abs/2410.18982
現在可以做 Knowledge Distillation
Sky-T1: https://novasky-ai.github.io/posts/sky-t1/
s1:https://arxiv.org/abs/2501.19393
reasoning process
Input
answer
Input
?????
Reasoning Model
現在可以做 Knowledge Distillation
https://arxiv.org/abs/2501.12948
Foundation Model
打造「推理」語言模型的方法
更強的思維鏈 (Chain-of-Thought, CoT)
給模型推論工作流程
教模型推理過程 (Imitation Learning)
以結果為導向學習推理 (Reinforcement Learning, RL)
DeepSeek-R1 系列的作法
input
Reasoning Process
answer
Reasoning Process
answer
ground truth
input
Training Data:
(Foundation Model)
RL
DeepSeek-v3-base
DeepSeek-R1-Zero
https://arxiv.org/abs/2501.12948
Accuracy as reward
推理過程內容不重要,最後答案是對的就好
Reinforcement Learning (RL)
Source of image: https://arxiv.org/abs/2501.12948
Majority vote
Aha Moment
Source of image: https://arxiv.org/abs/2501.12948
input
Reasoning Process
answer
Reasoning Process
answer
ground truth
input
Training Data:
推理過程內容不重要,最後答案是對的就好
https://arxiv.org/abs/2501.12948
Poor readability &
Language Mixing
(Foundation Model)
RL
DeepSeek-v3-base
DeepSeek-R1-Zero
Accuracy as reward
Imitation Learning
Model A?
RL
DeepSeek-v3-base
DeepSeek-R1-Zero
Accuracy as reward
DeepSeek-v3-base
reasoning process
Input
ground truth
Generated data
+ human annotation
Model A?
RL
Accuracy / Language coherence as reward
Model B?
(Thousands of examples)
Model B?
input
Reasoning Process
Including tasks without standard answers
ans
Reasoning Process
ans
Reasoning Process
ans
Imitation Learning
Model C?
DeepSeek-v3-base
RL
DeepSeek-R1
Model C?
Safety / Helpfulness
DeepSeek-v3
As verifier
Based on the Deepseek-R1 paper, both the process verifier and MTCS were tried but ultimately not used.
600k examples
“filtered out chain-of-thought with mixed languages, long parapraphs, and code blocks”
Foundation Model 很重要
以 Qwen-32B-Base 作為 Foundation Model
RL 是強化模型原有的能力
Foundation Model
本來就會 Aha
Source of image:
https://arxiv.org/abs/2503.20783
DeepSeek-v3
打造「推理」語言模型的方法
更強的思維鏈 (Chain-of-Thought, CoT)
給模型推論工作流程
教模型推理過程 (Imitation Learning)
以結果為導向學習推理 (Reinforcement Learning, RL)
不用微調參數
需要微調參數
下回預告:推理模型的挑戰與未來發展
reasoning process
Input
answer
Reasoning Model
花錢、花算力
planning
Verification (for a step)
123 x 456 =?
(sub)planning
verification
verification + explore
verification + explore
verification + explore
verification
verification
verification + explore
……
下回預告:推理模型的挑戰與未來發展
reasoning process
Input
answer
Reasoning Model
真的需要產生這麼長的推論過程嗎?有沒有辦法縮短推論過程
花錢、花算力