翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。
Amazon Bedrock で LLM がサポートする一般的なタスクには、テキスト分類、要約、質問と回答 (コンテキストの有無にかかわらず) が含まれます。これらのタスクでは、以下のテンプレートと例を使用して、Amazon Bedrock テキストモデルのプロンプトを作成できます。
テキスト分類
テキスト分類では、プロンプトには選択肢がいくつかある質問が含まれ、モデルは正しい選択肢で回答する必要があります。また、プロンプトに回答の選択肢を含めると、Amazon Bedrock の LLM がより正確なレスポンスを出力します。
最初の例は、単純明快な多肢選択式の分類質問です。
|
|
(プロンプトの出典: サンフランシスコの Wikipedia
センチメント分析は分類の一形態で、モデルがテキストで表現された選択肢のリストからセンチメントを選択するものです。
|
|
(プロンプトの出典: AWS、使用されるモデル: Amazon Titan Text)
次の例では、Anthropic Claude モデルを使用して、テキストを分類しています。AnthropicClaude ガイド
(出典: 作成者 AWS) |
|
(プロンプトの出典: AWS、使用されるモデル: Anthropic Claude)
質問応答 (コンテキストなし)
コンテキストがない質問応答プロンプトでは、モデルはコンテキストやドキュメントを一切使用せずに、内部の知識を使って質問に応答する必要があります。
|
|
(プロンプトの出典: AWS、使用されるモデル: Amazon Titan Text)
モデルを励ますことは、質問応答のタスクにも役立ちます。
|
|
(プロンプトの出典: AWS、使用されるモデル: Amazon Titan Text)
|
|
(プロンプトの出典: AWS、使用されるモデル: AI21 Labs Jurassic-2 Ultra v1)
質問応答 (コンテキストあり)
コンテキストがある質問応答プロンプトでは、ユーザーが入力テキストに続いて質問を入力し、モデルは入力テキスト内の情報に基づいて質問に回答する必要があります。テキストの後である最後に質問を付けると、Amazon Bedrock の LLM が質問に回答しやすくなります。モデルを励ますことは、このユースケースでも有効です。
|
|
(プロンプトの出典: https://en.wikipedia.org/wiki/Red_panda、使用モデル: Amazon Titan Text)
Anthropic Claude モデルにプロンプトを出すときには、入力テキストを XML タグで囲むと役立ちます。次の例では、入力テキストを <text></text>
で囲んでいます。
|
|
(プロンプトの出典: 「スーパーボウル LV ハーフタイムショーに関する Wikipedia
要約
要約タスクでは、プロンプトはテキストの一節であり、モデルは入力の要点を捉えた短い文章で応答する必要があります。このユースケースでは、出力を文または段落の長さ (または数) で指定すると有効です。
|
|
(プロンプトの出典: AWS、使用されるモデル: Amazon Titan Text)
次の例では、Anthropic Claude は与えられたテキストを 1 つの文に要約しています。入力テキストをプロンプトに含めるには、「<text> {{text content}} </text>
」のように、テキストを XML マークアップで書式設定します。Anthropic Claude モデルにプロンプトを出すときは、プロンプト内で XML を使用するのが一般的なやり方です。
|
|
(プロンプトの出典: 「ナッシュ均衡に関する Wikipedia
テキスト生成
Amazon Bedrock の LLM は、プロンプトを受け取ると、説明と一致するオリジナルテキストの一節を返信する場合があります。1 つの例を次に示します。
|
|
(プロンプトの出典: AWS、使用されるモデル: Amazon Titan Text)
テキスト生成のユースケースでは、詳細なタスク要件を指定するとうまくいく場合があります。次の例では、感嘆符付きのレスポンスを生成するようにモデルに要求しています。
|
|
(プロンプトの出典: AWS、使用されるモデル: Amazon Titan Text)
次の例では、ユーザーがモデルに対し、テキストを生成するときに特定の人物の役割を引き受けるように求めるプロンプトを出しています。レスポンス応答の中でモデルが担っている役割が署名に反映されていることに注目してください。
|
|
(プロンプトの出典: AWS、使用されるモデル: AI21 Labs Jurassic-2 Ultra v1)
コードの生成
このプロンプトには、ユーザーがモデルによって生成されることを期待するコードに関するタスクまたは関数とプログラミング言語を記述します。
|
|
(プロンプトの出典: AWS、使用されるモデル: Amazon Titan Text)
|
|
(プロンプトの出典: AWS、使用されるモデル: Anthropic Claude)
数学
入力には、数値、論理、幾何学など、あるレベルでの数学的推論を必要とする問題を記述します。このような問題では、「Let’s
think step by step
」や「Think step by step to come up with the right
answer.
」などのフレーズを指示に追加して、問題に断片的に取り組むようモデルに要求するのが有効です。
|
|
(プロンプトの出典: AWS、使用されるモデル: Amazon Titan Text)
また、次の例でも、モデルに 1 ステップずつに考えてもらう方法を示しています。
|
|
(プロンプトの出典: AWS、使用されるモデル: AI21 Labs Jurassic-2 Ultra v1)
推論/ロジカルシンキング
複雑な推論タスクやロジカルシンキングを必要とする問題については、モデルに論理的な推理をさせて、その回答を説明するように要求することができます。
|
|
(プロンプトの出典: AWS、使用されるモデル: Amazon Titan Text)
次に、Anthropic Claude モデルを使用した別の例を示します。
|
|
(プロンプトの出典: https://en.wikipedia.org/wiki/Barber_paradox、使用モデル: Anthropic Claude)
エンティティの抽出
指定された入力質問からのエンティティ抽出の場合。生成されたテキストからエンティティを抽出し、さらに処理するために XML タグ内に配置します。
|
(プロンプトの出典: AWS、使用モデル: Amazon Titan Text G1- Premier)
例:
User: You are an expert entity extractor who extracts entities from provided input question.
You are responsible for extracting following entities: name, location
Please follow below instructions while extracting the Name, and reply in <name></name>
XML Tags:
- These entities include a specific name of a person, animal or a thing
- Please extract only specific name name entities mentioned in the input query
- DO NOT extract the general mention of name by terms of "name", "boy", "girl",
"animal name", etc.
Please follow below instructions while extracting the location, and reply
in <location></location> XML Tags:
- These entities include a specific location of a place, city, country or a town
- Please extract only specific name location entities mentioned in the input query
- DO NOT extract the general mention of location by terms of "location", "city", "country",
"town", etc.
If no name or location is found, please return the same input string as is.
Below are some examples:
input: How was Sarah's birthday party in Seattle, WA?
output: How was <name>Sarah's</name> birthday party
in <location>Seattle, WA</location>?
input: Why did Joe's father go to the city?
output: Why did <name>Joe's</name> father go to the city?
input: What is the zipcode of Manhattan, New york city?
output: What is the zipcode of <location>Manhattan,New york city<location>?
input: Who is the mayor of San Francisco?
Bot:
思考連鎖の推論
回答の導出方法に関するステップバイステップの分析を提供します。モデルが回答をどのように生成したかをファクトチェックして検証します。
|
(プロンプトの出典: AWS、使用モデル: Amazon Titan Text G1- Premier)
例:
User: If Jeff had 100 dollars, and he gave $20 to Sarah,
and bought lottery tickets with another $20. With the lottery
tickets he bought he won 35 dollars. Jeff then went to buy
his lunch and spend 40 dollars in lunch. Lastly he made a
donation to charity for $20. Stephen met with Jeff and wanted
to lend some money from him for his taxi. How much maximum money
can Jeff give to Stephen, given that he needs to save $10 for
his ride back home?. Please do not answer immediately, think
step by step and show me your thinking.
Bot: