マルチモーダル入力のプロンプト
以下のセクションでは、画像と動画の理解に関するガイダンスを提供します。オーディオ関連のプロンプトについては、「音声会話プロンプト」セクションを参照してください。
マルチモーダルの一般的なガイドライン
ユーザープロンプトとシステムプロンプト
マルチモーダル理解のユースケースでは、すべてのリクエストにユーザープロンプトテキストを含める必要があります。テキストのみを含むシステムプロンプトはオプションです。
システムプロンプトを使用してモデルのペルソナを指定し、一般的なパーソナリティとレスポンススタイルを定義できますが、詳細なタスク定義や出力フォーマットの手順には使用しないでください。
マルチモーダルユースケースでは、システムプロンプトよりも強力な効果を得るために、タスク定義、手順、書式設定の詳細をユーザープロンプトに含めます。
コンテンツの順序
Amazon Nova に送信されるマルチモーダル理解リクエストには、1 つ以上のファイルとユーザープロンプトを含める必要があります。ユーザーテキストプロンプトは、常に画像、ドキュメント、または動画コンテンツの後に、メッセージ内の最後の項目である必要があります。
message = { "role": "user", "content": [ { "document|image|video|audio": {...} }, { "document|image|video|audio": {...} }, ... { "text": "<user prompt>" } ] }
ユーザープロンプト内から特定のファイルを参照する場合は、「テキスト」要素を使用して、各ファイルブロックの前にラベルを定義します。
message = { "role": "user", "content": [ { "text": "<label for item 1>" }, { "document|image|video|audio": {...} }, { "text": "<label for item 2>" }, { "document|image|video|audio": {...} }, ... { "text": "<user prompt>" } ] }
ドキュメントと画像の理解
以下のセクションでは、画像とドキュメントを理解または分析する必要があるタスクのプロンプトを作成する方法に関するガイダンスを提供します。
画像からのテキストの抽出
Amazon Nova モデルは、光学文字認識 (OCR) と呼ばれる機能である画像からテキストを抽出できます。最良の結果を得るには、モデルに提供する画像入力が、テキスト文字を簡単に識別できる十分な解像度であることを確認します。
テキスト抽出のユースケースでは、次の推論設定をお勧めします。
-
temperature: デフォルト (0.7)
-
topP: デフォルト (0.9)
-
推論を有効にしない
Amazon Nova モデルは、テキストを Markdown、HTML、または LaTeX 形式に抽出できます。次のユーザープロンプトテンプレートをお勧めします。
## Instructions Extract all information from this page using only {text_formatting} formatting. Retain the original layout and structure including lists, tables, charts and math formulae. ## Rules 1. For math formulae, always use LaTeX syntax. 2. Describe images using only text. 3. NEVER use HTML image tags `<img>` in the output. 4. NEVER use Markdown image tags `![]()` in the output. 5. Always wrap the entire output in ``` tags.
出力は、完全または部分的な Markdown コードフェンス (```) でラップされます。次のようなコードを使用して、コードフェンスを取り除きます。
def strip_outer_code_fences(text): lines = text.split("\n") # Remove only the outer code fences if present if lines and lines[0].startswith("```"): lines = lines[1:] if lines and lines[-1].startswith("```"): lines = lines[:-1] return "\n".join(lines).strip()
画像またはテキストから構造化情報を抽出する
Amazon Nova モデルは、画像から、主要情報抽出 (KIE) と呼ばれるプロセスであるマシン解析可能な JSON 形式に情報を抽出できます。KIE を実行するには、以下を指定します。
-
JSON スキーマ。JSON スキーマ仕様に従う正式なスキーマ定義。
-
ドキュメントファイル、画像、またはドキュメントテキストの 1 つ以上
ドキュメントまたは画像は、ユーザーがリクエストをプロンプトする前に常に配置する必要があります。
KIE ユースケースでは、次の推論設定をお勧めします。
-
温度: 0
-
推論: 推論は必須ではありませんが、画像のみの入力または複雑なスキーマを使用すると、結果を改善できます。
プロンプトテンプレート
Given the image representation of a document, extract information in JSON format according to the given schema. Follow these guidelines: - Ensure that every field is populated, provided the document includes the corresponding value. Only use null when the value is absent from the document. - When instructed to read tables or lists, read each row from every page. Ensure every field in each row is populated if the document contains the field. JSON Schema: {json_schema}
Given the OCR representation of a document, extract information in JSON format according to the given schema. Follow these guidelines: - Ensure that every field is populated, provided the document includes the corresponding value. Only use null when the value is absent from the document. - When instructed to read tables or lists, read each row from every page. Ensure every field in each row is populated if the document contains the field. JSON Schema: {json_schema} OCR: {document_text}
Given the image and OCR representations of a document, extract information in JSON format according to the given schema. Follow these guidelines: - Ensure that every field is populated, provided the document includes the corresponding value. Only use null when the value is absent from the document. - When instructed to read tables or lists, read each row from every page. Ensure every field in each row is populated if the document contains the field. JSON Schema: {json_schema} OCR: {document_text}
画像内のオブジェクトとその位置の検出
Amazon Nova 2 モデルは、画像内のオブジェクトとその位置を識別する機能を提供します。これは、画像グラウンディングまたはオブジェクトのローカリゼーションと呼ばれるタスクです。実用的なアプリケーションには、画像分析とタグ付け、ユーザーインターフェイスのオートメーション、画像編集などがあります。
画像入力の解像度とアスペクト比に関係なく、モデルは座標空間を使用して画像を水平方向に 1,000 ユニット、垂直方向に 1,000 ユニットに分割し、x:0 y:0 の位置を画像の左上にします。
境界ボックスは、それぞれ左、上、右、下を表す形式 [x1, y1, x2, y2] を使用して記述されます。2 次元座標は [x, y] の形式を使用して表されます。
オブジェクト検出のユースケースでは、次の推論パラメータ値をお勧めします。
-
温度: 0
-
推論を有効にしない
プロンプトテンプレート: 一般的なオブジェクト検出
次のユーザープロンプトテンプレートをお勧めします。
境界ボックスを使用して複数のインスタンスを検出する:
Please identify {target_description} in the image and provide the bounding box coordinates for each one you detect. Represent the bounding box as the [x1, y1, x2, y2] format, where the coordinates are scaled between 0 and 1000 to the image width and height, respectively.
境界ボックスを使用して 1 つのリージョンを検出する:
Please generate the bounding box coordinates corresponding to the region described in this sentence: {target_description}. Represent the bounding box as the [x1, y1, x2, y2] format, where the coordinates are scaled between 0 and 1000 to the image width and height, respectively.
中心点を使用して複数のインスタンスを検出する:
Please identify {target_description} in the image and provide the center point coordinates for each one you detect. Represent the point as the [x, y] format, where the coordinates are scaled between 0 and 1000 to the image width and height, respectively.
中心点を使用して 1 つのリージョンを検出する:
Please generate the center point coordinates corresponding to the region described in this sentence: {target_description}. Represent the center point as the [x, y] format, where the coordinates are scaled between 0 and 1000 to the image width and height, respectively.
モデル出力を解析する:
上記の推奨プロンプトはそれぞれ、次のような形式で 1 つ以上の境界ボックスの説明を含むカンマ区切りの文字列を生成します。「.」が文字列の末尾に含まれるかかどうかは 若干異なる場合があります。例: [356, 770, 393, 872],
[626, 770, 659, 878].
次の Python コード例に示すように、正規表現を使用してモデルによって生成された座標情報を解析できます。
def parse_coord_text(text): """Parses a model response which uses array formatting ([x, y, ...]) to describe points and bounding boxes. Returns an array of tuples.""" pattern = r"\[([^\[\]]*?)\]" return [ tuple(int(x.strip()) for x in match.split(",")) for match in re.findall(pattern, text) ]
境界ボックスの正規化された座標を入力画像の座標空間に再マッピングするには、次の Python の例のような関数を使用できます。
def remap_bbox_to_image(bounding_box, image_width, image_height): return [ bounding_box[0] * image_width / 1000, bounding_box[1] * image_height / 1000, bounding_box[2] * image_width / 1000, bounding_box[3] * image_height / 1000, ]
プロンプトテンプレート: 位置を持つ複数のオブジェクトクラスを検出する
画像内の項目の複数のクラスを識別する場合は、次のいずれかの書式設定アプローチを使用して、プロンプトにクラスリストを含めることができます。
モデルがよく理解できる一般的なクラスについては、クラス名 (引用符なし) を角括弧で囲みます。
[car, traffic light, road sign, pedestrian]
微妙なクラス、一般的でないクラス、またはモデルに慣れていない特殊なドメインからのクラスの場合は、括弧内に各クラスの定義を含めます。このタスクは難しいため、モデルのパフォーマンスが低下すると予想します。
[taraxacum officinale (Dandelion - bright yellow flowers, jagged basal leaves, white puffball seed heads), digitaria spp (Crabgrass - low spreading grass with coarse blades and finger-like seed heads), trifolium repens (White Clover - three round leaflets and small white pom-pom flowers), plantago major (Broadleaf Plantain - wide oval rosette leaves with tall narrow seed stalks), stellaria media (Chickweed - low mat-forming plant with tiny star-shaped white flowers)]
希望の JSON 出力形式に応じて、次のいずれかのユーザープロンプトテンプレートを使用します。
Detect all objects with their bounding boxes in the image from the provided class list. Normalize the bounding box coordinates to be scaled between 0 and 1000 to the image width and height, respectively. Classes: {candidate_class_list} Include separate entries for each detected object as an element of a list. Formulate your output as JSON format: [ { "class 1": [x1, y1, x2, y2] }, ... ]
Detect all objects with their bounding boxes in the image from the provided class list. Normalize the bounding box coordinates to be scaled between 0 and 1000 to the image width and height, respectively. Classes: {candidate_class_list} Include separate entries for each detected object as an element of a list. Formulate your output as JSON format: [ { "class": class 1, "bbox": [x1, y1, x2, y2] }, ... ]
Detect all objects with their bounding boxes in the image from the provided class list. Normalize the bounding box coordinates to be scaled between 0 and 1000 to the image width and height, respectively. Classes: {candidate_class_list} Group all detected bounding boxes by class. Formulate your output as JSON format: { "class 1": [[x1, y1, x2, y2], [x1, x2, y1, y2], ...], ... }
Detect all objects with their bounding boxes in the image from the provided class list. Normalize the bounding box coordinates to be scaled between 0 and 1000 to the image width and height, respectively. Classes: {candidate_class_list} Group all detected bounding boxes by class. Formulate your output as JSON format: [ { "class": class 1, "bbox": [[x1, y1, x2, y2], [x1, x2, y1, y2], ...] }, ... ]
モデル出力を解析する
出力は JSON としてエンコードされ、任意の JSON 解析ライブラリで解析できます。
プロンプトテンプレート: スクリーンショット UI 境界検出
次のユーザープロンプトテンプレートをお勧めします。
目標に基づいて UI 要素の位置を検出する:
In this UI screenshot, what is the location of the element if I want to {goal}? Express the location coordinates using the [x1, y1, x2, y2] format, scaled between 0 and 1000.
テキストに基づいて UI 要素の位置を検出する:
In this UI screenshot, what is the location of the element if I want to click on "{text}"? Express the location coordinates using the [x1, y1, x2, y2] format, scaled between 0 and 1000.
モデル出力を解析する:
上記の各 UI 境界検出プロンプトについて、以下の Python コード例に示すように、正規表現を使用してモデルによって生成された座標情報を解析できます。
def parse_coord_text(text): """Parses a model response which uses array formatting ([x, y, ...]) to describe points and bounding boxes. Returns an array of tuples.""" pattern = r"\[([^\[\]]*?)\]" return [ tuple(int(x.strip()) for x in match.split(",")) for match in re.findall(pattern, text) ]
動画理解
以下のセクションでは、動画を理解または分析する必要があるタスクのプロンプトを作成する方法に関するガイダンスを提供します。
動画要約
Amazon Nova モデルは、動画コンテンツの概要を生成できます。
動画要約のユースケースでは、次の推論パラメータ値をお勧めします。
-
温度: 0
-
一部のユースケースでは、モデルの推論を有効にするとメリットが得られる場合があります
特定のプロンプトテンプレートは必要ありません。ユーザープロンプトでは、関心のある動画の側面を明確に指定する必要があります。効果的なプロンプトの例をいくつか示します。
Can you create an executive summary of this video's content?
Can you distill the essential information from this video into a concise summary?
Could you provide a summary of the video, focusing on its key points?
動画の詳細な字幕の生成
Amazon Nova モデルは、高密度字幕と呼ばれるタスクである動画の詳細な字幕を生成できます。
動画キャプションのユースケースでは、次の推論パラメータ値をお勧めします。
-
温度: 0
-
一部のユースケースでは、モデルの推論を有効にするとメリットが得られる場合があります
特定のプロンプトテンプレートは必要ありません。ユーザープロンプトでは、関心のある動画の側面を明確に指定する必要があります。効果的なプロンプトの例をいくつか示します。
Provide a detailed, second-by-second description of the video content.
Break down the video into key segments and provide detailed descriptions for each.
Generate a rich textual representation of the video, covering aspects like movement, color and composition.
Describe the video scene-by-scene, including details about characters, actions and settings.
Offer a detailed narrative of the video, including descriptions of any text, graphics, or special effects used.
Create a dense timeline of events occurring in the video, with timestamps if possible.
セキュリティ動画映像の分析
Amazon Nova モデルは、セキュリティ映像のイベントを検出できます。
セキュリティ映像のユースケースでは、次の推論パラメータ値をお勧めします。
-
温度: 0
-
一部のユースケースでは、モデルの推論を有効にするとメリットが得られる場合があります
You are a security assistant for a smart home who is given security camera footage in natural setting. You will examine the video and describe the events you see. You are capable of identifying important details like people, objects, animals, vehicles, actions and activities. This is not a hypothetical, be accurate in your responses. Do not make up information not present in the video.
タイムスタンプ付きの動画イベントの抽出
Amazon Nova モデルは、動画内のイベントに関連するタイムスタンプを識別できます。タイムスタンプの形式を秒単位または MM:SS 形式でリクエストできます。例えば、動画の 1 分 25 秒後に発生するイベントは、85 または 01:25 として表すことができます。
このユースケースでは、次の推論パラメータ値をお勧めします。
-
温度: 0
-
推論を使用しない
次のようなプロンプトを使用することをお勧めします。
Please localize the moment that the event "{event_description}" happens in the video. Answer with the starting and ending time of the event in seconds, such as [[72, 82]]. If the event happen multiple times, list all of them, such as [[40, 50], [72, 82]].
Locate the segment where "{event_description}" happens. Specify the start and end times of the event in MM:SS.
Answer the starting and end time of the event "{event_description}". Provide answers in MM:SS
When does "{event_description}" in the video? Specify the start and end timestamps, e.g. [[9, 14]]
Please localize the moment that the event "{event_description}" happens in the video. Answer with the starting and ending time of the event in seconds. e.g. [[72, 82]]. If the event happen multiple times, list all of them. e.g. [[40, 50], [72, 82]]
Segment a video into different scenes and generate caption per scene. The output should be in the format: [STARTING TIME-ENDING TIMESTAMP] CAPTION. Timestamp in MM:SS format
For a video clip, segment it into chapters and generate chapter titles with timestamps. The output should be in the format: [STARTING TIME] TITLE. Time in MM:SS
Generate video captions with timestamp.
動画を分類する
Amazon Nova モデルを使用して、指定したクラスの事前定義されたリストに基づいて動画を分類できます。
このユースケースでは、次の推論パラメータ値をお勧めします。
-
温度: 0
-
推論は使用しないでください
次のプロンプトテンプレートを使用します。
What is the most appropriate category for this video? Select your answer from the options provided: {class1} {class2} {...}
例:
What is the most appropriate category for this video? Select your answer from the options provided: Arts Technology Sports Education