跳轉到主要內容

Documentation Index

Fetch the complete documentation index at: https://docs.claude.com/llms.txt

Use this file to discover all available pages before exploring further.

While these tips apply broadly to all Claude models, you can find prompting tips specific to extended thinking models here.
Claude 的擴展上下文視窗(Claude 3 模型可達 200K tokens)使其能夠處理複雜且資料豐富的任務。本指南將幫助您有效地運用這種能力。

長文本提示的基本技巧

  • 將長格式資料放在頂部:將您的長文件和輸入(約 20K+ tokens)放在提示的頂部,位於查詢、指令和範例之上。這可以顯著提升 Claude 在所有模型中的表現。
    測試顯示,將查詢放在末尾可以將回應品質提升高達 30%,尤其是在處理複雜的多文件輸入時。
  • 使用 XML 標籤來組織文件內容和元數據:當使用多個文件時,用 <document> 標籤包裹每個文件,並使用 <document_content><source>(以及其他元數據)子標籤以提高清晰度。
    <documents>
      <document index="1">
        <source>annual_report_2023.pdf</source>
        <document_content>
          {{ANNUAL_REPORT}}
        </document_content>
      </document>
      <document index="2">
        <source>competitor_analysis_q2.xlsx</source>
        <document_content>
          {{COMPETITOR_ANALYSIS}}
        </document_content>
      </document>
    </documents>
    
    分析年度報告和競爭對手分析。識別戰略優勢並推薦第三季度重點領域。
    
  • 以引用為基礎進行回應:對於長文件任務,請要求 Claude 在執行任務之前先引用文件中的相關部分。這有助於 Claude 在文件內容的「雜訊」中找到重點。
    您是一位 AI 醫生助手。您的任務是幫助醫生診斷可能的患者疾病。
    
    <documents>
      <document index="1">
        <source>patient_symptoms.txt</source>
        <document_content>
          {{PATIENT_SYMPTOMS}}
        </document_content>
      </document>
      <document index="2">
        <source>patient_records.txt</source>
        <document_content>
          {{PATIENT_RECORDS}}
        </document_content>
      </document>
      <document index="3">
        <source>patient01_appt_history.txt</source>
        <document_content>
          {{PATIENT01_APPOINTMENT_HISTORY}}
        </document_content>
      </document>
    </documents>
    
    從患者記錄和就診歷史中找出與診斷患者報告症狀相關的引用。將這些引用放在 <quotes> 標籤中。然後,根據這些引用,列出所有能幫助醫生診斷患者症狀的信息。將您的診斷信息放在 <info> 標籤中。
    

提示庫

從精心策劃的各種任務和使用案例的提示中獲得靈感。

GitHub 提示教程

一個包含豐富示例的教程,涵蓋了我們文檔中的提示工程概念。

Google Sheets 提示教程

通過互動式試算表提供的輕量級版本提示工程教程。