11. Chat API
• 比較新的 Chat API
• 提供了 role 可以包裹對話
• Role 有 system, user, assistant
• OpenAI API 內部會轉換成 ChatML 格式
https://github.com/openai/openai-python/blob/main/chatml.md
• 注意: API 是 Stateless 無狀態沒有上下⽂關係的,因為每次呼叫API,都必須把對話全部傳過去
• 提供的 Model 有
• gpt-3.5-turbo 反應速度和價格較好
• gpt-4 ⽬前產出效果最好的 (GPT-4 API 要排隊,記得去排)
12. Completions API v.s. Chat API
prompt 參數差異
You are AI assistant. Answer as
concisely as possible.
user: How are you
assistant: well!
user: How are you now?
[
{"role": "system", "content": "You are AI assistant.
Answer as concisely as possible."},
{"role": "user", "content": "How are you"},
{"role": "assistant", "content": "well!"},
{"role": "user", "content": "How are you now?"}
]
51. • 給模型思考時間,指⽰模型對⼀個問題進⾏更長的思考時間,⽤更多算⼒
• 若模型出現推理錯誤,你應該嘗試重新設計 prompt,要求要有⼀系列的推理
• 太困難的任務,模型無法在短時間或⽤很少的詞來完成,就會亂掰
• 跟⼈思考⼀樣,⼀下給太困難的問題,⼈也會犯錯
• 這招叫做 Chain of Thought (CoT)
• 光是叫模型 Step by Step,就會⼤幅改進推理
• 因為模型在預測 token 時,給每個 token 的計算時間都是⼀樣的
Principle 2: Give the model time to think