Chih-Sheng (Tommy) Huang
  • NEW!
    NEW!  Connect Ideas Across Notes
    Save time and share insights. With Paragraph Citation, you can quote others’ work with source info built in. If someone cites your note, you’ll see a card showing where it’s used—bringing notes closer together.
    Got it
      • 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
    ###### tags: `大語言模型` `AI` `Agent` `核心概念大串聯` # 第三篇:與模型溝通的語言 — Prompt、User Prompt、System Prompt > **系列**:AI 核心概念大串聯 | [返回總覽](https://hackmd.io/@TommyHuang/ByDQ96dcZx) > [← 上一篇:Context 與 Context Window](https://hackmd.io/@TommyHuang/SkiIsT_qbe) | [下一篇:Tool 與 MCP →](https://hackmd.io/@TommyHuang/Bkltjadc-l) --- ## 一、Prompt 是什麼? **Prompt(提示詞)** 是你傳給 LLM 的輸入內容,是人類與模型之間的「溝通語言」。 Prompt 的品質直接決定模型輸出的品質。同樣的模型、同樣的問題,不同的 Prompt 寫法可能產生天壤之別的結果。 ``` 差的 Prompt:「幫我寫文章」 好的 Prompt:「請以科技部落格風格,為一般讀者撰寫一篇 600 字的文章, 主題是 AI Token 的概念,需要包含生活化比喻與具體範例」 ``` --- ## 二、Prompt 的兩大類型 在 AI 系統架構中,Prompt 依**傳送者與目的**分為兩種: ``` ┌─────────────────── LLM 收到的 Context ───────────────────┐ │ ┌─────────────────────────────────────────────────────┐ │ │ │ System Prompt(開發者設定,使用者通常看不到) │ │ │ └─────────────────────────────────────────────────────┘ │ │ ┌─────────────────────────────────────────────────────┐ │ │ │ User Prompt(使用者輸入的訊息) │ │ │ └─────────────────────────────────────────────────────┘ │ └───────────────────────────────────────────────────────────┘ ``` --- ## 三、User Prompt **User Prompt** 是使用者在對話中輸入的訊息,也就是你平常在 ChatGPT 或 Claude 對話框裡打的那些字。 ### 特性 - **即時性**:每次對話動態產生 - **可見性**:使用者自己寫、自己看得到 - **目的**:表達需求、提問、給指令 ### 範例 ``` User Prompt 範例: - 「幫我把這段程式碼從 Python 改寫成 JavaScript」 - 「請摘要以下這篇論文的重點:[論文內容]」 - 「你覺得我的商業計畫有什麼問題?」 ``` --- ## 四、System Prompt **System Prompt** 是開發者在對話開始前預先設定的指令,用來定義模型的**角色、行為規則與限制**。 使用者通常看不到 System Prompt,但它對模型的影響力極大——往往比 User Prompt 的優先級更高。 ### System Prompt 能做什麼? ``` System Prompt 範例: 你是一位專業的法律助理,只能回答台灣法律相關問題。 - 回答必須引用相關法條 - 不可提供投資建議 - 若問題超出法律範圍,請禮貌拒絕並說明原因 - 回答語氣正式、精確 ``` ### System Prompt 的用途 | 用途 | 範例 | |------|------| | **角色設定** | 「你是一個客服機器人,代表 XX 品牌」 | | **行為規範** | 「不可討論競爭對手產品」 | | **輸出格式** | 「所有回答必須用 JSON 格式」 | | **知識注入** | 把產品文件、FAQ 放入 System Prompt | | **安全護欄** | 「不可生成任何有害內容」 | --- ## 五、兩者的關鍵差異 | | User Prompt | System Prompt | |--|-------------|---------------| | **撰寫者** | 使用者 | 開發者 | | **可見性** | 使用者可見 | 通常隱藏 | | **時機** | 對話中動態輸入 | 對話前預先設定 | | **目的** | 提出需求 | 定義角色與規則 | | **類比** | 顧客的點餐 | 餐廳的服務手冊 | --- ## 六、Prompt Engineering 「**Prompt Engineering(提示詞工程)**」是指系統化地設計 Prompt 以獲得更好輸出結果的技術。 ### 幾個重要技巧 **1. 給予角色(Role Prompting)** ``` 「你是一位擁有 20 年經驗的軟體架構師,請審查以下程式碼…」 ``` **2. 提供範例(Few-shot Prompting)** ``` 「請按照以下格式分類商品評論: 範例 1:'這個產品很棒' → 正面 範例 2:'品質很差' → 負面 現在分類:'還可以接受'」 ``` **3. 思維鏈(Chain of Thought)** ``` 「請一步步思考,先分析問題,再給出答案」 ``` **4. 明確限制** ``` 「用繁體中文、300 字以內、條列式回答」 ``` --- ## 七、重點整理 - **Prompt** = 傳給 LLM 的輸入,是人機溝通的核心介面 - **User Prompt** = 使用者的即時輸入,表達需求 - **System Prompt** = 開發者預設的規則,定義模型角色與行為 - 好的 Prompt 設計能大幅提升輸出品質——這就是 Prompt Engineering --- > 下一篇:[第四篇 — 賦予模型行動力:Tool 與 MCP →](https://hackmd.io/@TommyHuang/Bkltjadc-l)

    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