aquachieh
    • 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

      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.
      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
    • 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 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

    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.
    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
    # [2025李宏毅ML] 第10講:人工智慧的微創手術 — 淺談 Model Editing :::success :+1: 筆記全集Book 請至: https://hackmd.io/@4j/r1U_UJ_pye/ ::: :::info 2025生成式AI時代下的機器學習_李宏毅 課程網站 https://speech.ee.ntu.edu.tw/~hylee/ml/2025-spring.php video: https://www.youtube.com/watch?v=9HPsz7F0mJg [[ppt]](https://docs.google.com/presentation/d/10-o047tqJzpE4x77ga4eUAVNF3bqB663/edit#slide=id.p1) [[pdf]](https://speech.ee.ntu.edu.tw/~hylee/ml/ml2025-course-data/edit.pdf) (20250511) ::: :::spoiler 目錄 [TOC] ::: Model Editing: 人工智慧的微創手術 ![image](https://hackmd.io/_uploads/HypUqYjbll.png =500x) ## Model Editing ![image](https://hackmd.io/_uploads/rygdPqYobxl.png =500x) 需求:想教模型最新的知識、虛假的知識、... **Model Editing**:植入一項知識 不同於 **Post training**:學習較大的技能(新語言、工具、推理等) ![image](https://hackmd.io/_uploads/HkKd9tsWxg.png =500x) ▪ **把 Model Editing 視為 Post training?** 不太好 因 Model Editing 通常僅 "一筆" 訓練資料,他可能會學成回答同一個答案 ## **Model Editing 的評量方法** ![image](https://hackmd.io/_uploads/SJVY5FoWee.png =500x) ▪ **Reliability**:想要修改的輸入及答案皆有達成改變 ▪ **Generalization**:輸入有些改變時,答案也要能達成改變 ▪ **Locality**:其他無關的輸入,其答案不該變動 ![image](https://hackmd.io/_uploads/r1F99KsWee.png =500x) ▪ **"Generalization" 在不同論文裡的寬限度不同** **- paraphrase** 跟目標輸入是 "相同意思的輸入",是否可達成目標改變 **- reverse** 目標輸入 跟 目標答案 "反過來問",是否可達成 **- portability** 目標的 "其他特性" 應該也要連得起來(最困難) ![image](https://hackmd.io/_uploads/SkDsqtibgx.png =500x) :+1: ## Model Editing 常見方法 ### 1. 不動參數 ![image](https://hackmd.io/_uploads/SkQ25FjWgl.png =500x) ▪ **In-context Knowledge Editing (IKE)** ![image](https://hackmd.io/_uploads/rkzT9KsWlx.png =300x) ![image](https://hackmd.io/_uploads/HJATqFo-lg.png =300x) 模型不一定會相信你給他的新知識 --> 需要給一些**範例**,告訴模型如何使用新資訊 ![image](https://hackmd.io/_uploads/H1dksto-ee.png =500x) ex: 提供 Reliability/Generalization/Locality 三方向的範例 ### 2-1. 改變參數:人類決定如何編輯 ![image](https://hackmd.io/_uploads/ryfgotobxx.png =500x) 由人類對模型的理解 找出要更新的地方跟方法 ▪ **Rank-One Model Editing (ROME)** ![image](https://hackmd.io/_uploads/H1_-ots-ee.png =500x) step1: 找出最相關的編輯位置 step2: 修改參數 ![image](https://hackmd.io/_uploads/SkHzjKo-ex.png =500x) ▪ **案例:太空針塔在西雅圖 想讓他改成是台北** 目標:找出模型中跟西雅圖這個答案最有關的位置,改參數,讓他變成回答台北 ![image](https://hackmd.io/_uploads/HyS7otoWgl.png =300x) ![image](https://hackmd.io/_uploads/SkkEits-le.png =300x) **- 怎麼找出欲修改的位置:** 先把輸入"太空針塔"跟 embedding 都遮起來,再把 原embedding 一個個放進去試,看哪個會使他輸出答案西雅圖,此即為存放此資訊的重要的位置 ![image](https://hackmd.io/_uploads/ByPeCYs-ge.png =500x) 猜想:在中間位置存了兩者關係的資訊 在最後attention把中間資訊帶過來輸出 ![image](https://hackmd.io/_uploads/rJjVAKs-ge.png =500x) 想編輯feedforward network(W)內的資訊 即會改變加入 residual stream 的輸入 即會改變此 layer 的輸出 即會改變 答案 ![image](https://hackmd.io/_uploads/S1P8CKo-ex.png =500x) **- 怎麼找出`v*`使得最終輸出為 Taipei:** 論文是用 gradient decent 去找出`v*`這個參數 (較舊的方法) ![image](https://hackmd.io/_uploads/HJHbnFobxx.png =500x) `k*: 是前幾個字的輸入經過layer` `W^*: 是更改後的參數` 此論文還需要訂出什麼是不想被改到的 有 close form solution! ![image](https://hackmd.io/_uploads/r1DGnYiWgx.png =500x) 寫成數學式的樣子 ### 2-2. 改變參數:人工智慧學習如何編輯 ![image](https://hackmd.io/_uploads/B1FQnYoWlx.png =500x) ![image](https://hackmd.io/_uploads/rJGsCtj-lg.png =500x) 由人類決定要如何進行編輯 --> 讓另外一個人工智慧學習如何編輯 ![image](https://hackmd.io/_uploads/H1lJ1ciZxg.png =500x) 給他 輸入/輸出/thita 希望他輸出更新檔 e 來給模型更新 這種編輯模型(可輸出別人模型的參數) 又叫 **"Hypernetwork"** ![image](https://hackmd.io/_uploads/S10ykqoZgl.png =500x) 就是一種 **Meta Learning** Meta Learning 完整介紹請見《機器學習2019》 https://www.youtube.com/playlist?list=PLJV_el3uVTsOK_ZK5L0Iv_EQoL1JefRL4 https://youtu.be/QNfymMRUg3M?si=GQP2H_pGyqLR6cWI ### 如何訓練 Hypernetwork? ![image](https://hackmd.io/_uploads/ByNMy5jbgx.png =500x) 希望給他輸入輸出後,他可以輸出 ei but 我們未知 ei 阿!! >![image](https://hackmd.io/_uploads/Hyd7Jqj-xg.png =500x) 所以要把兩個模型 **"合起來"** 看成一個類神經網路 將 ei 看作中間某層的輸出 ![image](https://hackmd.io/_uploads/SytEJqsZle.png =500x) Training:準備多組的資料 (含不想被改動的,這樣當資料夠多時,模型就不會改到其他無關資訊) Testing:不用準備不想被改動的資料 -->此做法實際上有點困難... ▪ 實際上的做法 ![image](https://hackmd.io/_uploads/HJfLy9iZxg.png =500x) -我們平常訓練nn模型的方式是: 訓練資料 算出 loss 及 gradient descent g 再把 g 加到 thita 上 去更新模型 ![image](https://hackmd.io/_uploads/HJRLyqsbgx.png =300x) ![image](https://hackmd.io/_uploads/rysw1qoWlx.png =300x) 照著 將g 輸入一個nn得到更新檔e --> 沒有強制給nn一些限制的話 還是很難訓練起來... 因為參數太多了 (1024^4, 比目前 DeepSeek 系列最大的模型參數更多) ▪ **MEND** ![image](https://hackmd.io/_uploads/HJduJqo-xl.png =500x) https://arxiv.org/abs/2110.11309 gradient descent 可以拆成 u 乘上 vt ![image](https://hackmd.io/_uploads/H1NCZ5oZeg.png =500x) 推導詳見 [[十年前影片]](https://speech.ee.ntu.edu.tw/~tlkagk/courses/MLDS_2015_2/Lecture/DNN%20backprop.ecm.mp4/index.html) [【舊影片上傳】DNN Backpropagation (2015 年上課錄影)](https://youtu.be/zpRR_A3Thoo?si=QfNKme8D9tkh_kKR) ## 總結 ![image](https://hackmd.io/_uploads/Bk60b9s-le.png =500x) 介紹了 Model Editing 常見與經典的方法 1. 不動參數 2. 改變參數:人類決定如何編輯、人工智慧學習如何編輯 ![image](https://hackmd.io/_uploads/rJeWzqiWel.png =500x) 更多方法: EnowDdit https://zjunlp.github.io/project/KnowEdit/ -- END --

    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

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    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