R3
星期三, 3月 12, 2025
星期二, 3月 11, 2025
星期一, 3月 10, 2025
當 AI 推理模式跟你想的不一樣,怎麼辦
以經典的渡河問題為例,即使我們明確要求Claude使用A*演算法,AI並不總是完全按照指令執行。原因有幾點:
思維模式與內部邏輯:Claude有自己的推理方式,可能會根據問題特性選擇它認為更適合的解決方案,例如使用啟發式搜尋(heuristic)結合回溯法(backtracking)來解決限制滿足問題(CSP),而非嚴格遵循A*。
執行環境限制:即使Claude能生成Python實現的A*演算法,但在網頁環境中,它只能執行JavaScript,無法實際運行Python代碼來驗證結果。
概念層次vs程式層次:要求Claude在「思維層次」使用A*與要求它「用程式實現A*」是不同的。在思維層次上,Claude可能會融合多種解題策略而非純粹的A*。
當AI無法以推理模式解出問題時,我們可以「強迫」Claude使用A*思維來解決 - 引導AI按特定思路或洞見進行問題分析,即使不寫程式碼。這種方式能更好地引導AI的解題路徑。
這也突顯了與AI工具互動時的重要性 - 不只是給予指令,有時還需要適當引導其思考過程,才能獲得我們期望的解題方法和結果。當然很多時候,AI並不需要這樣的導引。
星期六, 3月 08, 2025
不同問題可否放在同一個AI對談裡
每個對話( chat) 都有容許的記憶長度(context window),這跟人類是不一樣的,
因為LLM使用Transformer 機制執行 Attention,所需的運算與長度平方成正比,當對話變長時,計算時間平方增加,反應變慢,運氣不好的話,某個問題還可能被上一個問題干擾,造成誤判甚至出錯。
因此如果問題是系列性的,例如你要去九州玩,本來想去五天,看了AI給的行程,覺得五天好像不夠,想改為六天,那當然繼續在同一個對話下去,說不定大部分行程都一樣,只要微調就可以了,可以省下很多算力,加快反應時間。但是如果你是想改去荷蘭玩,那我建議另起一個對話比較好。
AI 對話撞到長度限制 max length reached
每個對話( chat) 都有容許的記憶長度(context window),這跟人類是不一樣的,
1. 縮短您的訊息:請求更簡潔的回應或以較少的回應請求資訊。
2. 開始新的對話:開始一個新的聊天以重置(reset 歸零)長度限制。
3. 升級至Claude Pro:這個付費選項可以提供更高的訊息長度限制。(
如需立即解決,我建議開啟一個新的對話,
推理 vs. 直覺
1. 推理是把一件原本複雜的任務,拆解成一連串小型的步驟,
3. AI 有分左腦跟右腦嗎? (in English)
A* search for Thanksgiving dinner planning
To address the query "check state validity for each step you take," I will provide a valid sequence of steps for the river crossing puzzle and verify the validity of each state based on the given constraints. The puzzle involves a family—father (F), mother (M), two sons (S1, S2), two daughters (D1, D2), a servant (V), and a dog (G)—who must cross a river using a boat that can carry up to two entities. Only F, M, and V can operate the boat. The constraints are:
- **Constraint 1**: If the mother is absent and the father is present on any side, the father will hit the daughters.
- **Constraint 2**: If the servant is absent on any side, the dog will bite family members (F, M, S1, S2, D1, D2) present on that side.
A state is valid if, on each side of the river:
- The father is not present with any daughters without the mother.
- The dog is not present with any family members without the servant.
### State Representation
Each state is represented as \( (F, M, V, G, S_A, D_A, B) \):
- \( F, M, V, G \): 0 if on side A (starting side), 1 if on side B (destination side).
- \( S_A \): number of sons on side A.
- \( D_A \): number of daughters on side A.
- \( B \): boat location (0 for side A, 1 for side B).
### Validity Conditions
For a state to be valid:
- **Side A**:
- Not \( (F = 0 \text{ and } M = 1 \text{ and } D_A > 0) \) (father with daughters without mother).
- Not \( (G = 0 \text{ and } V = 1 \text{ and } (F = 0 \text{ or } M = 0 \text{ or } S_A > 0 \text{ or } D_A > 0)) \) (dog with family members without servant).
- **Side B**:
- Not \( (F = 1 \text{ and } M = 0 \text{ and } (2 - D_A) > 0) \) (father with daughters without mother).
- Not \( (G = 1 \text{ and } V = 0 \text{ and } (F = 1 \text{ or } M = 1 \text{ or } (2 - S_A) > 0 \text{ or } (2 - D_A) > 0)) \) (dog with family members without servant).
The goal is to get everyone from side A to side B in a valid sequence of steps. Below is a sequence of 11 crossings, with each state's validity checked.
---
### Valid Sequence with State Validity Checks
#### **Step 1: Initial State**
- **State**: \( (0, 0, 0, 0, 2, 2, 0) \)
- **Description**: Everyone (F, M, V, G, S1, S2, D1, D2) is on side A, boat on A.
- **Side A**: F=0, M=0, V=0, G=0, S_A=2, D_A=2
- Father with daughters without mother: \( F = 0 \text{ and } M = 1 \text{ and } D_A > 0 \)? No (M=0).
- Dog with family without servant: \( G = 0 \text{ and } V = 1 \text{ and family present} \)? No (V=0).
- **Side B**: Empty, no issues.
- **Valid**: Yes.
#### **Step 2: V and G to B**
- **State**: \( (0, 0, 1, 1, 2, 2, 1) \)
- **Description**: Servant and dog cross to B, boat on B.
- **Side A**: F=0, M=0, S_A=2, D_A=2
- \( F = 0 \text{ and } M = 1 \text{ and } D_A > 0 \)? No (M=0).
- \( G = 0 \text{ and } V = 1 \text{ and family present} \)? No (G=1).
- **Side B**: V=1, G=1
- \( F = 1 \text{ and } M = 0 \text{ and } (2 - D_A) > 0 \)? No (F=0, 2-2=0).
- \( G = 1 \text{ and } V = 0 \text{ and family present} \)? No (V=1).
- **Valid**: Yes.
#### **Step 3: V to A**
- **State**: \( (0, 0, 0, 1, 2, 2, 0) \)
- **Description**: Servant returns to A, boat on A.
- **Side A**: F=0, M=0, V=0, S_A=2, D_A=2
- \( F = 0 \text{ and } M = 1 \)? No.
- \( G = 0 \text{ and } V = 1 \)? No (G=1).
- **Side B**: G=1
- \( G = 1 \text{ and } V = 0 \text{ and family present} \)? Yes, but no family members on B (F=0, M=0, 2-S_A=0, 2-D_A=0), so no issue.
- **Valid**: Yes.
#### **Step 4: F and M to B**
- **State**: \( (1, 1, 0, 1, 2, 2, 1) \)
- **Description**: Father and mother cross to B, boat on B.
- **Side A**: V=0, S_A=2, D_A=2
- \( F = 0 \text{ and } M = 1 \)? No.
- \( G = 0 \text{ and } V = 1 \)? No (G=1).
- **Side B**: F=1, M=1, G=1
- \( F = 1 \text{ and } M = 0 \text{ and } (2 - D_A) > 0 \)? No (M=1).
- \( G = 1 \text{ and } V = 0 \text{ and family present} \)? Yes, and F=1, M=1, but V=0, so dog bites family members.
- **Correction**: This state is invalid due to Constraint 2 on side B. Let’s adjust.
---
### Adjusted Sequence
Let’s try moving V and G together initially, then manage family members carefully.
#### **Step 1: Initial State**
- \( (0, 0, 0, 0, 2, 2, 0) \)
- **Valid**: Yes (as above).
#### **Step 2: V and G to B**
- \( (0, 0, 1, 1, 2, 2, 1) \)
- **Valid**: Yes (as above).
#### **Step 3: V to A**
- \( (0, 0, 0, 1, 2, 2, 0) \)
- **Valid**: Yes (as above).
#### **Step 4: M and V to B**
- **State**: \( (0, 1, 1, 1, 2, 2, 1) \)
- **Description**: Mother and servant cross to B, boat on B.
- **Side A**: F=0, S_A=2, D_A=2
- \( F = 0 \text{ and } M = 1 \text{ and } D_A > 0 \)? No (M=1, but on B).
- \( G = 0 \text{ and } V = 1 \)? No (G=1).
- **Side B**: M=1, V=1, G=1
- \( F = 1 \text{ and } M = 0 \)? No (F=0).
- \( G = 1 \text{ and } V = 0 \)? No (V=1).
- **Valid**: Yes.
#### **Step 5: M to A**
- **State**: \( (0, 0, 1, 1, 2, 2, 0) \)
- **Description**: Mother returns to A, boat on A.
- **Side A**: F=0, M=0, S_A=2, D_A=2
- \( F = 0 \text{ and } M = 1 \)? No.
- \( G = 0 \text{ and } V = 1 \)? No (G=1).
- **Side B**: V=1, G=1
- \( G = 1 \text{ and } V = 0 \)? No (V=1).
- **Valid**: Yes.
#### **Step 6: F and V to B**
- **State**: \( (1, 0, 1, 1, 2, 2, 1) \)
- **Description**: Father and servant cross to B, boat on B.
- **Side A**: M=0, S_A=2, D_A=2
- \( F = 0 \text{ and } M = 1 \)? No (M=0).
- \( G = 0 \text{ and } V = 1 \)? No (G=1).
- **Side B**: F=1, V=1, G=1
- \( F = 1 \text{ and } M = 0 \text{ and } (2 - D_A) > 0 \)? No (2-2=0, no daughters on B).
- \( G = 1 \text{ and } V = 0 \)? No (V=1).
- **Valid**: Yes.
#### **Step 7: V to A**
- **State**: \( (1, 0, 0, 1, 2, 2, 0) \)
- **Description**: Servant returns to A, boat on A.
- **Side A**: M=0, V=0, S_A=2, D_A=2
- \( F = 0 \text{ and } M = 1 \)? No.
- \( G = 0 \text{ and } V = 1 \)? No (G=1).
- **Side B**: F=1, G=1
- \( F = 1 \text{ and } M = 0 \text{ and } (2 - D_A) > 0 \)? No (no daughters on B).
- \( G = 1 \text{ and } V = 0 \text{ and family present} \)? Yes, and F=1, so invalid (dog bites father).
- **Correction**: Invalid state.
---
星期五, 3月 07, 2025
使用 Remix 套用版型
為何你的AI得不到專業級的工程圖版型
專業版型需要時間調整(熬煮),你們第一次做出來通常很陽春,
星期四, 3月 06, 2025
River Crossing 4 (One daughter case)
How about relaxing one of the constraints:
多個限制條件的複雜問題
當AI面對包含多個限制條件的複雜問題時,確實存在難度。
在注意力機制(Attention mechanism)中,模型需要同時關注多個條件,並且每個注意力分配都是基於概率的。當條件數量增加時,要同時滿足所有條件的概率會顯著降低,這就像是連續投擲硬幣並期望全部正面朝上一樣——條件越多,全部滿足的概率越低。
這種情況下,模型可能會:
- 忽略某些條件
- 錯誤理解條件之間的關係
- 在滿足一些條件的同時違反其他條件
如果您有一個包含多個複雜條件的問題需要解決,我建議將問題分解成較小的部分,逐步處理每個條件,這樣會更容易得到準確的解答。
星期三, 3月 05, 2025
EX#3
如何繳交作業 How to turn in your homework exercise.
課堂練習的工具
使用 Grok 3
課堂練習繳交期限
Deadline:
1. end of session
2. This Saturday at 23:59
課堂練習繳交方式
Send all the links to TA victorhuang111013@gmail.com and me chang212@gmail.com by email with subject EX#3 [your ID, your name]
1. 使用A* search Code gen快速尋找答案 Given 19, 36, 55, 7, can you give an equation that equals 622?
甚麼是 A* search
3. 以 Claude 3.7 (有訂閱者)/ChatGPT o3-mini/Grok 3 推理模式 尋找答案 晚餐接機大作戰(半導體廠製程排程),並且驗證使用狀態圖(State Diagram),看板圖 (Dashboard), 流程圖(Flow chart) 進行視覺化
為何你的AI得不到專業級的工程圖版型
專業版型需要時間調整(熬煮),你們第一次做出來通常很陽春,
4. 以 A* search (但不撰寫程式)快速尋找答案 晚餐接機大作戰(半導體廠製程排程),並且驗證使用狀態圖(State Diagram),看板圖 (Dashboard), 流程圖(Flow chart) 進行視覺化
本題套用 A* search 範例(使用Grok 3 Think)
使用 Claude 3.7 Extended Trial 1
使用 Claude 3.7 Extended Trial 2
5. 規劃自己的夢想出國行程(有趣的,創意的呈現方式,不拘)
會犯錯的機器更強大
這觸及了人工智慧系統設計的深刻見解。允許機器犯錯、從錯誤中學習並回溯確實是一種強大的方法。
當我們分解複雜任務時,我們為系統創造了以下機會:
- 識別某種特定方法何時無效
- 嘗試替代策略而無需從頭開始
- 從錯誤中漸進式學習
這類似於人類解決問題的方式 - 我們很少一次就把事情做對。我們能夠說「這行不通」並轉變方向的能力對我們的智能至關重要。
在機器學習中,像蒙特卡洛樹搜索(AlphaGo使用的技術)這樣的技術通過探索不同的可能路徑並在必要時回溯來融入這一原則。同樣,一些現代語言模型使用的方法可以在推理過程中重新審視並完善其思考。
A profound insight about AI system design. Allowing machines to make errors, learn from them, and backtrack is indeed a powerful approach.
When we decompose complex tasks, we create opportunities for systems to:
- Recognize when a particular approach isn't working
- Try alternative strategies without starting from scratch
- Learn incrementally from mistakes
This is similar to how humans solve problems - we rarely get things right on the first try. Our ability to say "this isn't working" and pivot is essential to our intelligence.
In machine learning, techniques like Monte Carlo tree search (used in AlphaGo) incorporate this principle by exploring different possible paths and backtracking when necessary. Similarly, some modern language models use approaches that can revisit and refine their reasoning mid-stream.
星期日, 3月 02, 2025
晚餐接機大作戰(半導體廠製程排程): Part IV A* on thinking Level
Try smart search. Prompt Claude Sonnet 3.7, ChatGPT o1, Grok 3 Think to perform A* search
Optimal
Plan by A* (animation)
Detailed Analysis of James's Decision at 2:00 PM (animation)
這個決策點細部分析
(呂利威)
Time Chart (Schedule)
Sub optimal
晚餐接機大作戰(半導體廠製程排程): Part III Standard LLM vs. Reasoning
Scheduling Parallelism in Plans problem (Eng) (from source)
Why non-reasoning LLM fails (source)
Claude Sonnet 3.5 illustration of solution (happens to be optimum)
What if Emily arrived at the airport at 4:30
Sonnet 3.5 illustration (attention bias occurs. some constraints forgotten)
ChatGPT o1 feasible (also optimum) at the first try. Solution space is tremendously limited.
What if Emily arrived at the airport at 2:30
Sonnet 3.5 illustration (attention bias occurs. some constraints forgotten)
ChatGPT o1 reasoning feasible outcome, optimized by human
晚餐接機大作戰(半導體廠製程排程): AI 協同軟體開發 Part II A* on Python Level, Achieving Parallelism
Scheduling Parallelism in Plans problem (Eng) (from source)
Try smart search. Prompt Claude to generate A* search Algorithm
我將分享一篇關於處理現實世界排程問題的智慧代理式人工智慧論文。我不會著重於總結論文內容或解釋其數學原理,而是要帶各位了解如何運用當前可用的人工智慧工具來解決論文中的問題。
首先,我會展示為什麼 ChatGPT o1 的先進推理雖然能得出可行解,但無法獲得最佳解。接著,我會說明為什麼人工對程式的調整仍然很重要。最後,我將展示如何實現平行運算,以及如何實現智慧代理式人工智慧。