19 ポイント 投稿者 ninebow 2024-05-12 | まだコメントはありません。 | WhatsAppで共有

はじめに

昨年半ばごろ、OpenAIのChatGPTモデルを使ってより良い回答を得るためのプロンプト作成戦略6つを翻訳・整理したことがあったのですが、最近Claude-3も本格的に使い始めて調べてみると、例示されているプロンプトの雰囲気が微妙に違うことに気づきました。

何か違いがあるのかと参考資料を探していたところ、Anthropicが公開しているプロンプトエンジニアリング文書があったのでざっと読んでみたのですが、OpenAIが整理していた6つのプロンプト作成戦略と重なる部分が多そうだったため、全文をすべて整理するよりは競合モデル(…)であるChatGPTに簡単な要約を頼んでみました。

ぜひ一度ご覧いただき、不足している内容は OpenAIのGPTベストプラクティス: 概要。より良い回答を得るための6つのプロンプト作成戦略 (Six strategies for getting better results) シリーズとあわせて、Anthropicの原文も参照してみてください。 :D

紹介

今回の文書では、Claude-3のプロンプトエンジニアリング戦略について扱っています。これらの戦略を使うことで、Claude-3の性能を向上させ、特定のユースケースに合わせて応答を細かく調整できます。これらの技術は必須ではありませんが、Claudeの入力と出力を改善するのに役立ちます。

プロンプトエンジニアリングは実験科学であり、プロンプトを反復しながらテストして性能を最適化していく過程を含みます。つまり、プロンプトエンジニアリングはエンティティ抽出、質問応答、テキスト要約からさらに複雑な作業へとつながる反復的な開発と評価を通じて進められ、この過程ではさまざまなテストケースを作成し、初期プロンプトを開発してモデルの反応を評価・修正する段階が含まれます。

Claudeを他のAIモデルと比較すると、Claude-3は特定の役割を与えたり、XMLタグを使用したりするなど、さまざまなプロンプトエンジニアリング技法を用いて性能を高められる点が特徴です。これらの技術は、Claudeがより正確で一貫した出力を提供するのに役立ちます。

主な手法

以下は、文書で説明されている主な手法です。

明確かつ直接的に尋ねる(Be clear & direct

Claudeに望む応答を伝えるために、明確な指示と文脈を提供してください。

  1. 詳細な文脈と指示を提供する: タスクを正確に実行するために、Claudeにはできる限り多くの文脈と詳細な指示を与えるべきです。たとえば、個人情報を削除してほしいという依頼では、どの情報をどのように削除するのかを具体的に明示することが含まれます。
Role Prompt
User We want to anonymize some text by removing all personally identifiable information (PII).

Please follow these steps:

  1. Replace all instances of names, phone numbers, and home and email addresses with 'XXX'.
  2. If the text contains no PII, copy it word-for-word without replacing anything.
  3. Output only the processed text, without any additional commentary.

Here is the text to process: {{TEXT}}|

  1. 番号付きリストまたは箇条書きを使う: 複雑なタスクを指示する際に番号付きリストや箇条書きを使って指示を分けると、Claudeが指示をよりよく理解し、従いやすくなります。たとえば、教科書の章を授業計画に変換するよう求める指示では、各ステップを明確に分離して伝えられます。
Role Prompt
User Your task is turn the given textbook chapter into a comprehensive lesson plan. To do this task, you should:
  1. Extract and summarize key concepts by section
  2. Convert each extracted concept into a 30 minute lesson plan, including a list of questions to check comprehension.
  3. Design an accompanying homework assignment that reinforces learnings from this chapter.

Here is the chapter: {{CHAPTER}}|

  1. 望むものを具体的に明示する: Claudeに明確な答えや特定の立場を求めるときは、それを明示的に伝える必要があります。たとえば、「史上最高のバスケットボール選手は誰か?」という質問に対して、具体的に1人の選手を選ぶよう求めることができます。
Role Prompt
User (悪い例) Who is the best basketball player of all time?
(良い例) Who is the best basketball player of all time? Yes, there are differing opinions, but if you absolutely had to pick one player, who would it be?
Assistant (Claude's response) There is no definitive answer to who is the best basketball player of all time, as reasonable people can disagree on this. However, if forced to choose just one player, I would say Michael Jordan is most commonly considered the GOAT (Greatest Of All Time) based on his exceptional talent, championships, awards, and cultural impact on the game of basketball. But others like LeBron James, Kareem Abdul-Jabbar, Wilt Chamberlain and Bill Russell are also frequently mentioned in the debate. It's a subjective call without a clear consensus.
  1. 明確なプロンプティングの黄金律: そのプロンプトを他の人に見せて、その指示どおりに実行できるか確認してください。これはClaudeに対しても同様に当てはまり、指示が明確かどうかを検証する助けになります。

例を示す (Use examples

望む出力形式やスタイルを説明するために、プロンプトに例を含めてください。

  1. なぜ例を使うのか?: 例を使うことで、Claudeは与えられた指示をよりよく理解し、望ましい出力形式を明確に把握できます。これにより、モデルがより正確で一貫した結果を生成するのを助けられます。

  2. 効果的な例を作る: 効果的な例は、入力と期待される出力を明確に示す必要があります。例は実際のユースケースを反映しているべきであり、Claudeが学習できる十分な情報を含んでいる必要があります。

Role Content
User いくつかの引用を渡します。引用ブロックから著者を抽出してください。

例を示します。 Quote: "When the reasoning mind is forced to confront the impossible again and again, it has no choice but to adapt." ― N.K. Jemisin, The Fifth Season Author: N.K. Jemisin

Quote: "Some humans theorize that intelligent species go extinct before they can expand into outer space. If they're correct, then the hush of the night sky is the silence of the graveyard." ― Ted Chiang, Exhalation Author:| |Assistant (Claude's response)|Ted Chiang|

広告
  1. 出力のフォーマット: 例を使って望ましい出力形式を指定することで、Claude が予測可能で一貫した形で結果を返せるようになります。これは特に、データ抽出やレポート生成のような作業で有用です。
Role Content
User ``
Text: Sarah Martinez, a dedicated nurse, was known for her compassionate care at the local hospital. David Thompson, an innovative software engineer, worked tirelessly on groundbreaking projects.
Output:
  1. Sarah Martinez [NURSE]
  2. David Thompson [SOFTWARE ENGINEER] ``

`` Text: Chef Oliver Hamilton has transformed the culinary scene with his farm-to-table restaurant. Just down the street, you'll find the library, where head librarian Elizabeth Chen has worked diligently to create a welcoming space for all. Output:

  1. Oliver Hamilton [CHEF]
  2. Elizabeth Chen [LIBRARIAN] ``

Text: At the town's bustling farmer's market, you'll find Laura Simmons, a passionate organic farmer known for her delicious produce. In the community center, Kevin Alvarez, a skilled dance instructor, has brought the joy of movement to people of all ages. Output:| |Assistant (Claude's response)|1. Laura Simmons [ORGANIC FARMER] 2. Kevin Alvarez [DANCE INSTRUCTOR]|

  1. 注意点: 例を使う際は、あまりに限定的なデータに依存しすぎないよう注意し、Claude が特定のパターンだけに過度に依存するのを防ぐ必要があります。

  2. 反復と修正: 最初に提示した例で望む結果が得られなかった場合は、例を修正したり新しい例を追加したりして、段階的に改善していくべきです。この過程を通じて、モデルの出力を継続的に改善できます。

    • 結果の分析: Claude の回答から、望むものと異なるパターンを探してください。そうすることで、例のどこが不明確なのか、どこに誤解を招く余地があるのか、あるいは追加の例が役立つ箇所はどこかを把握しやすくなります。

    • 例の追加: Claude が特定の種類の入力に苦労している場合は、そのシナリオを具体的に扱う追加の例を提供してください。

    • 既存の例の修正: ときには、例をほんの少し修正するだけでも大きな違いが生まれます。さまざまな表現、形式、構造を試し、何が最も効果的かを見極めてください。

    • Claude の助けを借りる: 良い例を作るのは難しいものです。Claude に、与えられたタスクに対する例の多様性や関連性を評価するよう依頼したり、参考となる既存の例セットをもとに新しい例を作ってもらったりできます。

Claude に役割を与える(Give Claude a role)

ユースケースごとの性能を高めるために、Claude に専門家のような特定の役割を与えます。

  1. 役割プロンプティングが機能する仕組み: Claude に具体的な役割を与えることで、特定の状況や問題をより正確に理解し、対応できるようになります。たとえば、数学の問題を解く「数学の専門家」という役割を Claude に与えると、より良い性能を発揮できます。

  2. 役割プロンプティングを使うべき場面: とくに技術的または複雑な作業を行うとき、あるいは特定のコミュニケーションスタイルが必要なときに、役割プロンプティングは有効です。この方法は、Claude の基本性能を向上させるのにも役立ちます。

たとえば、There are two ducks in front of a duck, two ducks behind a duck and a duck in the middle. How many ducks are there? のような問題を解く必要がある場合は、次のような方法を試せます。

Role Content
User You are a master logic bot designed to answer complex logic problems. Solve this logic puzzle. There are two ducks in front of a duck, two ducks behind a duck and a duck in the middle. How many ducks are there?
Assistant (Claude's response) [Automatically outputting thinking step by step as part of its training...] Without additional clarification or assumptions, the logic puzzle does not provide enough information to determine the exact number of ducks. The answer could range from a minimum of 3 ducks to a maximum of 5 ducks, depending on the interpretation of the given information.
  1. 役割プロンプティングの例: 「なぜ空は青いのか」をさまざまな聞き手に説明するために、Claude にそれぞれ異なる役割(幼稚園の先生、大学教授)を与える例があります。役割に応じて、Claude の説明スタイルは変わります。
Role Content
User You are a kindergarten teacher. Succinctly explain why the sky is blue to your students.
Assistant (Claude's response) Have you ever wondered why the sky looks so pretty and blue? The reason is because of the sunlight! When the sun's rays shine down through the Earth's atmosphere, they hit lots of tiny gas molecules in the air. The blue colors in the sunlight get scattered and bounced all around by these molecules. And that's what makes the sky look blue to our eyes! Isn't that neat? The bright blue sky is like nature's big colorful painting just for us.
Role Content
User You are a graduate physics professor. Succinctly explain why the sky is blue to your students.
Assistant (Claude's response) The sky appears blue due to the phenomenon of Rayleigh scattering of sunlight by the molecules in the Earth's atmosphere. Sunlight, which is composed of a spectrum of wavelengths, interacts with the gaseous molecules in the atmosphere. The shorter wavelengths of visible light, corresponding to the blue and violet colors, are scattered more efficiently by these molecules than the longer wavelengths.

This selective scattering of the shorter blue wavelengths in all directions by the atmospheric molecules is what causes the sky to appear blue when viewed from the Earth's surface. The longer wavelengths of red and orange, being less scattered, tend to pass through the atmosphere more directly, giving rise to the reddish hues we see during sunrise and sunset when the sunlight has to travel through a greater depth of the atmosphere.|

  1. 効果的なロールプロンプティングのヒント: Claude に役割を与える際は、具体的な文脈と役割情報を提供することが重要です。さまざまな役割とプロンプトを試し、最適なアプローチを見つける必要があります。

XMLタグの使用(Use XML tags)

XMLタグを併用してプロンプトと応答を構造化することで、明確さを高めることができます。

  1. XMLタグとは何か?: XMLタグは コンテンツ内容 のように、山括弧のタグで内容を囲むために使用します。これらのタグは命令、例、または入力データを区別し、Claude が文脈をよりよく理解して正確な出力を生成できるように助けます。 タグ名については、Claude が特別にうまく動作する標準的な XML タグはありません。たとえば、 と同様にうまく動作します。ただし、関数呼び出し機能を使用する場合は、特定のタグ名を使う必要があります。

    広告
  2. XMLタグを使う理由: XMLタグを使うことで、プロンプトのさまざまな部分を明確に区別し、より正確な反応を引き出すことができます。特に複雑なプロンプトや多様な入力を扱う際に有用です。

  3. XMLタグの使い方: XMLタグを使って命令、内容、例を分離でき、変数入力を含むプロンプトテンプレートを扱う際にも、XMLタグを使ってコンテンツの挿入位置を指定できます。

Role Content
User Please analyze this document and write a detailed summmary memo according to the instructions below, following the format given in the example:
``
{{DOCUMENT}}
``

{{DETAILED_INSTRUCTIONS}}

{{EXAMPLE}}|

次は特定の変数入力の例です。

Role Content
User I will tell you the name of an animal. Please respond with the noise that animal makes.
{{ANIMAL}}

構造化された出力を求める際にも使用します。

Role Content
User Please extract the key details from the following email and return them in XML tags:
  • Sender name in `` tags
  • Main topic in `` tags
  • Any deadlines or dates mentioned in `` tags

`` From: John Smith To: Jane Doe Subject: Project X Update

Hi Jane,

I wanted to give you a quick update on Project X. We've made good progress this week and are on track to meet the initial milestones. However, we may need some additional resources to complete the final phase by the August 15th deadline.

Can we schedule a meeting next week to discuss the budget and timeline in more detail?

Thanks, John ``|

次のような回答を受け取ることができます。

Role Content
Assistant (Claude's response) John Smith
Project X Update
``August 15th
`
  1. XML利用のベストプラクティス: XMLタグを最大限に活用するには、次のヒントを覚えておきましょう:
    • , `` のように、タグに含まれるコンテンツを反映した説明的なタグ名を使用してください。

    • プロンプト全体でタグ名の一貫性を保ち、タグは開始タグ と終了タグ を対で使用する必要があります。

    • 必要に応じてタグをネストして使用できますが、複雑さによっては5層を超えるネストで性能低下が起こる可能性があります。

プロンプトをつなげる(Chain prompts)

複雑なタスクをより小さく管理しやすいステップに分割して、より良い結果を得ましょう:

  1. チェーンプロンプトとは何か? (What is prompt chaining?): チェーンプロンプトは、複雑な目標を達成するために、ある出力を次の入力として使い、タスクを順番に処理する方法です。この方式は、正確性と一貫性の向上に役立ちます。

  2. チェーンプロンプトを使うべき時 (When to use prompt chaining): 複数のステップを要するタスクや複雑な指示を含む場合、チェーンプロンプトを使うことで各ステップの性能を改善できます。

  3. チェーンプロンプトを効果的に使うためのヒント (Tips for effective prompt chaining): 各サブタスクをシンプルで明確に保ち、XMLタグを使ってデータを構造化することが重要です。

    広告
  4. 例 (Examples): 文書と質問を使って回答を生成したり、文法エラーを特定してそれを検証したりするような作業を、チェーンプロンプトで行う方法を示します:

例: 文書および引用文(quotes)を使って質問に答える

  • 質問と一緒に与えられた文書から、Claudeが文書内の引用文を使って回答を生成するようにします。

プロンプト1. 引用文(quotes)を抽出する

Role Content
User Here is a document, in `` XML tags:

{{DOCUMENT}}

Please extract, word-for-word, any quotes relevant to the question {{QUESTION}}. Please enclose the full list of quotes in `` XML tags. If there are no quotes in this document that seem relevant to this question, please say "I can't find any relevant quotes".|

プロンプト2.(プロンプト1の {{QUOTES}} 出力を使って)回答する

Role Content
User I want you to use a document and relevant quotes from the document to answer a question.
Here is the document:
``
{{DOCUMENT}}
``

Here are direct quotes from the document that are most relevant to the question: {{QUOTES}}

Please use these to construct an answer to the question " {{QUESTION}}"

Ensure that your answer is accurate and doesn't contain any information not directly supported by the quotes.|

Claudeに考えさせる(Let Claude think)

段階的な思考を促すことで、Claudeの出力品質を向上させることができます:

  1. 複雑な質問への対応: Claudeが複雑な問題に直面したとき、問題を段階的に分解して取り組めば、より緻密で正確な答えを出せます。これは特に、論理的または分析的な思考が必要な問題で有効です。
Role Content
User Use the following clues to answer the multiple-choice question below, using this procedure:
  1. Go through the clues one by one and consider whether each is potentially relevant
  2. Combine the relevant clues to reason out the answer to the question
  3. Map the answer to one of the multiple choice options: (a), (b), or (c)

Clues:

  1. Miss Scarlett was the only person in the lounge.
  2. The person with the pipe was in the kitchen.
  3. Colonel Mustard was the only person in the observatory.
  4. Professor Plum was not in the library nor the billiard room.
  5. The person with the candlestick was in the observatory.

Question: Was Colonel Mustard in the observatory with the candlestick? (a) Yes; Colonel Mustard was in the observatory with the candlestick (b) No; Colonel Mustard was not in the observatory with the candlestick (c) Unknown; there is not enough information to determine whether Colonel Mustard was in the observatory with the candlestick |

  1. 段階的に考えさせる方法: ユーザーは、プロンプトに「段階的に考えなさい」という指示を含めることで、Claudeに問題へ分析的にアプローチさせることができます。こうすることで、Claudeは各ステップを説明しながら最終結論に到達します。

  2. 思考過程の把握: 思考の過程を可視化するために、XMLタグを使ってClaudeの思考過程と最終回答を明確に区別できます。これは、ユーザーがClaudeの推論プロセスをより明確に理解するのに役立ちます。

Role Content
User [Rest of prompt] Before answering the question, please think about it step-by-step within tags. Then, provide your final answer within tags.
Assistant (prefill) ``

(これは、以下で見る応答のプリフィル手法を使ったものです。)

Role Content
Assistant (Claude's response) [問題を段階的に推論する]
``

[最終回答]|

広告
  1. 考慮事項: この手法を使用すると、Claude の出力が長くなるため、応答時間が長くなる場合があります。そのため、使用前にこうした特性を考慮し、適切な状況で使う必要があります。

Claude の応答を事前入力する(Prefill Claude's response)

望ましい方向に出力を導くために、Claude の応答の冒頭を事前に入力して開始します。

  1. Claude の応答を事前入力する理由: この手法は、ユーザーが特定の形式や内容で応答してほしい場合に有用です。たとえば、あらかじめ定めた形式に合わせて情報を整理したり、特定の単語やフレーズで応答を始めさせることで、応答の一貫性を保つことができます。以下のような場合、{ で始まる応答を事前入力することで、Claude が JSON 形式で回答するように誘導できます。
ole Good Prompt
User Please extract the name, size, price, and color from this product description and output it within a JSON object.

The SmartHome Mini is a compact smart home assistant available in black or white for only $49.99. At just 5 inches wide, it lets you control lights, thermostats, and other connected devices via voice or app—no matter where you place it in your home. This affordable little hub brings convenient hands-free control to your smart devices.| |Assistant (prefill)|{|

Claude の応答は次のようになります。

Role Response
Assistant (Claude's response) "name": "SmartHome Mini",
"size": "5 inches wide",
"price": "$49.99",
"colors": [
"black",
"white"
]
}
  1. Claude の応答をどのように事前入力するか?: ユーザーは Claude に開始テキストを与えることで、応答の方向性を設定できます。この方法は、特に API を通じた自動化システムで有用であり、構造化データ形式において Claude が必要な情報を正確に提供するようにできます。

出力形式を制御する(Control output format)

一貫性と可読性を確保するために、望ましい出力形式を指定できます。

  1. 望む形式を指定する: ユーザーは Claude に具体的な出力形式を指定することで、成果物の一貫性と正確性を高めることができます。これは特にデータ処理やレポート作成において不可欠な要素であり、明確な形式ガイドラインが重要です。たとえば、JSON、XML、HTML、Markdown など、さまざまな形式で応答するよう設定できます。このように Claude に明確な形式指示を与えることで、一貫した出力形式を保証できます。
Role Content
User Please write a haiku about a cat. Use JSON format with the keys "first_line", "second_line", and "third_line".
Assistant (Claude's response) {
"first_line": "Soft furry feline",
"second_line": "Napping in the warm sunlight",
"third_line": "Purring contentedly"
}
  1. 応答を事前入力する: 応答の冒頭を事前入力しておくことで、Claude が指定された形式に合わせて内容を生成するよう誘導できます。この方法は、構造化データ形式を使用する際に特に有用です。
Role Content
User Please generate a recipe for chocolate chip cookies in JSON format.
Assistant (prefill) {
Assistant (Claude's response) "title": "Chocolate Chip Cookies",
"ingredients": [
"中力粉 2 1/4カップ",
"重曹 小さじ1",
"塩 小さじ1",
"食塩不使用バター 1カップ(やわらかくしたもの)",
"グラニュー糖 3/4カップ",
"ブラウンシュガー 3/4カップ",
"バニラエッセンス 小さじ1",
"大きめの卵 2個",
"セミスイートのチョコレートチップ 2カップ"
],
"instructions": [
"オーブンを375°F(190°C)に予熱し、天板にクッキングシートを敷きます。",
"中くらいのボウルで、小麦粉、重曹、塩を泡立て器で混ぜ合わせます。脇に置いておきます。",
"大きなボウルで、バターと2種類の砂糖を電動ミキサーで軽くふんわりするまで、約2〜3分混ぜます。",
"バニラと卵を1個ずつ加え、よく混ざるまで混ぜます。",
"小麦粉の混合物をバターの混合物に少しずつ加え、ちょうど混ざるまで混ぜます。",
"チョコレートチップをさっくり混ぜ込みます。",
"用意した天板に、生地を丸い大さじ1杯分ずつ、約2インチ間隔で落とします。",
"縁がきつね色になるまで、9〜11分焼きます。",
"クッキーを天板の上で5分冷ました後、網に移して完全に冷まします。"
],
"yield": "約3ダース分"
}
  1. 例の提示: 適切な出力形式をより明確に伝えるために、例を提示できます。これにより、Claude が要件をよりよく理解し、適切な形式の応答を生成しやすくなります。特に複雑な形式を必要とするタスクで有用です。
Role Content
User Your task is to write a poem. Here are some examples of ideal formatting for the poem:

`` Title: "Autumn Leaves" Verse 1: Crisp autumn leaves dance In the gentle, chilly breeze A colorful sight

Verse 2: Red, orange, and gold Painting the world with beauty Before winter comes ``

`` Title: "Moonlit Night" Verse 1: Moonlight casts shadows Across the tranquil garden A peaceful retreat

Verse 2: Stars twinkle above As crickets sing their nightsong Nature's lullaby ``

Now, please write a poem about a sunset, following the formatting of the examples above.| |Assistant (prefill)|``| |Assistant (Claude's response)|Title: "Sunset Symphony" Verse 1: Fiery sun descends Painting the sky with wonder A masterpiece forms

Verse 2: Pinks, purples, and reds Blending in pure harmony Day bids night hello ``|

  1. 出力制御のためのヒント: 効果的に出力を制御するには、さまざまな例と明確な指示を提供する必要があります。できるだけ多様な種類の例を提示し、望ましい形式を強調したうえで、実験を通じて最適な方法を見つけることが重要です。この過程で複数の手法を組み合わせながら最適な結果を導き出し、Claude の性能を継続的に改善できます。

Claude に書き直しを依頼する (Ask Claude for rewrites)

赤ペン(rubric)で修正を求める箇所を示し、Claude が出力を反復して改善できるようにします。

  1. 書き直しを依頼する理由: Claude の初期応答が正確でなかったり、期待に達していなかったりする場合、書き直しを依頼して出力を改善できます。ユーザーは特定の形式、スタイル、または内容の詳細を明確にすることで、Claude がより正確に反応するよう導くことができます。

  2. 書き直しを依頼する方法: API を通じて以前に生成されたテキストを含め、書き直しのための具体的な指示を追加します。たとえば、特定のテーマに焦点を当てるよう求めながら段落を書き直してもらうことができます。

Role Prompt
User Here's a paragraph:
``
{{PARAGRAPH}}
``

I'd like you to rewrite it using the following instructions: {{INSTRUCTIONS}}

Please put your rewrite in tags.| |Assistant (prefill)||

広告
  1. 効果的な書き直し指示の作成: 書き直しのための指示は、明確かつ具体的でなければなりません。望ましい形式、トーン、スタイル、追加情報などを含めることで、Claude が何を期待されているのかを正確に理解できるようにする必要があります。
Role Prompt
User Tell me about all the ways I can get fitter.
Assistant (Claude's response) Here are some ways you can get fitter: [list-style response]
User Rewrite this as a single paragraph of text, focusing on the most effective strategies.
Assistant (Claude's response) If you're looking to get fitter, some of the most effective strategies include: [brief paragraph-style response]
  1. 反復的な書き直しのプロセス: 1回の書き直しだけでは完璧な結果を得るのが難しい場合があります。そのようなときは、複数回の書き直しを通じて段階的に結果を改善し、各段階でフィードバックを与えることで、Claudeがユーザーの好みを学習できるようにします。

長いコンテキストウィンドウのヒント(Long context window tips)

Claudeの長いコンテキストウィンドウを活用できるよう、プロンプトを最適化できます。

以下は「長いコンテキストウィンドウのヒント(Long Context Window Tips)」文書の各セクションの詳しい説明です。

  1. 長い文書の扱い (Handling Long Documents): 長い文書を扱うときは、重要な情報を文書の前半に配置し、質問を文書の最後に置く必要があります。こうすることで、Claudeは文書全体にわたって必要な情報を効果的に処理し、適切な回答を提供できます。
Here are some documents for you to reference for your task:

(a unique identifying source for this item - could be a URL, file name, hash, etc)

(the text content of the document - could be a passage, web page, article, etc)

(a unique identifying source for this item - could be a URL, file name, hash, etc)

(the text  content of the document - could be a passage, web page, article, etc)

...

[Rest of prompt]
  1. 文書と質問の配置 (Document-query Placement): 文書に関連する質問は、文書データを提示した後に配置する必要があります。この構造により、Claudeは文書全体を参照して、より正確に回答できるようになります。

  2. 文書Q&A作成のヒント (Tips for Document Q&A): 文書ベースの質疑応答タスクを行うときは、質問を文書の最後に配置し、関連する引用文を見つけて応答に反映させるようにします。これは結果の正確性を高めるのに役立ちます。

Role Content
User I'm going to give you a document. Read the document carefully, because I'm going to ask you a question about it. Here is the document: {{TEXT}}

First, find the quotes from the document that are most relevant to answering the question, and then print them in numbered order in `` tags. Quotes should be relatively short. If there are no relevant quotes, write "No relevant quotes" instead.

Then, answer the question in `` tags. Do not include or reference quoted content verbatim in the answer. Don't say "According to Quote [1]" when answering. Instead make references to quotes relevant to each section of the answer solely by adding their bracketed numbers at the end of relevant sentences.

Thus, the format of your overall response should look like what's shown between the `` tags. Make sure to follow the formatting and spacing exactly.

[Examples of question + answer pairs, with answers written exactly like how Claude's output should be structured]

If the question cannot be answered by the document, say so.

Here is the first question: {{QUESTION}}|

  1. 多肢選択問題の生成 (Multiple Choice Question Generation): 文書をもとに多肢選択問題を作成する際は、文書内容に基づいた例題と解答を提供します。これにより、Claudeが問題を生成する際に一貫した形式と内容を維持しやすくなります.
Role Content
User Your task is to generate multiple choice questions based on content from the following document:
``
{{DOCUMENT}}
``

以下は、テキストの他の部分に基づいて作成された多肢選択式の質問と回答の例です: `` Q1: [ドキュメント内の情報から作成された例題 1] A. [回答選択肢 A] B. [回答選択肢 B] C. [回答選択肢 C] D. [回答選択肢 D] Answer: [正解のアルファベット]

Q2: [ドキュメント内の情報から作成された例題 2] A. [回答選択肢 A] B. [回答選択肢 B] C. [回答選択肢 C] D. [回答選択肢 D] Answer: [正解のアルファベット] ``

指示:

  1. 提供されたテキストに基づいて、多肢選択式の質問を 5 問作成してください。
  2. 各質問には 4 つの選択肢(A、B、C、D)を含めてください。
  3. 各質問について正解を示してください。
  4. 質問はテキストに関連しており、すべての選択肢がもっともらしい内容であることを確認してください。|

さらに読む

https://docs.anthropic.com/claude/docs/prompt-engineering


この記事は GPT モデルで整理した内容をもとにしており、原文の内容や意図と異なる形でまとめられている可能性があります。関心のある内容であれば、原文もあわせてご参照ください。お読みいただく中で不自然な点や誤りを見つけた場合は、コメントでお知らせいただけますと幸いです。 🤗

⚠️広告⚠️: 🔥PyTorch 韓国ユーザーコミュニティ🇰🇷がまとめたこの記事は役に立ちましたか? 会員登録すると、主要な記事をメール💌でお届けします!(デフォルトは Weekly ですが、Daily への変更も可能です。)

まだコメントはありません。

まだコメントはありません。