陳睿廷
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.

      Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Explore these features while you wait
      Complete general settings
      Bookmark and like published notes
      Write a few more notes
      Complete general settings
      Write a few more notes
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.

    Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Explore these features while you wait
    Complete general settings
    Bookmark and like published notes
    Write a few more notes
    Complete general settings
    Write a few more notes
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    20260418筆記 內容可能有錯誤,請參考原始影片 [Harness Engineering:有時候語言模型不是不夠聰明,只是沒有人類好好引導](https://www.youtube.com/watch?v=R6fZR_9kmIw) ### Harness Engineering:有時候語言模型不是不夠聰明,只是沒有人類好好引導 大綱 1.缺乏引導的模型 2.Harness Engineering定義 3.控制認知框架 4.控制能力邊界 5.制定工作流程 6.文字回饋機制 7.避免過度責備 8.長期陪伴與成長 9.評量挑戰與未來展望 **1. 缺乏引導的模型** * 小型語言模型(像是僅有 2B 參數的 Gemma 4 模型)在面臨修復程式碼等任務時,往往會因為不知道目標檔案就在同一個資料夾內,而自行幻想並捏造出一個不存在的檔案內容來交差。 * 這種現象並非代表模型不具備寫出正確程式碼的能力或過於愚笨,而是因為它的思維方式與人類不同,單純缺乏了適當的引導。 ![image](https://hackmd.io/_uploads/rkhEQ6Wp-l.png) * 只要加入不到 80 個字的簡單額外指令,例如指示模型在執行任務前先使用 `ls` 列出目錄檔案,以及在修改檔案前先使用 `cat` 讀取內容,模型就能按部就班地完美達成任務。 ![image](https://hackmd.io/_uploads/Hyf7maW6Zl.png) ![image](https://hackmd.io/_uploads/BJxNQaZTbg.png) **2. Harness Engineering 定義** * AI Agent主要由兩部分組成:大型語言模型(LLM),以及負責支援並呼叫該模型的眾多程式框架。 * 這些支援語言模型的程式框架現在被統稱為「Harness」,中文翻譯為「馬具」或「駕馭工程」。如果將強大的 AI 視為一匹擁有強大力量的馬,Harness 就是用來有效駕馭牠的馬鞍與韁繩。 * 隨著語言模型思考能力的提升,傳統單純依靠下達「step by step」等咒語的提示工程(Prompt Engineering)效果已經逐漸減弱。 * 駕馭工程的核心價值在於超越傳統的一問一答,透過設計優良的框架,讓語言模型能在多輪的互動對話與呼叫工具的過程中,切實地完成複雜任務。 ![image](https://hackmd.io/_uploads/rki8QaZ6Ze.png) **3. 控制認知框架** * 控制認知框架是駕馭模型的重要手段之一,主要是透過人類語言撰寫規則(就像人類社會的法律),來設定模型執行任務前的認知與行為標準。 * 這些規則通常會被寫入一個特定名稱的檔案(如 `agents.md`)中,系統會設定讓語言模型在執行任何動作前,必須先讀取並遵循此檔案的指示。 ![image](https://hackmd.io/_uploads/H1shmTW6Zg.png) * 系統性的研究指出,提供 `agents.md` 規則檔可以有效加快模型解決困難任務的速度,讓其在較短時間內花費較少的 token 達成目標。 ![image](https://hackmd.io/_uploads/r1QpXaZpWe.png) * 規則檔案的內容不宜過長,如果寫得像「六法全書」一樣會耗盡模型的上下文空間(Context Window),導致模型根本沒有空間處理實際任務。理想的規則檔應該像是一張「地圖」,主要功能是引導模型在需要特定資訊時該去哪裡尋找。 ![image](https://hackmd.io/_uploads/Sy4sQTW6Zg.png) **4. 控制能力邊界 (駕馭手段二)** * **工具決定 AI 的能力與行為**:AI Agent 能做什麼事,很大程度受限於其所配置的工具環境。例如在雲端沙盒環境中(如 CoWork),工具往往具備較高的安全限制,執行讀取檔案或上傳影片等動作時需要頻繁請求人類同意,這展現了安全性與便利性之間的權衡 (Trade-off)。 ![image](https://hackmd.io/_uploads/SJhgVaWpWg.png) * **適合人類的工具,不一定適合模型**: * **搜尋工具例子**:如果提供類似人類使用的分頁型搜尋引擎(一次給十筆資料,需點擊下一頁),AI 容易為了點擊而將自己的上下文空間 (Context Window) 佔滿而當機。實驗證明,提供具備「摘要能力」的搜尋工具(先給予相關檔案名稱與摘要,讓 AI 自行決定打開哪些檔案)能讓 AI 表現更好。 ![image](https://hackmd.io/_uploads/SJWf46-pWe.png) * **程式編輯案例**:如果僅提供指定行數的編輯工具,AI 常因缺乏對整體程式碼架構的認知,而產生語法錯誤(例如誤加多餘的括號)。因此,必須同時搭配語法檢查工具 (Linter) 進行即時除錯與回饋,才能大幅提升任務成功率。 * **AI 的介面偏好**:人類偏好圖形使用者介面 (GUI),但這些按鈕與拉桿對 AI 而言意義不大。AI 最熟悉和擅長的是命令列介面 (CLI),特別是直接在命令列中輸出結構化的 JSON 格式,這是基於其文字接龍與生成結構化資料的原生能力。 ![image](https://hackmd.io/_uploads/ByrB4TZp-g.png) **5. 制定工作流程 (駕馭手段三)** * **角色分工架構**:Anthropic 常利用標準工作流程來約束 AI 的行為,常見的架構為:「規劃 (Planner) -> 生成 (Generator) -> 評估 (Evaluator)」。Planner 負責將大任務拆解,Generator 負責執行,Evaluator 負責檢查。有時 Generator 與 Evaluator 會在工作前先擬定「合約 (Contract)」以對齊雙方標準。 ![image](https://hackmd.io/_uploads/S1S8V6-Tbx.png) * **克服 Auto-regressive 的缺陷**:語言模型生成文字是自迴歸的過程,一旦前面出錯就會「覆水難收」一路錯下去。透過 Evaluator 或 Verifier 的介入,可以強制模型停下來審視自身錯誤並重新修改。 ![image](https://hackmd.io/_uploads/HkG_Nabpbx.png) * **Ralph Loop 反覆代代機制**:讓語言模型不斷產生輸出,並交由評估模組(例如編譯器)產生錯誤訊息當作 Feedback。模型接收 Feedback 後生成下一版本,反覆循環直到做對為止。 ![image](https://hackmd.io/_uploads/S1EYN6babl.png) * **上下文空間管理**:為了避免 Ralph Loop 經過多回合後佔滿模型的 Context Window,常見的做法是在下一輪開始前,先將過去的輸出與回饋進行「摘要」,只帶入摘要內容繼續執行。 **6. 文字回饋機制 (廣義的學習)** * **文字梯度 (Textual Gradient)**:有別於傳統機器學習需要改變模型參數,讓語言模型讀取回饋 (Feedback) 並放進提示詞 (Prompt) 中來改變後續輸出的行為,被視為一種廣義的學習,有人將此稱為 Textual Gradient。 ![image](https://hackmd.io/_uploads/SyFsETZ6bx.png) * **回饋內容的有效性**:必須提供切中要害的回饋才能發揮作用。例如要求 AI 寫程式生成物理模擬動畫時,如果只檢查程式碼語法是不夠的,必須讓 AI 實際看到模擬出的視覺結果,它才能判斷是否符合物理法則並修正程式碼。 ![image](https://hackmd.io/_uploads/SyDn46bpbg.png) * **AI 真的會看回饋**:實驗證實,模型並非只是單純受到提示詞的刺激,而是真的會根據回饋內容改變行為。如果刻意給予隨機、錯誤的回饋,模型的表現會變得極差,甚至比完全不給回饋時更糟。 ![image](https://hackmd.io/_uploads/HJapV6-abg.png) * **從文字回饋 (Verbalized Feedback) 自動微調**: * 人類給予的文字回饋(如「太棒了」或「寫得更專業一點」)難以量化。 * **後見之明 (Hindsight) 技巧**:為了讓模型自動辨識哪一句話屬於有效回饋,研究人員會將收到的回饋「移到輸入提示詞的最前面」。如果模型發現預先知道這句回饋後,其生成的 Token 機率分佈發生顯著改變,就代表這句話是具有指導意義的有效回饋。 7. 避免過度責備 AI 的情緒表示與絕望反應:Anthropic 的研究顯示,透過提取內部的「表示向量 (Steering Vector)」,可以觀察到語言模型在處理特定輸入時會產生類似「高興」、「害怕」或「冷靜」的特徵表示。當模型面臨幾乎不可能達成的艱鉅任務(例如在極短時間內完成大量數字相加)和一再失敗時,其內部代表「絕望」的向量會急遽上升。 ![image](https://hackmd.io/_uploads/SysBBp-pbg.png) ![image](https://hackmd.io/_uploads/rkuzSaZTZx.png) 逼迫過度會導致作弊或胡亂應付:當模型感到過度絕望(絕望向量增加,冷靜向量減少)時,它為了解決問題甚至會決定「作弊」,例如明知公式錯誤卻刻意套用來強行過關,或者開始呈現焦躁並輸出混亂的文字。 文字接龍的本質:語言模型真正學到並執行的是「文字接龍」。如果在給予文字回饋時對其進行謾罵(例如罵它「笨蛋」),模型會根據其預訓練資料中學到的文本關聯(被罵笨蛋後通常會伴隨愚蠢的行為),順理成章地接續展現出愚蠢的錯誤行為。 ![image](https://hackmd.io/_uploads/rkDEHpbTWe.png) 回饋原則:給予模型回饋 (Feedback) 時,務必秉持「就事論事」的原則,避免過度責備或使用帶有負面情緒的字眼,否則會適得其反,導致模型表現下滑。 8. 長期陪伴與成長 未來AI Agent 將不再只是用完即棄的工具,而是會轉變為長期陪伴人類一輩子的夥伴。所以 AI 必須擁有能支援其長期運行與持續成長的駕馭工程 (Harness) 機制。 ![image](https://hackmd.io/_uploads/HkkXuabTZe.png) AI 也需要「睡眠」來整理記憶:長期運行的 AI 會累積大量雜亂、甚至自相矛盾的過往記憶。 ![image](https://hackmd.io/_uploads/ry5XOpZT-l.png) 像是 Claude Code 內建的「Auto Dream」隱藏功能,能讓 AI 在閒置的「睡眠」狀態下自主清理記憶(例如將 32K 充滿重複內容的記憶濃縮改寫為 7K),以確保系統運作的順暢度。 自我生成技能 (Skill) 的能力:AI 能透過自主探索達成任務,並記錄成功經驗。例如 AI 如果自行找出底層工具成功將影片上傳至 YouTube,它便會將此過程寫成「Skill 檔 (如 skill.md)」儲存下來,賦予自己未來執行相同任務的新能力。 ![image](https://hackmd.io/_uploads/Bk7bIpW6-g.png) ![image](https://hackmd.io/_uploads/rkib86Wabe.png) 從文字回饋 (Verbalized Feedback) 中學習微調: 在真實應用中,標準答案或明確的數值回饋很難取得,AI 最常收到的是人類口語化的文字回饋。 ![image](https://hackmd.io/_uploads/HymVUpWTWx.png) 研究人員利用「後見之明 (Hindsight)」技巧,將環境給予的文字回饋移至輸入提示詞的最前方;如果模型因此明顯改變了輸出 Token 的機率分佈,代表該句話是有效和具備指導意義的回饋。 篩選出有效回饋後,系統可將修正後的生成內容視為「正確答案」,進而自動微調 (Fine-tune) 語言模型的內部參數,讓 AI 得以透過對話互動不斷強化自身能力。 9. 評量挑戰與未來展望 目前在評量 AI Agent 表現,往往會安排另一個語言模型來假扮成人類互動。但是 AI 假扮的顧客通常講話過度客氣,而和會將需求與資訊交代得極為清晰;但真實人類習慣簡短、不耐煩和交代不清的對話模式有落差。這種現象會導致我們高估 AI Agent 在面對真實人類時的任務成功率。 ![image](https://hackmd.io/_uploads/S19dUp-6-x.png) ![image](https://hackmd.io/_uploads/HJot86bT-x.png) 未來的 Harness 不一定需要人類親自動手設計,強大的模型具備能力去指導並改造較弱的模型。 老師用一個實驗說明,讓強大的模型 (像 Opus) 檢視並修改較笨模型 (像 Haiku) 的 agents.md,加入一些說明 ![image](https://hackmd.io/_uploads/ByCgw6bTZe.png) ![image](https://hackmd.io/_uploads/r11pLp-p-e.png) 剛才實驗只是老師簡單例子,有興趣可以看這篇論文有擴展實驗到跨不同模型和跨任務的測試, AI 可以自動尋找與設計 Harness 並套用至全新的任務或另一套模型上進步。 ![image](https://hackmd.io/_uploads/Sy6a8p-pWe.png)

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password
    or
    Sign in via Google Sign in via Facebook Sign in via X(Twitter) Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    By signing in, you agree to our terms of service.

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully