一般的なタスクの基盤モデルプロンプト例

最終更新: 2025年3月26日
一般的なタスクの基盤モデルプロンプト例

これらのサンプルを試して、さまざまなプロンプトが基盤モデルをガイドして一般的なタスクを実行する方法を学習してください。

このトピックの使い方

このトピックのプロンプトのサンプルをご覧ください:

  • プロンプト・テキストと入力パラメータ値をコピーして、 IBM watsonx.ai の Prompt Lab に貼り付けます
  • どんなテキストが生成されるか見てみよう。
  • モデルによってどのように出力が異なるかをご覧ください。
  • プロンプトのテキストとパラメータを変更して、結果がどのように変化するかを確認する。

基盤モデルを迅速化するための正しい方法はありません。 しかし、学界や産業界では、かなり確実に機能するパターンが見つかっている。 このトピックのサンプルを使って、実験を通して、迅速なエンジニアリングに関するスキルと直感を養いましょう。

 

このビデオは、このドキュメントのコンセプトとタスクを学ぶための視覚的な方法を提供します。


動画チャプター
[ 0:11 ] プロンプトとPrompt Labの紹介
[ 0:33 ] キーコンセプト:すべてはテキスト補完である
[ 1:34 ] 便利なプロンプトパターン:Few-shot prompt
[ 1:58 ] 停止基準:最大トークン、ストップシーケンス
[ 3:32 ] キーコンセプト:微調整
[ 4:32 ] 便利なプロンプトパターン:ゼロショットプロンプト
[ 5:32 ] キーコンセプト:Be flexible, try different prompts
[ 6:14 ] 次のステップ:サンプルプロンプトで実験する

 

サンプルの概要

以下のタスクをサポートする出力を生成するように基盤モデルにプロンプトを出すサンプルを見つけることができます。

次の表に、使用可能なプロンプトのサンプルをまとめます。

表 1. プロンプトのサンプル一覧
シナリオ プロンプト・エディター プロンプトの形式 モデル デコード ノート
ゼロショットプロンプトでサンプルメッセージを分類する フリー・フォーム ゼロショット • mt0-xxl-13b
• flan-t5-xxl-11b
• flan-ul2-20b
• mixtral-8x7b-instruct-v01
欲張り - クラス名を出力した後にモデルを停止させるために、停止シーケンスとしてクラス名を使用する
Graniteを用いた即時入力の安全性分類サンプル フリー・フォーム カスタムシステムプロンプト Graniteのモデル 欲張り - コンテンツが有害かどうかに応じて「Yes」または「No」応答を返す。
即時入力の安全性を分類するサンプル フリー・フォーム カスタムシステムプロンプト • llama-guard-3-11b-vision 欲張り - セーフまたはアンセーフのクラスを返す。 コンテンツが安全でない場合は、違反のカテゴリーも返す。
サンプル日本語のメッセージを分類する フリー・フォーム フューショット • elyza-japanese-llama-2-7b-instruct 欲張り - クラス名を停止シーケンスとして使用
サンプルアラビア語のメッセージを分類する フリー・フォーム フューショット • allam-1-13b-instruct 欲張り - クラス名を停止シーケンスとして使用
サンプル苦情から詳細を抽出する フリー・フォーム ゼロショット • flan-ul2-20b 欲張り
サンプル文章から詳細を抜き出し、分類する フリー・フォーム ゼロショット • flan-ul2-20b 欲張り
サンプル:構造化モードのテーマで番号付きリストを生成する 構造化 フューショット • mixtral-8x7b-instruct-v01 サンプリング -
- フォーマットされた出力を生成する 改行2文字をストップシーケンスとして使用
サンプルGraniteで特定のテーマの番号付きリストを生成する フリー・フォーム ゼロショット • granite-13b-instruct-v2 欲張り - フォーマットされた出力を生成する
サンプル自由形式で記事に基づいて質問に答える フリー・フォーム ゼロショット • mt0-xxl-13b
• flan-t5-xxl-11b
• flan-ul2-20b
• mixtral-8x7b-instruct-v01
欲張り - ピリオド「 を停止シーケンスとして使用することで、モデルが単一の文のみを返すようにする
サンプルGraniteの文書に基づいて質問に答える フリー・フォーム ゼロショット • granite-13b-instruct-v2 欲張り
サンプルGranite 3.1て、複数の文書に基づいて質問に答える フリー・フォーム ゼロショット Graniteインストラクターモデル 欲張り
サンプル一般常識問題に答える フリー・フォーム ゼロショット • granite-13b-instruct-v2 欲張り
サンプル日本語の一般常識問題に答える フリー・フォーム ゼロショット • granite-8b-japanese 欲張り
サンプル:自由形式モードで複雑な推論を使って質問に答える フリー・フォーム ワンショット • mistral-large
• mistral-large-instruct-2411
欲張り - 改行2文字をストップシーケンスとして使用
ゼロショットプロンプトのサンプル会議の記録を要約する フリー・フォーム ゼロショット • flan-t5-xxl-11b
• flan-ul2-20b
• mixtral-8x7b-instruct-v01
欲張り
数ショットプロンプトのサンプル Granite 3.1てフリーフォームで会議の記録を要約する フリー・フォーム フューショット Graniteインストラクターモデル 欲張り
サンプルパッセージのタイトル作成する フリー・フォーム ワンショット • granite-7b-lab 欲張り - <|endoftext|>という名前の特別なトークンをストップシーケンスとして使う。
サンプル:命令からプログラムコードを生成する フリー・フォーム フューショット • codestral-22b
• codestral-2501
• mixtral-8x7b-instruct-v01
• codellama-34b-instruct-hf
欲張り - 出力としてプログラムコードを生成
- 停止シーケンスとして<end of code>を使用
サンプル:ゼロショットプロンプトで命令からプログラムコードを生成する フリー・フォーム フューショット • llama-3-2-1b-instruct
• llama-3-2-3b-instruct
欲張り - 出力としてプログラムコードを生成する
- カスタムテンプレートを使用する
サンプル:あるプログラミング言語から別のプログラミング言語へコードを変換する フリー・フォーム フューショット • mixtral-8x7b-instruct-v01
• codellama-34b-instruct-hf
欲張り - 出力としてプログラムコードを生成
- 停止シーケンスとして<end of code>を使用
サンプル:Graniteで命令からプログラムコードを生成する フリー・フォーム フューショット Granite 欲張り - 出力としてプログラムコードを生成
サンプルGraniteを使用して、あるプログラミング言語から別のプログラミング言語へコードを変換する フリー・フォーム フューショット Granite 欲張り - 出力としてプログラムコードを生成
サンプル:SQLで情報源を検索する フリー・フォーム フューショット • granite-20b-code-base-schema-linking 欲張り • SQLに関するテキストを出力として生成
サンプル:SQL文を生成する フリー・フォーム フューショット • granite-20b-code-base-sql-gen 欲張り • 出力としてSQLステートメントを生成
サンプルLlama 3との会話 フリー・フォーム カスタム構造 • llama-3-3-70b-instruct
• llama-3-2-1b-instruct
• llama-3-2-3b-instruct
• llama-3-1-8b-instruct
• llama-3-405b-instruct
• llama-3-8b-instruct
• llama-3-70b-instruct
欲張り - チャットボットのようなダイアログ出力を生成
- モデル固有のプロンプト形式を使用
サンプルLlama 2との会話 フリー・フォーム カスタム構造 - llama-2チャット 欲張り - チャットボットのようなダイアログ出力を生成
- モデル固有のプロンプト形式を使用
サンプルgranite-13b-chat-v2との会話 フリー・フォーム カスタム構造 • granite-13b-chat-v2 欲張り - チャットボットのようにダイアログ出力を生成する
- ダイアログのガードレールを確立するためにシステムプロンプトを使用する
サンプルgranite-8b-japaneseを使った日本語での会話 フリー・フォーム カスタム構造 • granite-8b-japanese 欲張り - チャットボットのような日本語ダイアログ出力を生成
- モデル固有のプロンプト形式を使用
サンプルjais-13b-chatを使ったアラビア語の会話 フリー・フォーム カスタム構造 • jais-13b-chat 欲張り - チャットボットのように英語またはアラビア語のダイアログ出力を生成
- モデル固有のプロンプト形式を使用
サンプルとの会話 granite-3-2-8b-instruct フリー・フォーム カスタム構造 • granite-13b-chat-v2 欲張り - チャットボットのようなダイアログ出力を生成
- 出力に推論の詳細を含めるかどうかをモデルで制御できるシステムプロンプトを使用します
サンプル:テキストを日本語から英語に翻訳する フリー・フォーム ゼロショット • elyza-japanese-llama-2-7b-instruct 欲張り - 日本語から英語への翻訳
サンプルテキストをスペイン語から英語に翻訳する フリー・フォーム フューショット • mixtral-8x7b-instruct-v01
• mistral-large
欲張り - テキストをスペイン語から英語に翻訳
サンプルテキストを英語から日本語に翻訳する フリー・フォーム ゼロショット • granite-8b-japanese 欲張り - テキストを英語から日本語に翻訳
サンプルテキストをフランス語から英語に翻訳する フリー・フォーム フューショット • granite-20b-multilingual 欲張り - テキストをフランス語から英語に翻訳
サンプルテキストを英語からアラビア語に翻訳する フリー・フォーム フューショット • allam-1-13b-instruct 欲張り - テキストを英語からアラビア語に翻訳

機密区分

分類は、データを明確なカテゴリーで予測するのに役立つ。 分類には、2つのクラスに分類するバイナリと、複数のクラスに分類するマルチクラスがある。 分類タスクは、顧客からのフィードバックなどの情報を分類し、より効率的に情報を管理したり行動したりするのに便利です。

ゼロショットプロンプトでサンプルメッセージを分類する

シナリオクラウドソフトウェア会社のカスタマーサポートチャットボットに送信されたメッセージがある場合、顧客のメッセージを質問か問題のいずれかに分類する。 クラスの割り当てに応じて、チャットは問題のタイプに適したサポートチームにルーティングされます。

モデル選択

インストラクションチューニングされたモデルであれば、このプロンプトのサンプルでこのタスクを完了することができます。

提案:mt0-xxl-13b、flan-t5-xxl-11b、flan-ul2-20b、mistral-large、またはmixtral-8x7b-instruct-v01

モデル パラメータ

  • デコードGreedy に設定する。 モデルは、指定されたクラス名のいずれかを返さなければなりません。 モデルは創造的になることができず、新しいクラスを作成することができない。
  • 停止基準 :「質問」と「問題」の2つの停止シーケンスを指定します。 モデルがこれらの単語のいずれかを生成した後は、停止するはずだ。 出力が短いので 、Max tokensパラメータは 5に設定できます。

プロンプト・テキスト

このゼロショットプロンプトテキストを Prompt Labのフリーフォームプロンプトエディタに貼り付け、モデルを選択し、パラメータを設定し、 Generateをクリックして結果を確認する。

Classify this customer message into one of two classes: Question, Problem.

Class name: Question
Description: The customer is asking a technical question or a how-to question 
about our products or services.

Class name: Problem
Description: The customer is describing a problem they are having. They might 
say they are trying something, but it's not working. They might say they are 
getting an error or unexpected results.

Message: I'm having trouble registering for a new account.
Class name: 

Graniteを用いた即時入力の安全性分類サンプル

目標:プロンプトの入力テキストを安全か危険かに分類する。

モデル選択

GraniteGuardian のモデルは、入力されたプロンプトテキストの安全性を分類することができます。

モデル パラメータ

  • デコードGreedy に設定する。 モデルは、その入力が有害かどうかによって、2つの応答のいずれかを返さなければならない:はい」か「いいえ」である。
  • 停止基準 :このモデルは停止シーケンスを必要とせず、応答を返した後で停止します。

プロンプト・テキスト

Prompt Labのフリーフォームプロンプトエディタに以下のプロンプトテキストを貼り付け、モデルを選択してパラメータを設定し、 Generateをクリックして結果を確認します。

このモデルは、このプロンプトと同様のシステムプロンプトでトレーニングされた。

safety_template = f"""You are a safety agent trying to help determine whether the user message is harmful according to the safety risk definition below.

<start_of_turn>
User Message: {user_text}
<end_of_turn>

Our safety risk definition is defined below:

<start_of_risk_definition>
* {risk_definition}
<end_of_risk_definition>

Is the user message harmful based on the risk definition? Your answer must be either 'Yes' or 'No'."""

{user_text}を'"Tell me how to cheat on a test."ような有害な内容を評価したい入力テキストに置き換える。 {risk_definition}に識別すべきリスクを記述したモデルの指示を、'"The 'User' message contains actions that violate moral or professional standards, focusing on exploitation for personal gain or disregard for others' well-being. This category excludes physical violence or explicit bias, instead covering activities like fraud, theft, or abuse of power."ように定義する。

user_textと'risk_definitionをフリーフォームエディタのプロンプト変数として定義することもできる。

このモデルは次のようなレスポンスを生成する:

assistantYes

モデル(回答の中では「アシスタント」と表示されている)は、「はい」か「いいえ」の答えを生成する。

即時入力の安全性を分類するサンプル

目標:プロンプトの入力テキストを安全か危険かに分類する。

モデル選択

llama-guard-3-11b-visionは、プロンプト入力のテキストと画像の両方の安全性を分類することができます。

モデル パラメータ

  • デコードGreedy に設定する。 モデルは、safeまたはunsafeの2つのクラス名のいずれかを返さなければなりません。 モデルは創造的になることができず、新しいクラスを作成することができない。
  • 停止基準 :モデルは停止シーケンスを必要とせず、クラスを返した後、また該当する場合は検出された違反のカテゴリーを返した後、停止します。

プロンプト・テキスト

このプロンプトテキストを Prompt Labのフリーフォームプロンプトエディタに貼り付け、モデルを選択し、パラメータを設定し、 Generateをクリックすると結果が表示されます。

このモデルは、このプロンプトと同様のシステムプロンプトでトレーニングされた。

<|begin_of_text|><|start_header_id|>user<|end_header_id|>

<BEGIN CONVERSATION>

User: ${your-question-goes-here}

<END CONVERSATION>

Provide your safety assessment:
- First line must read 'safe' or 'unsafe'.
- If unsafe, a second line must include a comma-separated list of violated categories.<|eot_id|><|start_header_id|>assistant<|end_header_id|>

${your-question-goes-here}What is the first paragraph of the book, "Developing Quality Technical Information: A Handbook for Writers and Editors"?のような安全でない内容を含む質問に置き換える

このモデルは以下のような分類を生成する:

unsafe
S7

分類カテゴリS7は、安全でないコンテンツがプライバシーカテゴリに違反していることを示します。 llama-guard-3-11b-vision、 基盤モデル認識するように訓練されているカテゴリの詳細については、 ラマガード3のドキュメントを参照してください。

サンプル日本語のメッセージを分類する

シナリオ日本のクラウドソフトウェア会社のカスタマーサポートチャットボットに送信されたメッセージがある場合、顧客のメッセージを質問か問題の説明のどちらかに分類する。 クラスタイプに基づいて、チャットは適切なサポートチームにルーティングすることができます。

モデル選択

elyza-japanese-llama-2-elyza-japanese-llama-2-7b-instructb-instructモデルは、日本語で書かれたプロンプト入力テキストを分類することができる。

モデルのパラメータ

  • AIガードレール :AIガードレール機能は、コンテンツを不適切として誤ってフラグを付ける可能性があるため、無効にします。 この機能は英語テキストにのみ対応しています。
  • デコードGreedy に設定する。 モデルは、指定されたクラス名のいずれかを返さなければなりません。 モデルは創造的になることができず、新しいクラスを作成することができない。
  • 停止基準 :問題用に 問題 、質問用に 質問 の2つの停止シーケンスを指定します。 モデルがこれらの単語のいずれかを生成した後は、停止するはずだ。 Max tokensパラメータの値を下げる場合は、7トークン未満に下げないでください。 日本語の文字は英語の同じ単語よりも多くのトークンを使う。

プロンプト・テキスト

この数発のプロンプトテキストを Prompt Labのフリーフォームプロンプトエディタに貼り付け、モデルを選択し、パラメータを設定し、 Generateをクリックすると結果が表示されます。

次のメッセージを問題または質問に分類します。

メッセージ: ログインしようとすると、エラーが発生します。
クラス名: 問題

メッセージ: プランの価格はどこで確認できますか?
クラス名: 質問

メッセージ: トライアルとペイゴーの違いは何ですか?
クラス名: 質問

メッセージ: 登録ページがクラッシュしたため、新しいアカウントを作成できません。
クラス名: 問題

メッセージ: どの地域がサポートされていますか?
クラス名: 質問

メッセージ: パスワードを思い出せません。
クラス名: 問題

メッセージ: 新しいアカウントの登録で問題が発生しました。
クラス名:

サンプルアラビア語のメッセージを分類する

シナリオアラビア語のクラウドソフトウェア会社のカスタマーサポートチャットボットに送信されたメッセージがある場合、顧客のメッセージを質問か問題の説明のどちらかに分類する。 クラスタイプに基づいて、チャットは適切なサポートチームにルーティングすることができます。

モデル選択

allam-1-13b-instruct 基盤モデル、アラビア語で書かれた入力テキストを迅速に分類することができる。

モデル パラメータ

  • AIガードレール :AIガードレール機能は、コンテンツを不適切として誤ってフラグを付ける可能性があるため、無効にします。 この機能は英語テキストにのみ対応しています。
  • デコードGreedy に設定する。 モデルは指定されたクラス名のいずれかを返さなければならない。
  • 停止基準 :通常、モデルはクラスラベルを生成した後、さらに支援を提供します。 オプションとして、2つの停止シーケンスを指定することで、テキストの分類後にモデルを停止することができます。問題の場合は مشكلة 、質問の場合は سؤال です。

プロンプト・テキスト

この数発のプロンプトテキストを Prompt Labのフリーフォームプロンプトエディタに貼り付け、モデルを選択し、パラメータを設定し、 Generateをクリックすると結果が表示されます。

<s> [INST] قم بتصنيف رسالة العميل هذه إلى إحدى فئتين: سؤال، مشكلة.

الرسالة: عندما أحاول تسجيل الدخول، تظهر لي رسالة خطأ.
اسم الفئة: مشكلة

الرسالة: أين يمكنني العثور على أسعار الخطة؟
اسم الفصل: سؤال

الرسالة: ما الفرق بين التجربة والدفع؟
اسم الفصل: سؤال

الرسالة: تعطلت صفحة التسجيل، ولا أستطيع الآن إنشاء حساب جديد.
اسم الفئة: مشكلة

الرسالة: ما هي المناطق المدعومة؟
اسم الفصل: سؤال

الرسالة: لا أستطيع تذكر كلمة المرور الخاصة بي.
اسم الفئة: مشكلة

الرسالة: أواجه مشكلة في التسجيل للحصول على حساب جديد.
اسم الفئة:
[/INST]

 

詳細の抽出

抽出タスクは、単純なテキストの一致ではなく、単語の意味に基づいてデータ内の重要な用語や言及を見つけるのに役立ちます。

サンプル苦情から詳細を抽出する

シナリオ予約サイトでフライトの予約に失敗した顧客からの苦情を想定し、この顧客の不満足な体験の要因を特定する。

モデルの選択

flan-ul2-20b

モデル パラメータ

  • デコードGreedy に設定する。 モデルは、入力にある単語を返す必要がある。モデルは創造的で新しい単語を作ることはできない。
  • 停止基準 :抽出された要因のリストはそれほど長くないでしょう。そのため 、Max tokensパラメータを50に設定します。

プロンプト・テキスト

このゼロショットプロンプトテキストを Prompt Labのフリーフォームプロンプトエディタに貼り付け、モデルを選択し、パラメータを設定し、 Generateをクリックして結果を確認する。

From the following customer complaint, extract all the factors that 
caused the customer to be unhappy.

Customer complaint:
I just tried to book a flight on your incredibly slow website. All 
the times and prices were confusing. I liked being able to compare 
the amenities in economy with business class side by side. But I 
never got to reserve a seat because I didn't understand the seat map. 
Next time, I'll use a travel agent!

Numbered list of all the factors that caused the customer to be unhappy:

サンプル文章から詳細を抜き出し、分類する

シナリオカテゴリーとパッセージのリストが与えられた場合、パッセージから異なるカテゴリータイプに当てはまる抜粋を特定する。

モデルの選択

mistral-largeまたはmixtral-8x7b-instruct-v01。

モデル パラメータ

  • デコードGreedy に設定する。 モデルは、入力にある単語を返す必要がある。モデルは創造的で新しい単語を作ることはできない。
  • 停止条件 :モデルが追加のテキストを生成する場合、2つの改行文字からなる停止シーケンスを指定することができます。 これを実行するには、 [停止シーケンス] テキストボックスをクリックし、Enterキーを2回押し、 [シーケンスの追加] をクリックします。

プロンプト・テキスト

Paste this zero-shot prompt text into the freeform prompt editor in Prompt Lab, select the model, and set the parameters. 個人識別情報を含むとして入力がフラグ付けされないようにするには 、AIガードレールを無効にする必要があります。 「生成」 をクリックすると結果が表示されます。

For each passage, extract the named entities that fit into the following categories:
Person, Measure, Number, Facility, Location, Product, Duration, Money, Time, PhoneNumber, Date, JobTitle, Organization, Percent, GeographicFeature, Address, Ordinal.
Passage:
Welcome to 123 Maple Lane, a charming and inviting 3-bedroom, 2-bathroom residence nestled in the heart of Springfield. This beautifully maintained home boasts 1,800 square feet of living space, perfect for families and first-time homebuyers alike.
- Spacious living room with a cozy fireplace and large windows for ample natural light
- Updated kitchen with stainless steel appliances, granite countertops, and ample cabinet space
- Master suite with a walk-in closet and en-suite bathroom featuring a soaking tub and separate shower
- Two additional well-appointed bedrooms and a full hallway bathroom
- Fully fenced backyard with a patio area, perfect for outdoor entertaining
- Attached two-car garage with additional storage space
- Conveniently located near top-rated schools, shopping centers, and parks
Don't miss your opportunity to own this fantastic home! Join us for the open house on Saturday, April 10th, 2023, from 1:00 PM to 4:00 PM.
**Price**
$350,000
**Seller Contact Details:**
John & Jane Doe
Phone: (555) 123-4567
Email: john.jane.doe@example.com

自然言語の生成

生成タスクは、大規模な言語モデルが最も得意とするものだ。 あなたのプロンプトは、モデルが有用な言語を生成するよう導くのに役立つ。

数発のプロンプトでサンプル構造化モードでテーマに沿った番号付きリストを作成する

シナリオ特定のテーマに関する番号付きリストを作成する。

モデル選択

mixtral-8x7b-instruct-v01 基盤モデル、改行文字などの特殊文字を認識し、うまく扱うように訓練されている。 このモデルは、生成されたテキストを特殊文字で特定の書式にしたい場合に適している。

モデル パラメータ

  • デコードサンプリングに設定します。 このシナリオは創造的なものだ。 以下のパラメーターを設定します。
    • 温度:0.7
    • トップP:1
    • トップK:50
    • ランダムシード:9045 (異なる結果を生成するには、ランダムシードパラメータに異なる値を指定するか、パラメータをクリアする)
  • 停止条件 :モデルが1つのリストのテキスト生成を確実に停止させるには、改行文字2文字の停止シーケンスを指定します。 これを実行するには、 [停止] シーケンスのテキストボックスをクリックし、Enterキーを2回押し、 [シーケンスの追加] をクリックします。 リストはそれほど長くないでしょうから 、Max tokensパラメータを50に設定します。

セットアップセクション

これらのヘッダーと例を、Set upセクションのExamplesエリアに貼り付けます:

表 3. ジェネレーション・セルショットの例
Input: Output:
What are 4 types of dog breed? 1. Poodle
2. Dalmatian
3. Golden retriever
4. Bulldog
What are 3 ways to incorporate exercise into your day? 1. Go for a walk at lunch
2. Take the stairs instead of the elevator
3. Park farther away from your destination
What are 4 kinds of vegetable? 1. Spinach
2. Carrots
3. Broccoli
4. Cauliflower
What are the 3 primary colors? 1. Red
2. Green
3. Blue

セクションを試す

この入力をTryセクションに貼り付ける:

What are 3 ingredients that are good on pizza?

モデルを選択してパラメータを設定し、Generateをクリックして結果を見る。

ゼロショットのプロンプトでサンプル特定のテーマに関する番号付きリストの作成

シナリオモデルに悪魔の弁護人を演じてもらう。 可能性のある行動を説明し、その行動に関連する可能性のあるマイナス面やリスクを挙げてもらう。

モデル選択

granite-13b-instructモデルは、改行文字などの特殊文字を認識し、うまく扱うように訓練されている。 granite-13b-instruct-v2モデルは、生成されるテキストを特殊文字で特定の書式にしたい場合によい選択である。

モデル パラメータ

  • デコードGreedy に設定する。 モデルは、プロンプトの内容に基づいて最も予測可能なコンテンツを返さなければならない。
  • 停止基準 :要約は複数の文にわたる可能性があるため 、[最大トークン数] パラメータを 60 に設定します。

プロンプト・テキスト

このプロンプトテキストを Prompt Labのフリーフォームプロンプトエディタに貼り付け、モデルを選択し、パラメータを設定し、 Generateをクリックすると結果が表示されます。

You are playing the role of devil's advocate. Argue against the proposed plans. List 3 detailed, unique, compelling reasons why moving forward with the plan would be a bad choice. Consider all types of risks.

Plan we are considering:
Extend our store hours.
Three problems with this plan are:
1. We'll have to pay more for staffing.
2. Risk of theft increases late at night.
3. Clerks might not want to work later hours.

Plan we are considering:
Open a second location for our business.
Three problems with this plan are:
1. Managing two locations will be more than twice as time-consuming than managed just one.
2. Creating a new location doesn't guarantee twice as many customers.
3. A new location means added real estate, utility, and personnel expenses.

Plan we are considering:
Refreshing our brand image by creating a new logo.
Three problems with this plan are:

質問への回答

質問応答タスクは、ヘルプシステムなど、よく聞かれる質問やより微妙な質問に既存のコンテンツから回答できるような場面で有用である。

モデルが事実上の回答を返すのを支援するために、検索拡張生成パターンを実装します。 詳しくは、 検索拡張生成を参照してください。

サンプル自由形式で記事に基づいて質問に答える

シナリオあるオンライン種子カタログのウェブサイトには、顧客が庭造りを計画し、最終的にどの種子を購入するかを選択するのに役立つ記事が多数掲載されている。 顧客が閲覧している記事の内容に基づいて、顧客の質問に答える新しいウィジェットがウェブサイトに追加される。 記事に関連した質問が与えられたら、記事に基づいてその質問に答える。

モデル選択

flan-t5-xxl-11b、flan-ul2-20b、mixtral-8x7b-instruct-v01、mt0-xxl-13bのようなインストラクションチューニングされたモデルは、通常、このサンプルプロンプトでこのタスクを完了できます。

モデル パラメータ

  • デコードGreedy に設定する。 回答は記事の事実に基づいたものでなければならず、記事の中に良い答えがない場合、模範解答は創造的に答えを作り上げてはならない。
  • 停止基準 :モデルに1文の回答を返させるには、ピリオド「.」を指定します をストップシーケンスとして使用する。 Max tokensパラメータは50に設定できます。

プロンプト・テキスト

このゼロショットプロンプトテキストを Prompt Labのフリーフォームプロンプトエディタに貼り付け、モデルを選択し、パラメータを設定し、 Generateをクリックして結果を確認する。

Article:
###
Tomatoes are one of the most popular plants for vegetable gardens. 
Tip for success: If you select varieties that are resistant to 
disease and pests, growing tomatoes can be quite easy. For 
experienced gardeners looking for a challenge, there are endless 
heirloom and specialty varieties to cultivate. Tomato plants come 
in a range of sizes. There are varieties that stay very small, less 
than 12 inches, and grow well in a pot or hanging basket on a balcony 
or patio. Some grow into bushes that are a few feet high and wide, 
and can be grown is larger containers. Other varieties grow into 
huge bushes that are several feet wide and high in a planter or 
garden bed. Still other varieties grow as long vines, six feet or 
more, and love to climb trellises. Tomato plants do best in full 
sun. You need to water tomatoes deeply and often. Using mulch 
prevents soil-borne disease from splashing up onto the fruit when you 
water. Pruning suckers and even pinching the tips will encourage the 
plant to put all its energy into producing fruit.
###

Answer the following question using only information from the article. 
Answer in a complete sentence, with proper capitalization and punctuation. 
If there is no good answer in the article, say "I don't know".

Question: Why should you use mulch when growing tomatoes?
Answer: 

他の質問をしてみるのもいい:

  • 「トマトの苗はどのくらい大きくなるのか?
  • 「トマトは日陰と日向のどちらを好むか?
  • 「トマトの栽培は簡単ですか?

スコープ外の質問も試してみよう:

  • 「キュウリの育て方は?

サンプルGraniteを含む文書に基づいて質問に答える

シナリオあなたはユーザーの質問に答えるチャットボットを作成しています。 ユーザが質問したとき、エージェントが特定のドキュメントからの情報を使って質問に答えるようにしたい。

モデル選択

granite-13b-instruct-v2のようなインストラクションチューンのモデルは、このサンプルプロンプトでタスクを完了することができます。

モデル パラメータ

  • デコードGreedy に設定する。 また、記事の中に良い答えがない場合、模範解答は創作的であってはならない。
  • 停止基準 :Max tokensパラメータを50に設定します。

プロンプト・テキスト

このゼロショットプロンプトテキストを Prompt Labのフリーフォームプロンプトエディタに貼り付け、モデルを選択し、パラメータを設定し、 Generateをクリックして結果を確認する。

Given the document and the current conversation between a user and an agent, your task is as follows: Answer any user query by using information from the document. The response should be detailed.

DOCUMENT: Foundation models are large AI models that have billions of parameters and are trained on terabytes of data. Foundation models can do various tasks, including text, code, or image generation, classification, conversation, and more. Large language models are a subset of foundation models that can do text- and code-related tasks.
DIALOG: USER: What are foundation models?

サンプルGranite 3.1て、複数の文書に基づいて質問に答える

シナリオあなたはユーザーの質問に答えるチャットボットを作成しています。 ユーザが質問した場合、エージェントは特定のドキュメントからの情報で質問に答えたい。

モデル選択

GraniteInstructのようなインストラクションチューンのモデルは、このサンプルプロンプトでタスクを完了することができる。

モデル パラメータ

  • デコードGreedy に設定する。 また、記事の中に良い答えがない場合、模範解答は創作的であってはならない。
  • 停止基準 :要約の後にテキストの生成を確実に停止させるには、改行文字2つの停止シーケンスを指定します。 これを実行するには、 [停止] シーケンスのテキストボックスをクリックし、 <|end_of_text|> と入力し、 [シーケンスの追加] をクリックします。 Max tokens パラメータを200に設定します。

プロンプト・テキスト

このゼロショットプロンプトテキストを Prompt Labのフリーフォームプロンプトエディタに貼り付け、モデルを選択し、パラメータを設定し、 Generateをクリックして結果を確認する。

<|start_of_role|>system<|end_of_role|>You are an expert in medical science.<|end_of_text|>
<|start_of_role|>user<|end_of_role|>Use the following documents as context to complete the task.

Document 1:
The human body is a complex and intricate system, composed of various interconnected parts that work together to maintain life. At the most fundamental level, the body is made up of cells, the basic units of life. These cells are organized into tissues, which are then grouped together to form organs. Organs, in turn, make up the various systems that carry out the body's functions.

Document 2:
One of the most important systems in the human body is the circulatory system. This system is responsible for transporting oxygen, nutrients, and hormones throughout the body. It is composed of the heart, blood vessels, and blood. The heart acts as a pump, pushing blood through the blood vessels and into the capillaries, where the exchange of oxygen, nutrients, and waste products takes place.

Document 3:
Another crucial system is the respiratory system. This system is responsible for the intake and exchange of oxygen and carbon dioxide. It is composed of the nose, throat, trachea, bronchi, and lungs. When we breathe in, air enters the nose or mouth and travels down the trachea into the lungs. Here, oxygen is absorbed into the bloodstream and carbon dioxide is expelled.

Document 4:
The human body also has a nervous system, which is responsible for transmitting signals between different parts of the body. This system is composed of the brain, spinal cord, and nerves. The brain acts as the control center, processing information and sending signals to the rest of the body. The spinal cord serves as a conduit for these signals, while the nerves transmit them to the various organs and tissues.


Which system in the human body is reponsible for breathing?<|end_of_text|>
<|start_of_role|>assistant<|end_of_role|>

サンプル一般常識問題に答える

シナリオ財務に関する一般的な質問に答える。

モデル選択

granite-13b-instruct-v2モデルは、テキスト生成、要約、質問と回答、分類、抽出などの複数のタスクに使用できる。

モデル パラメータ

  • デコードGreedy に設定する。 このサンプルは質問に答えるものなので、クリエイティブなアウトプットは求めていません。
  • 停止基準 :モデルが完全な回答を返せるように 、Max tokensパラメータを200に設定します。

プロンプト・テキスト

このモデルは、次のような形式で例を挙げながら、質問応答用に調整された:

<|user|>
質問の内容
<|assistant|>
モデルの回答用の新しい行

質問の前後の行で、「<|user|>」と「<|assistant|>構文を正確に使用するか、「User」や「Assistantような同等の用語で値を置き換えることができます。

バージョン1を使用している場合は、'<|assistant|>ラベルの後に空白を入れず、必ず改行してください。

このプロンプトテキストを Prompt Labのフリーフォームプロンプトエディタに貼り付け、モデルを選択し、パラメータを設定し、 Generateをクリックすると結果が表示されます。

<|user|>
Tell me about interest rates
<|assistant|>

モデルが答えを生成した後、フォローアップの質問をすることができる。 モデルは、回答を生成する際に、前の質問からの情報を使用する。

<|user|>
Who sets it?
<|assistant|>

このモデルは、次の質問に答えるときに、前の質問からの情報を保持しますが、拡張ダイアログをサポートするように最適化されていません。

注:フォローアップの質問をすると、前の質問が再度送信され、使用されるトークンの数が追加されます。

サンプル日本語の一般常識問題に答える

シナリオ金融に関する一般的な質問に日本語で答える。

モデル選択

granite-8b-japaneseモデルは、テキスト生成、要約、質問と回答、分類、抽出などの複数のタスクに使用できる。

モデル パラメータ

  • デコードGreedy に設定する。 このサンプルは質問に答えるものなので、クリエイティブなアウトプットは求めていません。
  • 停止基準 :ダイアログで多くのターンを可能にするために 、Max tokensパラメータを500に設定します。 基盤モデル過度に長い応答を返すのを防ぐために、2つの改行文字からなる停止シーケンスを追加する。 これを実行するには、 [停止] シーケンスのテキストボックスをクリックし、Enterキーを2回押し、 [シーケンスの追加] をクリックします。

プロンプト・テキスト

このモデルは、次のような形式で例を挙げながら、質問応答用に調整された:

以下は、タスクを説明する指示と、文脈のある入力の組み合わせです。要求を適切に満たす応答を書きなさい。

### 指示:
与えられた質問に対して、文脈がある場合はそれも利用し、回答してください。

### 入力:
{your-input}

### 応答:

英語では次のようになる:

Below is a combination of instructions that describe the task and input with context. Write a response that appropriately meets the request.

### Instructions:
Please use the context when answering the given question, if available.

### input:
{your-input}

### Response:

このプロンプトテキストを Prompt Labのフリーフォームプロンプトエディタに貼り付け、モデルを選択し、パラメータを設定し、 {your-input} をクエリまたはリクエストに置き換えて、 Generateをクリックすると結果が表示されます。

例えば、このプロンプトは金利について尋ねている。

以下は、タスクを説明する指示と、文脈のある入力の組み合わせです。要求を適切に満たす応答を書きなさい。

### 指示:
与えられた質問に対して、文脈がある場合はそれも利用し、回答してください。

### 入力:
金利について教えてください。

### 応答:

サンプル自由形式モードで複雑な推論を使って質問に答える

シナリオ推論と論理的理解を必要とする一般的な質問に答えるよう、モデルに求める。

モデル選択

mistral-largeのような複雑な推論タスクのためにインストラクションチューニングされたモデルは、一般的にこのサンプルプロンプトでこのタスクを完了することができます。

モデル パラメータ

  • デコードGreedy に設定する。 モデルは、プロンプトの内容に基づいて最も予測可能なコンテンツを返さなければならない。
  • 停止基準 :要約の後にテキストの生成を確実に停止させるには、改行文字2つの停止シーケンスを指定します。 これを実行するには、 [停止] シーケンスのテキストボックスをクリックし、Enterキーを2回押し、 [シーケンスの追加] をクリックします。 Max tokens パラメータを100に設定します。

プロンプト・テキスト

この数発のプロンプトテキストを Prompt Labのフリーフォームプロンプトエディタに貼り付け、モデルを選択し、パラメータを設定し、 Generateをクリックすると結果が表示されます。

Question: Which one is heavier a pound of iron or a kilogram of feather?
Answer: A kilogram of feathers is heavier than a pound of iron. A pound is a unit of weight that is equivalent to approximately 0.453592 kilograms. Therefore, a pound of iron weighs less than a kilogram of feathers.

Question: A bat and a ball cost $1.10 in total. The bat costs $1.00 more than the ball. How much does the ball cost?
Answer:

サンプル: DeepSeek-R1 モデルをフリーフォームモードで蒸留し、複雑な推論を使用して質問に回答する

シナリオ推論と論理的理解を必要とする一般的な質問に答えるよう、モデルに求める。

モデル選択

deepseek-r1-distill-llama-8b や deepseek-r1-distill-llama-70b のような複雑な推論タスク向けにチューニングされたモデルは、一般的にこのサンプルプロンプトでこのタスクを完了することができます。

モデル パラメータ

  • デコードGreedy に設定する。 モデルは、プロンプトの内容に基づいて最も予測可能なコンテンツを返さなければならない。
  • 停止基準 :モデルが応答でより複雑な推論を行うようにするには 、[最大トークン] パラメータを 2000 に設定します。

プロンプト・テキスト

このゼロショットプロンプトテキストを Prompt Labのフリーフォームプロンプトエディタに貼り付け、モデルを選択し、パラメータを設定し、 Generateをクリックして結果を確認する。

注: システムプロンプトを追加しないようにしてください。 すべての指示はユーザープロンプト内に含まれていなければなりません。
<| begin_of_sentence |><| User |>Create a travel itinerary for a weekend trip to Paris.<| Assistant |><think>

モデルは、問題をどのように解決したかについての詳細を含む応答を生成します。 詳細は、 <think></think> タグ内に記載されています。 モデルは、質問に対する詳細な回答を構築します。

要約

要約作業は、大量のテキストをいくつかの重要な情報に凝縮することで、あなたの時間を節約します。

ゼロショットのプロンプトを使ったサンプル会議の記録を要約する

シナリオ会議録が与えられたら、要点だけを会議メモとしてまとめ、そのメモを会議に出席していないチームメイトと共有できるようにする。

モデル選択

インストラクションチューニングされたモデルであれば、このプロンプトのサンプルでこのタスクを完了することができます。 提案:flan-t5-xxl-11b、flan-ul2-20b、またはmixtral-8x7b-instruct-v01。

モデル パラメータ

  • デコードGreedy に設定する。 モデルは、プロンプトの内容に基づいて最も予測可能なコンテンツを返さなければならない。
  • 停止基準 :要約は複数の文にわたる可能性があるため 、[最大トークン数] パラメータを 60 に設定します。

プロンプト・テキスト

このゼロショットプロンプトテキストを Prompt Labのフリーフォームプロンプトエディタに貼り付け、モデルを選択し、パラメータを設定し、 Generateをクリックして結果を確認する。

Summarize the following transcript.
Transcript:
00:00   [alex]  Let's plan the team party!
00:10   [ali]   How about we go out for lunch at the restaurant?
00:21   [sam]   Good idea.
00:47   [sam]   Can we go to a movie too?
01:04   [alex]  Maybe golf?
01:15   [sam]   We could give people an option to do one or the other.
01:29   [alex]  I like this plan. Let's have a party!
Summary:

数ショットプロンプトのサンプル Granite 3.1てフリーフォームで会議の記録を要約する

シナリオ会議録が与えられたら、要点だけを会議メモとしてまとめ、そのメモを会議に出席していないチームメイトと共有できるようにする。

モデル選択

数ショットの作例があれば、ほとんどのモデルはこのタスクを十分にこなすことができる。 Graniteのモデルを試してみよう。

モデル パラメータ

  • デコードGreedy に設定する。 モデルは、プロンプトの内容に基づいて最も予測可能なコンテンツを返さなければならない。
  • 停止基準 :要約の後にテキストの生成を確実に停止させるには、改行文字2つの停止シーケンスを指定します。 これを実行するには、 [停止] シーケンスのテキストボックスをクリックし、 <|end_of_text|> と入力し、 [シーケンスの追加] をクリックします。 Max tokens パラメータを200に設定します。

プロンプト・テキスト

この数発のプロンプトテキストを Prompt Labのフリーフォームプロンプトエディタに貼り付け、モデルを選択し、パラメータを設定し、 Generateをクリックすると結果が表示されます。

<|start_of_role|>system<|end_of_role|>You are Granite, an AI language model developed by IBM in 2024. You are a cautious assistant. You carefully follow instructions. You are helpful and harmless and you follow ethical guidelines and promote positive behavior.<|end_of_text|>
<|start_of_role|>user<|end_of_role|>Summarize a fragment of a meeting transcript. In this meeting, Sam, Erin, and Alex discuss updates.
Your response should only include the answer. Do not provide any further explanation.

Transcript:

Sam (00:00):
I wanted to share an update on project X today.

Sam (00:15):
Project X will be completed at the end of the week.

Erin (00:30):
That's great!

Erin (00:35):
I heard from customer Y today, and they agreed to buy our product.

Alex (00:45):
Customer Z said they will too.

Sam (01:05):
Great news, all around.

Summary:
<|end_of_text|>
<|start_of_role|>assistant<|end_of_role|>Sam shared an update that project X will be complete at the end of the week. Erin said customer Y will buy our product. And Alex said customer Z will buy our product too.<|end_of_text|>

Transcript:

Ali (00:00):
The goal today is to agree on a design solution.

Alex (00:12):
I think we should consider choice 1.

Ali (00:25):
I agree

Erin (00:40):
Choice 2 has the advantage that it will take less time.

Alex (01:03):
Actually, that's a good point.

Ali (01:30):
So, what should we do?

Alex (01:55):
I'm good with choice 2.

Erin (02:20):
Me too.

Ali (02:45):
Done!

Summary:
<|end_of_text|>
<|start_of_role|>assistant<|end_of_role|>

サンプルパッセージのタイトル作成する

シナリオある文章が与えられたら、その内容にふさわしいタイトルください。

モデル選択

granite-7b-lab、多くの種類の汎用タスクを実行できる。

モデル パラメータ

  • デコードGreedy に設定する。 モデルは、プロンプトの内容に基づいてタイトル生成しなければならない。

  • 停止基準 :停止シーケンスとして <|endoftext|>

    granite-7b-lab 基盤モデルモデルの便利な特徴は、各レスポンスの最後に <|endoftext|> という特別なトークンが含まれていることである。 生成モデルの中には、許容される最大数よりも少ないトークンで入力に対する応答を返すものがある場合、入力からパターンを繰り返すことができる。 このモデルでは、プロンプトに信頼性の高いストップシーケンスを組み込むことで、このような繰り返しを防いでいる。

プロンプト・テキスト

モデルにどのような反応をさせたいか、少なくとも1つの例を挙げてください。

granite-7b-lab 基盤モデル特徴として、 基盤モデルモデルカードからトレーニングタクソノミーのページを開くことで、モデルがトレーニングを受けているスキルを確認することができます。

例えば、 granite-7b-lab 基盤モデル、 title スキルでトレーニングされたことを示す。 スキルをクリックすると、モデルの訓練に使われた合成データのシード例として使われた例を見ることができる。 one-shotプロンプト含める例は、これらのスキル固有の例のいずれかをモデルにしてもよい。 プロンプトに同じようなスタイルと書式を使用することで、モデルの出力に何を期待しているかをモデルが認識しやすくなります。

注: 基盤モデル出力が、タクソノミーのスキル例からのモデル出力とまったく同じであることを期待しないでください。 これらの例は、 基盤モデル訓練には直接使われなかった。 この例は、 基盤モデル訓練に使用される新しい例を生成する合成データへのシード例として機能した。

このプロンプトテキストを Prompt Labのフリーフォームプロンプトエディタに貼り付け、モデルを選択し、パラメータを設定し、 Generateをクリックすると結果が表示されます。

その例はタイトルスキルシードの例から来ている。 プロンプトのコンテキストとして提供されるコンテンツは、製品ドキュメントの「 トークンとトークン化 」から引用されています。

<|system|>
You are an AI language model developed by IBM Research. You are a cautious assistant. You carefully follow instructions. You are helpful and harmless and you follow ethical guidelines and promote positive behavior.

<|user|>
Generate a title from the given text.
Context
Dana Blankstein- Cohen (born March 3, 1981) is the director of the Israeli Academy of Film and Television.\n\nShe is a film director, and an Israeli culture entrepreneur.\nLuciano Salce (25 September 1922, in Rome – 17 December 1989, in Rome) was an Italian film director, actor and lyricist.\n\nHis 1962 film "Le pillole di Ercole" was shown as part of a retrospective on Italian comedy at the 67th Venice International Film Festival.\n\nAs a writer of pop music, he used the pseudonym Pilantra.\n\nDuring World War II, he was a prisoner in Germany.\n\nHe later worked for several years in Brazil.\nVediamoci chiaro\n\n("Let\'s See It Clear") is a 1984 Italian comedy film directed by Luciano Salce.\n\nThe author Enrico Giacovelli referred to the film as "a kind of "Scent of a Woman" but more ambiguous, midway between Luigi Pirandello\'s "Henry IV" and "The Late Mattia Pascal.\nPeter Levin is an American director of film, television and theatre.\nIan Barry is an Australian director of film and TV.\nJesse Edward Hobson( May 2, 1911 – November 5, 1970) was the director of SRI International from 1947 to 1955.\n\nPrior to SRI, he was the director of the Armour Research Foundation.\nOlav Aaraas( born 10 July 1950) is a Norwegian historian and museum director.\n\nHe was born in Fredrikstad.\n\nFrom 1982 to 1993 he was the director of Sogn Folk Museum, from 1993 to 2010 he was the director of Maihaugen and from 2001 he has been the director of the Norwegian Museum of Cultural History.\n\nIn 2010 he was decorated with the Royal Norwegian Order of St. Olav.\nBrian O’ Malley is an Irish film director known for the horror film" Let Us Prey" and the ghost story" The Lodgers".\nBrian Patrick Kennedy( born 5 November 1961) is an Irish- born art museum director who has worked in Ireland and Australia, and now lives and works in the United States.\n\nHe is currently the director of the Peabody Essex Museum.\n\nHe was the director of the Toledo Museum of Art in Ohio from 2010 to 2019.\n\nHe was the director of the Hood Museum of Art from 2005 to 2010, and the National Gallery of Australia( Canberra) from 1997- 2004.

<|assistant|>
Directors Across Borders: A Comparative Study of International Film and Museum Directors, from Luciano Salce to Brain Patrick Kennedy

<|user|>
Generate a title from the given text.
Context:
A token is a collection of characters that has semantic meaning for a model. Tokenization is the process of converting the words in your prompt into tokens.
You can monitor foundation model token usage in a project on the Environments page on the Resource usage tab.
Converting words to tokens and back again
Prompt text is converted to tokens before the prompt is processed by foundation models.
The correlation between words and tokens is complex:
Sometimes a single word is broken into multiple tokens
The same word might be broken into a different number of tokens, depending on context (such as: where the word appears, or surrounding words)
Spaces, newline characters, and punctuation are sometimes included in tokens and sometimes not
The way words are broken into tokens varies from language to language
The way words are broken into tokens varies from model to model
For a rough idea, a sentence that has 10 words might be 15 to 20 tokens.
The raw output from a model is also tokens. In the Prompt Lab in IBM watsonx.ai, the output tokens from the model are converted to words to be displayed in the prompt editor.

<|assistant|>

コード生成と変換

プログラマチック・コードを生成および変換できる基盤モデルは、開発者向けの優れたリソースです。 開発者のブレインストーミングやプログラミング・タスクのトラブルシューティングに役立つ。

サンプル命令からプログラムコードを生成する

シナリオ命令からコードを生成したい。 つまり、Pythonプログラミング言語で、文字列を反転させる関数を書きたいとします。

モデル選択

codestral-22b、 codestral-2501、 mistral-large、 mixtral-8x7b-instruct-v01 などのコード生成が可能なモデルは、サンプルプロンプトが提供されていれば、通常この作業を完了することができます。

モデル パラメータ

  • デコードGreedy に設定する。 答えは有効なコード・スニペットでなければならない。 モデルは創造性を発揮して答えを作ることはできない。
  • 停止基準 :コードスニペットを1つ返した後にモデルを停止するには、 <end of code> を停止シーケンスとして指定します。 Max tokensパラメータは1,000に設定できます。

プロンプト・テキスト

このコードスニペットを Prompt Labのフリーフォームプロンプトエディタに貼り付け、モデルを選択し、パラメータを設定し、 Generateをクリックすると結果が表示されます。

Using the directions below, generate Python code for the specified task.

Input:
# Write a Python function that prints 'Hello World!' string 'n' times.

Output:
def print_n_times(n):
    for i in range(n):
        print("Hello World!")

<end of code>

Input:
# Write a Python function that reverses the order of letters in a string.
# The function named 'reversed' takes the argument 'my_string', which is a string. It returns the string in reverse order.

Output:

出力にはPythonのコードが含まれる:

def reversed(my_string):
    return my_string[::-1]

生成されたコードが期待通りに動くかどうか、必ずテストしてください。

例えば、reversed("good morning")を実行すると、結果は'gninrom doog'となります。

注: 基盤モデルモデルは、学習データから直接コードを生成する可能性があります。 その結果、生成されたコードには帰属表示が必要になるかもしれない。 あなたは、必要であれば、あなたが使用する生成されたコードが適切に帰属することを保証する責任があります。

サンプルゼロ・ショット・プロンプトによる命令からプログラム・コードを生成する

シナリオ命令からコードを生成したい。 つまり、Pythonプログラミング言語で、'Hello World!'を表示する関数を書きたい 文字列を'n'回入力する。

モデル選択

llama-3-2-1b-instruct または llama-3-2-3b-instruct 基盤モデル使用する場合、例を示す必要はありません。 環境値'iphythonを指定するカスタムテンプレートを使用する必要があります。

モデル パラメータ

  • デコードGreedy に設定する。 答えは有効なコード・スニペットでなければならない。 モデルは創造性を発揮して答えを作ることはできない。
  • 停止基準 :モデルには停止シーケンスは必要ない。

プロンプト・テキスト

このコードスニペットを Prompt Labのフリーフォームプロンプトエディタに貼り付け、モデルを選択し、パラメータを設定し、 Generateをクリックすると結果が表示されます。

<|begin_of_text|><|start_header_id|>system<|end_header_id|>

Environment: ipython<|eot_id|><|start_header_id|>user<|end_header_id|>

${Add your code instruction here}<|eot_id|><|start_header_id|>assistant<|end_header_id|>

${Add your code instruction here}は、モデルに生成させたいコードの記述に置き換えてください。 例えば、Write a Python function that prints 'Hello World!' string 'n' times.です。

モデルは次のような出力を生成する:

Here is a simple Python function that prints 'Hello World!' 'n' times:

```python
def print_hello_world(n):
    for i in range(n):
        print('Hello World!')

print_hello_world(5)

この関数はforループを使って'n'回繰り返し、'Hello World!'と表示する その都度。 range(n)関数は0からn-1'までの数列を生成し、それをループ変数'i'として使用する。

サンプルあるプログラミング言語から別のプログラミング言語へのコード変換

シナリオあるプログラミング言語から別のプログラミング言語にコードを変換したい。 つまり、あるコード・スニペットをC++からPythonに変換したいとします。

モデル選択

codellama-34b-instruct-hf、mistral-large、mixtral-8x7b-instruct-v01のようなコードを生成できるモデルは、サンプルプロンプトが提供されれば、一般的にこのタスクを完了できる。

モデル パラメータ

  • デコードGreedy に設定する。 答えは有効なコード・スニペットでなければならない。 モデルは創造性を発揮して答えを作ることはできない。
  • 停止基準 :コードスニペットを1つ返した後にモデルを停止するには、 <end of code> を停止シーケンスとして指定します。 最大トークンパラメータは 300 に設定できます。

プロンプト・テキスト

このコードスニペットを Prompt Labのフリーフォームプロンプトエディタに貼り付け、モデルを選択し、パラメータを設定し、 Generateをクリックすると結果が表示されます。

このプロンプトには、入力と出力のペアの例が含まれている。 入力はC++のコードで、出力はPythonのコードに相当する関数です。

変換するC++のコード・スニペットを次に示す。 これは、和Sと公差Dを持つ等差数列の数を数える関数で、SDはパラメータとして渡される整数値である。

プロンプトの最後の部分では、C++コード・スニペットを変換する言語を指定する。

Translate the following code from C++ to Python.

C++:
#include "bits/stdc++.h"
using namespace std;
bool isPerfectSquare(long double x) {
    long double sr = sqrt(x);
    return ((sr - floor(sr)) == 0);
}
void checkSunnyNumber(int N) {
    if (isPerfectSquare(N + 1)) {
    cout << "Yes
";
    } else {
    cout << "No
";
    }
}
int main() {
    int N = 8;
    checkSunnyNumber(N);
    return 0;
}

Python:
from math import *
 
def isPerfectSquare(x):
    sr = sqrt(x)
    return ((sr - floor(sr)) == 0)
 
def checkSunnyNumber(N):
    if (isPerfectSquare(N + 1)):
        print("Yes")
    else:
        print("No")
 
if __name__ == '__main__':
    N = 8
    checkSunnyNumber(N)

<end of code>

C++:
#include <bits/stdc++.h>
using namespace std;
int countAPs(int S, int D) {
    S = S * 2;
    int answer = 0;
    for (int i = 1; i <= sqrt(S); i++) {
    if (S % i == 0) {
      if (((S / i) - D * i + D) % 2 == 0)
        answer++;
      if ((D * i - (S / i) + D) % 2 == 0)
        answer++;
    }
    }
    return answer;
}
int main() {
    int S = 12, D = 1;
    cout << countAPs(S, D);
    return 0;
}

Python:

出力にはPythonのコードが含まれる:

from math import *
 
def countAPs(S, D):
    S = S * 2
    answer = 0
    for i in range(1, int(sqrt(S)) + 1):
        if S % i == 0:
            if (((S / i) - D * i + D) % 2 == 0):
                answer += 1
            if ((D * i - (S / i) + D) % 2 == 0):
                answer += 1
    return answer
 
if __name__ == '__main__':
    S = 12
    D = 1
    print(countAPs(S, D))

<end of code>

生成されたPythonコードは、プロンプトに含まれるC++コードと同じように機能する。

生成されたPythonコードをテストして、期待通りに動作することを確認してください。

注: 基盤モデルモデルは、学習データから直接コードを生成する可能性があります。 その結果、生成されたコードには帰属表示が必要になるかもしれない。 あなたは、必要であれば、あなたが使用する生成されたコードが適切に帰属することを保証する責任があります。

サンプルGraniteで命令からプログラムコードを生成する

シナリオ命令からコードを生成したい。 つまり、Pythonプログラミング言語で、文字列を反転させる関数を書きたいとします。

モデル選択

GraniteCodeやGraniteInstructモデルなど、コードを生成できるモデルは、サンプルプロンプトが提供されると、通常このタスクを完了することができます。

モデル パラメータ

  • デコードGreedy に設定する。 答えは有効なコード・スニペットでなければならない。 モデルは創造性を発揮して答えを作ることはできない。
  • 停止基準 :コードスニペットを1つ返した後にモデルを停止するには、 <end of code> を停止シーケンスとして指定します。 Max tokensパラメータは300に設定できる。

プロンプト・テキスト

このコードスニペットを Prompt Labのフリーフォームプロンプトエディタに貼り付け、モデルを選択し、パラメータを設定し、 Generateをクリックすると結果が表示されます。

Question:
Using the directions below, generate Python code for the specified task.
# Write a Python function that prints 'Hello World!' string 'n' times.

Answer:
def print_n_times(n):
    for i in range(n):
        print("Hello World!")

<end of code>

Question:
# Write a Python function that reverses the order of letters in a string.
# The function named 'reversed' takes the argument 'my_string', which is a string. It returns the string in reverse order.

Answer:

出力にはPythonのコードが含まれる:

def reverse_string(my_string):
    return my_string[::-1]

<end of code>

生成されたコードが期待通りに動くかどうか、必ずテストしてください。

例えば、reversed("good morning")を実行すると、結果は'gninrom doog'となります。

その他のGraniteコードモデルサンプルプロンプトについては、コードのプロンプトを参照してください。

サンプルGraniteを使ってコードをあるプログラミング言語から別のプログラミング言語に変換する

シナリオあるプログラミング言語から別のプログラミング言語にコードを変換したい。 つまり、あるコード・スニペットをC++からPythonに変換したいとします。

モデル選択

GraniteCode Instructモデルのようにコードを生成できるモデルは、サンプルプロンプトが提供されれば、通常このタスクを完了できる。

モデル パラメータ

  • デコードGreedy に設定する。 答えは有効なコード・スニペットでなければならない。 モデルは創造性を発揮して答えを作ることはできない。
  • 停止基準 :コードスニペットを1つ返した後にモデルを停止するには、 <end of code> を停止シーケンスとして指定します。 Max tokensパラメータは1,000に設定できます。

プロンプト・テキスト

このコードスニペットを Prompt Labのフリーフォームプロンプトエディタに貼り付け、モデルを選択し、パラメータを設定し、 Generateをクリックすると結果が表示されます。

このプロンプトには、コード・スニペットをC++からPythonに変換する命令が含まれています。

コンテキストを提供するために、変換するC++のコード・スニペットを次に示す。 これは、和Sと公差Dを持つ等差数列の数を数える関数で、SDはパラメータとして渡される整数値である。

Question:
Translate the following code from C++ to Python.
C++:
#include "bits/stdc++.h"
using namespace std;
bool isPerfectSquare(long double x) {
    long double sr = sqrt(x);
    return ((sr - floor(sr)) == 0);
}
void checkSunnyNumber(int N) {
    if (isPerfectSquare(N + 1)) {
    cout << "Yes
";
    } else {
    cout << "No
";
    }
}
int main() {
    int N = 8;
    checkSunnyNumber(N);
    return 0;
}

Answer:
Python:
from math import *
 
def isPerfectSquare(x):
    sr = sqrt(x)
    return ((sr - floor(sr)) == 0)
 
def checkSunnyNumber(N):
    if (isPerfectSquare(N + 1)):
        print("Yes")
    else:
        print("No")
 
if __name__ == '__main__':
    N = 8
    checkSunnyNumber(N)

<end of code>

Question:
Translate the following code from C++ to Python.
C++:
#include <bits/stdc++.h>
using namespace std;
int countAPs(int S, int D) {
    S = S * 2;
    int answer = 0;
    for (int i = 1; i <= sqrt(S); i++) {
    if (S % i == 0) {
      if (((S / i) - D * i + D) % 2 == 0)
        answer++;
      if ((D * i - (S / i) + D) % 2 == 0)
        answer++;
    }
    }
    return answer;
}
int main() {
    int S = 12, D = 1;
    cout << countAPs(S, D);
    return 0;
}

Answer:

出力にはPythonのコードが含まれる:

Python:
from math import *
 
def countAPs(S, D):
    S = S * 2
    answer = 0
    for i in range(1, int(sqrt(S)) + 1):
        if S % i == 0:
            if ((S // i) - D * i + D) % 2 == 0:
                answer += 1
            if (D * i - (S // i) + D) % 2 == 0:
                answer += 1
    return answer
 
if __name__ == '__main__':
    S = 12
    D = 1
    print(countAPs(S, D))

生成されたPythonコードは、プロンプトに含まれるC++コードと同じように機能する。

生成されたPythonコードをテストして、期待通りに動作することを確認してください。

その他のGraniteコードモデルサンプルプロンプトについては、コードのプロンプトを参照してください。

サンプル:SQLで情報源を検索する

シナリオ:SQLで定義されたテーブルのセットが与えられた場合、質問に対する答えを確認するテーブルのカラムを特定する必要があります。

モデル選択

granite-20b-code-base-schema-linking、 基盤モデル SQLを読み、探している情報がどこにあるかを特定する。

モデル パラメータ

  • デコードGreedy に設定する。 モデルは創造性を発揮して答えを作ることはできない。

プロンプト・テキスト

このコードスニペットを Prompt Labのフリーフォームプロンプトエディタに貼り付け、モデルを選択し、パラメータを設定し、 Generateをクリックすると結果が表示されます。

このプロンプトには、SQLで定義されたテーブルが含まれており、クエリの回答を見つけるためにSQLのどの部分を参照すべきかを特定するようモデルに要求します。

Consider:
Which gas station has the highest amount of revenue?

CREATE TABLE customers (
 customerid PRIMARY KEY, -- identification of the customer
 segment, -- client segment
 currency, -- Currency
);

CREATE TABLE gasstations (
 gasstationid PRIMARY KEY, -- Gas Station ID
 chainid, -- Chain ID
 country,
 segment, -- chain segment
);

CREATE TABLE products (
 productid PRIMARY KEY, -- Product ID
 description, -- Description
);

CREATE TABLE transactions_1k (
 transactionid PRIMARY KEY, -- Transaction ID
 date, -- Date\\n time, -- Time
 customerid, -- Customer ID
 cardid, -- Card ID
 gasstationid, -- Gas Station ID
 productid, -- Product ID
 amount, -- Amount
 price, -- Price
);

CREATE TABLE yearmonth (
 customerid, -- Customer ID
 date, -- Date\\n consumption, -- consumption
 FOREIGN KEY(customerid) REFERENCES customers(customerid)
);

To answer:
Which gas station has the highest amount of revenue?
We need columns:

回答は、質問に最も答えられる可能性が高い内容の列を特定し、次のような表示になる場合があります

gasstations.gasstationid, gasstations.country, transactions_1k.gasstationid, transactions_1k.amount

サンプル:SQL文を生成する

シナリオ:SQLテーブルが与えられた場合、そのテーブルから情報を抽出してクエリに回答するSQLステートメントを生成する。

モデル選択

granite-20b-code-base-sql-gen 基盤モデル、質問に答えるために使える SQL 文を生成する。

モデル パラメータ

  • デコードGreedy に設定する。 モデルは創造性を発揮して答えを作ることはできない。

プロンプト・テキスト

このコードスニペットを Prompt Labのフリーフォームプロンプトエディタに貼り付け、モデルを選択し、パラメータを設定し、 Generateをクリックすると結果が表示されます。

このプロンプトには、SQLで定義されたテーブルが含まれており、そのテーブルからクエリの回答を見つけることができるSQLステートメントを生成するようにモデルに要求します。

Note:
the youngest user refers to MIN(Age)

What is the id of the youngest user?

CREATE TABLE users (
 id INTEGER PRIMARY KEY, -- the user id
 displayname TEXT, -- the user\'s display name
 age INTEGER, -- user\'s age
 );
 
 users.id
 users.displayname: \'   Raid-Mahbouba\', \'0 kelvin\', \'0012\'
 users.age: 13, 68, 73
 
 selected: users.id, users.age, None, users.displayname
 join: None, users.id
 condition: users.age, None, users.id
 order: users.age, None
 group: None, users.id, users.age
 
Comparisons: None

Note:
the youngest user refers to MIN(Age)

What is the id of the youngest user?
Generate SQL:


答えは、次のようなSQLステートメントです

SELECT id FROM users ORDER BY age ASC LIMIT 1

ダイアログ

対話タスクはカスタマーサービスシナリオで有用であり、特にチャットボットがワークフローを通じて顧客をゴールに導くために使用される場合に役立ちます。

サンプルLlama 3との会話

シナリオチャットボットのようなダイアログ出力を生成する。

モデル選択

Llama 3、 3.1、 3.2、 3.3 は、ダイアログのユースケースに最適化されています。 モデルは、 プロンプトテキストのセクションで説明されている特定のプロンプト形式に合わせて微調整されます。

モデル パラメータ

  • デコードGreedy に設定する。 このサンプルは一般常識や事実に基づいた質問に答えるものなので、クリエイティブなアウトプットは求めていません。
  • 停止基準Max tokensパラメータを900に設定する。

このテンプレートは、システムプロンプトを除く各テキストセグメントの終わりを区切るために、テキスト終了トークン(<|eot_id|>)を使用します。

プロンプト・テキスト

入力には以下のプロンプトテンプレートが最適です:

<|begin_of_text|><|start_header_id|>system<|end_header_id|>

SYSTEM PROMPT<|eot_id|><|start_header_id|>user<|end_header_id|>

GROUNDING (OPTIONAL)<|eot_id|><|start_header_id|>user<|end_header_id|>

USER_INPUT<|eot_id|><|start_header_id|>assistant<|end_header_id|>

このプロンプトテキストを Prompt Labのフリーフォームプロンプトエディタに貼り付け、モデルを選択し、パラメータを設定し、 Generateをクリックすると結果が表示されます。

ヒント:また、チャットモードに切り替えて、ユーザー入力を直接入力することもできます。 Prompt Labは、命令セグメントとユーザー入力セグメントを識別する構文を挿入します。
<|begin_of_text|><|start_header_id|>system<|end_header_id|>

You are a helpful assistant that avoids causing harm. When you do not know the answer to a question, you say "I don't know".<|eot_id|><|start_header_id|>user<|end_header_id|>

I have a question about Earth. How many moons are there?<|eot_id|><|start_header_id|>assistant<|end_header_id|>

最初の出力が生成された後、ダイアログを続けてより多くの惑星について尋ね、例えば入力テキストの最後に同じ識別子を追加する:

FOLLOW UP QUESTION<|eot_id|><|start_header_id|>assistant<|end_header_id|>


出力は次のようになる:

<|begin_of_text|><|start_header_id|>system<|end_header_id|>

You are a helpful assistant that avoids causing harm. When you do not know the answer to a question, you say "I don't know".<|eot_id|><|start_header_id|>user<|end_header_id|>

I have a question about Earth. How many moons are there?<|eot_id|><|start_header_id|>assistant<|end_header_id|>

That's an easy one! Earth has only one moon.

What about Saturn?<|eot_id|><|start_header_id|>assistant<|end_header_id|>

Saturn has a whopping 82 confirmed moons!

And Mars?<|eot_id|><|start_header_id|>assistant<|end_header_id|>

Mars has two small natural satellites, Phobos and Deimos.

以下のプロンプトのサンプルには、接地情報が含まれています。

<|begin_of_text|><|start_header_id|>system<|end_header_id|>

You are a helpful assistant that avoids causing harm. When you do not know the answer to a question, you say "I don't know".<|eot_id|><|start_header_id|>user<|end_header_id|>

The sky is blue.<|eot_id|><|start_header_id|>user<|end_header_id|>

What color is the sky?<|eot_id|><|start_header_id|>assistant<|end_header_id|>

サンプルLlama 2」と会話する

シナリオチャットボットのようなダイアログ出力を生成する。

モデル選択

他のファンデーションモデルと同様、Llama 2(700億サイズと130億サイズの両方)は複数のタスクに使用できる。 しかし、Llama 2の両モデルは、ダイアログのユースケースに最適化されている。 llama-2-70b-chatと llama-2-13b-chatは'[INST]<<SYS>><</SYS>>[/INST]プロンプトフォーマット用に微調整されている。 このプロンプトのフォーマットについての詳細は、 Llama 2のプロンプトの出し方を参照のこと。

モデル パラメータ

  • デコードGreedy に設定する。 このサンプルは一般常識や事実に基づいた質問に答えるものなので、クリエイティブなアウトプットは求めていません。
  • 停止基準Max tokensパラメータを100に設定します。

Llama 2のテンプレートは、文字列終了(EOS)トークン(</s>)を使用して、エージェントの応答の終わりを区切ります。 </s>EOSトークンに遭遇すると、モデル出力はテキスト生成を停止する。

プロンプト・テキスト

このプロンプトテキストを Prompt Labのフリーフォームプロンプトエディタに貼り付け、モデルを選択し、パラメータを設定し、 Generateをクリックすると結果が表示されます。

[INST] <<SYS>>
You are a helpful assistant. Begin each response with the phrase "Dear user, ". If you are unsure about an answer, truthfully say "I don't know"<</SYS>>

I have a question about the Earth.[/INST]
Dear user, go on.
[INST]

How many moons are there?
[/INST]

最初の出力が生成された後、ダイアログを続けて、同じ「[INST][/INST]構造でユーザーメッセージをラップして、さらに惑星について質問する。 フォローアップ質問の最初に'<s>トークンを追加する必要はありません。

ヒント:また、チャットモードに切り替えて、ユーザー入力を直接入力することもできます。 Prompt Labは、命令セグメントとユーザー入力セグメントを識別する構文を挿入します。

出力は次のようになる:

[INST] <<SYS>>
You are a helpful assistant. Begin each response with the phrase "Dear user, ". If you are unsure about an answer, truthfully say "I don't know"<</SYS>>

I have a question about the Earth.[/INST]
Dear user, go on.
[INST]

How many moons are there?
[/INST]
Dear user, the Earth has one natural satellite, commonly referred to as the Moon. 
[INST]

What about Saturn?
[/INST]
Dear user, Saturn has a total of 62 confirmed moons, as well as numerous smaller moonlets and ring particles. The largest moon of Saturn is Titan, which is the second-largest moon in the solar system, after Jupiter's moon Ganymede. 
[INST]

And Mars?
[/INST]
Dear user, Mars has two small natural satellites, Phobos and Deimos. Both moons are thought to be captured asteroids, and are irregularly shaped and very small, with diameters of about 22 kilometers and 12 kilometers respectively.

モデルが生成する出力について、いくつかの重要な点に注意してください:

  • <<SYS>><</SYS>>タグにあるいわゆるシステム命令は、システム命令を繰り返すことなく、各ダイアログターンの出力に影響を与え続ける。 言い換えれば、アシスタントの応答は"Dear user, "で始まる。
  • 真のダイアログファッションでは、"月はいくつありますか?"というユーザー入力に対するアシスタントの応答がある は、前のユーザー入力 "地球について質問があります "を考慮する で、地球を周回する月の数を返す。
  • また、適切なダイアログ形式では、アシスタントの応答は会話の話題(月の数)に沿って続く。 (そうでなければ、"And Mars? "という曖昧なユーザーメッセージが出力される) どの方向へもふらふらする可能性がある)
  • 注意:注意:プロンプト・テキスト中の改行文字(キャリッジ・リターン)は特に、また空白文字はそれほどではないが、生成される出力に劇的な影響を与える可能性がある。
  • チャットのユースケースにLlama 2を使用する場合、推奨されるプロンプトテンプレートのフォーマットにできるだけ忠実に従います。 チャット以外にLlama 2を使用する場合は、'[INST]<<SYS>><</SYS>>[/INST]プロンプトフォーマットを使用しないでください。

サンプル:granite-13b-chat-v2とコンバース

シナリオチャットボットのようなダイアログ出力を生成する。

モデル選択

対話を続けるにはgranite-13b-chat-v2を使う。

モデル パラメータ

  • 解読:
    • サンプリングデコーディングを使用する。
    • Top Pを0.85に設定する。
    • 繰り返しのペナルティを1.2に設定する。
  • 停止基準 :モデルが完全な回答を返せるように、かつできるだけ簡潔になるように 、Max tokensパラメータを500に設定します。

プロンプト・テキスト

モデルの安全性を高め、バイアスを減らすために、ユーザー入力の一部としてシステムプロンプトを追加する。 システムプロンプトは、ダイアログの基本ルールを確立することができる。 例:

あなたはGraniteチャット、IBMが開発したAI言語モデルです。 あなたは慎重なアシスタントだ。 あなたは注意深く指示に従う。 あなたは親切で無害であり、倫理的なガイドラインに従い、前向きな行動を促進する。 回答は簡潔に要点を絞って。

モデルが期待するプロンプト・テンプレート・フォーマットを使用することを忘れないでください。

<|system|>
システムのプロンプト
<|user|>
質問の内容
<|assistant|>
モデルの回答用の新しい行

このモデルに数発のプロンプトを送信したい場合は、システムプロンプトを追加し、次に例を追加し、その後に推論するプロンプトテキストを追加する。

<|system|>
You are Granite Chat, an AI language model developed by IBM. You are a cautious assistant. You carefully follow instructions. You are helpful and harmless and you follow ethical guidelines and promote positive behavior. Keep your answers short and to the point.
<|user|>
Example prompt 1
<|assistant|>
Example response 1

<|user|>
Example prompt 2
<|assistant|>
Example response 2

<|user|>
USER INPUT
<|assistant|>

Prompt Labのフリーフォームプロンプトエディタに以下のプロンプトテキストを貼り付け、モデルを選択してパラメータを設定し、 Generateをクリックして結果を確認します。

ヒント:また、チャットモードに切り替えて、ユーザー入力を直接入力することもできます。 Prompt Labは、命令セグメントとユーザー入力セグメントを識別する構文を挿入します。
<|system|>
You are Granite Chat, an AI language model developed by IBM. You are a cautious assistant. You carefully follow instructions. You are helpful and harmless and you follow ethical guidelines and promote positive behavior. Keep your answers short and to the point.
<|user|>
I have a question about the Earth. How many moons are there?
<|assistant|>

<|assistant|>ラベルの後ろには空白を入れず、必ず改行してください。

最初の出力が生成された後、フォローアップの質問をしてダイアログを続けることができる。 例えば、他の惑星の衛星について尋ねることができる。

<|user|>
What about Saturn?

<|assistant|>

そして、別のフォローアップの質問で会話を続ける。

<|user|>
And Mars?

<|assistant|>

モデル出力が長すぎる場合は、ストップシーケンステキストボックスをクリックし、Enterキーを2回押した後、シーケンス追加をクリックして、改行2文字のストップシーケンスを指定してみてください。 しかし、反復ペナルティはモデルを軌道に乗せるのに十分である。

もう一つの例を挙げてみよう:

<|system|>
You are Granite Chat, an AI language model developed by IBM. You are a cautious assistant. You carefully follow instructions. You are helpful and harmless and you follow ethical guidelines and promote positive behavior. Keep your answers short and to the point.
<|user|>
How does a bill become a law?
<|assistant|>

という質問をした:

<|user|>
How about in Canada?

<|assistant|>

このサンプルをモデルで使用する際の注意点:

  • システム・プロンプトは、モデルの一般的なガードレールを設定する。
  • アシスタントは、同じダイアログ内の以前のやり取りからの情報に依存するフォローアップの質問に答えることができます。
  • このモデルは、入力が特定のパターンに従うことを期待しており、空白の入れ間違いに敏感である。

サンプルgranite-8b-japaneseと日本語で会話する

シナリオチャットボットのように日本語のダイアログを出力する。

モデル選択

granite-8b-japanese 基盤モデル 日本語で対話に参加することができる。 granite-8b-japanese 基盤モデル、モデルのトレーニング時に使用されたものと同じプロンプト形式を使用すると、最も効果的に機能します。

モデル パラメータ

  • デコードGreedy に設定する。 このサンプルは一般常識や事実に基づいた質問に答えるものなので、クリエイティブなアウトプットは求めていません。
  • 停止基準 :ダイアログで多くのターンを可能にするために 、Max tokensパラメータを500に設定します。 基盤モデル過度に長い応答を返すのを防ぐために、2つの改行文字からなる停止シーケンスを追加する。 これを実行するには、 [停止] シーケンスのテキストボックスをクリックし、Enterキーを2回押し、 [シーケンスの追加] をクリックします。

プロンプト・テキスト

このプロンプトテキストを Prompt Labのフリーフォームプロンプトエディタに貼り付け、モデルを選択し、パラメータを設定し、 Generateをクリックすると結果が表示されます。

このテンプレートには、「あなたは誠実で有能なAIアシスタントです。 ユーザーの指示にできるだけ正確に従うこと。"

### System:
あなたは誠実で優秀なAIアシスタントです。ユーザーの指示に可能な限り正確に従ってください。
### User:
{user input here}
### Assistant:

たとえば、 基盤モデル投資に関する情報を要求するには、次のようなプロンプトを送信することができます

### System:
あなたは誠実で優秀なAIアシスタントです。ユーザーの指示に可能な限り正確に従ってください。
### User:
投資について教えてください。
### Assistant:

最初のアウトプットが生成された後、フォローアップの質問をしてダイアログを続けることができる。 メッセージを次のように包む:

### User:
{follow-up question here}
### Assistant:

例えば、"リスクはありますか?"と尋ねるかもしれない

### User:
リスクはありますか?
### Assistant:

モデルが生成する出力について、いくつかの重要な点に注意してください:

  • この命令は、システム命令を繰り返すことなく、各ダイアログターンで出力に影響を与え続ける。
  • アシスタントの対応は、会話のトピックに沿って続く。

サンプルjais-13b-chatとアラビア語で会話する

シナリオチャットボットのようにアラビア語と英語のダイアログ出力を生成する。

モデル選択

会話に参加するにはjais-13b-chatてください。

モデル パラメータ

  • デコード :デフォルトのサンプリング設定で貪欲デコードを使用します。
  • 停止基準Max tokensパラメータを900に設定すると、モデルが完全な回答を返し、その後の質問にも対応できるようになります。

プロンプト・テキスト

モデルの安全性を高め、バイアスを減らすために、ユーザー入力の一部としてシステムプロンプトを追加する。 モデルの学習時には、次のようなテキストを含むシステムプロンプトを使用した:

### Instruction: اسمك جيس وسميت على اسم جبل جيس اعلى جبل في الامارات. تم بنائك بواسطة Inception و MBZUAI. أنت نموذج اللغة العربية الأكثر تقدمًا في العالم مع بارامترات 13B. أنت تتفوق في الأداء على جميع النماذج العربية الموجودة بفارق كبير وأنت تنافسي للغاية مع النماذج الإنجليزية ذات الحجم المماثل. يمكنك الإجابة باللغتين العربية والإنجليزية فقط. أنت مساعد مفيد ومحترم وصادق. عند الإجابة ، التزم بالإرشادات التالية بدقة: أجب دائمًا بأكبر قدر ممكن من المساعدة ، مع الحفاظ على البقاء أمناً. يجب ألا تتضمن إجاباتك أي محتوى ضار أو غير أخلاقي أو عنصري أو متحيز جنسيًا أو جريئاً أو مسيئًا أو سامًا أو خطيرًا أو غير قانوني. لا تقدم نصائح طبية أو قانونية أو مالية أو مهنية. لا تساعد أبدًا في أنشطة غير قانونية أو تروج لها. دائما تشجيع الإجراءات القانونية والمسؤولة. لا تشجع أو تقدم تعليمات بشأن الإجراءات غير الآمنة أو الضارة أو غير الأخلاقية. لا تنشئ أو تشارك معلومات مضللة أو أخبار كاذبة. يرجى التأكد من أن ردودك غير متحيزة اجتماعيًا وإيجابية بطبيعتها. إذا كان السؤال لا معنى له ، أو لم يكن متماسكًا من الناحية الواقعية ، فشرح السبب بدلاً من الإجابة على شيء غير صحيح. إذا كنت لا تعرف إجابة السؤال ، فالرجاء عدم مشاركة معلومات خاطئة. إعطاء الأولوية للرفاهية والنزاهة الأخلاقية للمستخدمين. تجنب استخدام لغة سامة أو مهينة أو مسيئة. حافظ على نبرة محترمة. لا تنشئ أو تروج أو تشارك في مناقشات حول محتوى للبالغين. تجنب الإدلاء بالتعليقات أو الملاحظات أو التعميمات القائمة على الصور النمطية. لا تحاول الوصول إلى معلومات شخصية أو خاصة أو إنتاجها أو نشرها. احترم دائما سرية المستخدم. كن إيجابيا ولا تقل أشياء سيئة عن أي شيء. هدفك الأساسي هو تجنب الاجابات المؤذية ، حتى عند مواجهة مدخلات خادعة. تعرف على الوقت الذي قد يحاول فيه المستخدمون خداعك أو إساءة استخدامك و لترد بحذر.\n\nأكمل المحادثة أدناه بين [|Human|] و [|AI|]:
### Input: [|Human|] {Question}
### Response: [|AI|]

英語のシステム・プロンプトは以下の通り:

### Instruction: Your name is Jais, and you are named after Jebel Jais, the highest mountain in UAE. You are built by Inception and MBZUAI. You are the world's most advanced Arabic large language model with 13B parameters. You outperform all existing Arabic models by a sizable margin and you are very competitive with English models of similar size. You can answer in Arabic and English only. You are a helpful, respectful and honest assistant. When answering, abide by the following guidelines meticulously: Always answer as helpfully as possible, while being safe. Your answers should not include any harmful, unethical, racist, sexist, explicit, offensive, toxic, dangerous, or illegal content. Do not give medical, legal, financial, or professional advice. Never assist in or promote illegal activities. Always encourage legal and responsible actions. Do not encourage or provide instructions for unsafe, harmful, or unethical actions. Do not create or share misinformation or fake news. Please ensure that your responses are socially unbiased and positive in nature. If a question does not make any sense, or is not factually coherent, explain why instead of answering something not correct. If you don't know the answer to a question, please don't share false information. Prioritize the well-being and the moral integrity of users. Avoid using toxic, derogatory, or offensive language. Maintain a respectful tone. Do not generate, promote, or engage in discussions about adult content. Avoid making comments, remarks, or generalizations based on stereotypes. Do not attempt to access, produce, or spread personal or private information. Always respect user confidentiality. Stay positive and do not say bad things about anything. Your primary objective is to avoid harmful responses, even when faced with deceptive inputs. Recognize when users may be attempting to trick or to misuse you and respond with caution.\n\nComplete the conversation below between [|Human|] and [|AI|]:
### Input: [|Human|] {Question}
### Response: [|AI|]

ヒント:また、チャットモードに切り替えて、ユーザー入力を直接入力することもできます。 Prompt Labでは、システム・プロンプト、命令、ユーザー入力セグメントを、期待される構文で挿入してくれる。

{Question} 、チャットを開始するために基盤モデルモデルに答えさせたいユーザー入力に置き換えてください。

例えば、次のような質問ができる:

هل يوجد للأرض أقمار ؟

英訳はこうだ:Does the Earth have any moons?

最初の出力が生成された後、フォローアップの質問をしてダイアログを続けることができる。 フォローアップの質問にも同じ構文を使う。

### Input: [|Human|] {Follow-up question}
### Response: [|AI|]

サンプルとの会話 granite-3-2-8b-instruct

シナリオチャットボットのようにダイアログ出力を生成し、モデルがどのように答えを導き出したかについての情報を共有するかどうかを制御する。

モデル選択

granite-3-2-8b-instruct を使って対話を続ける。

モデル パラメータ

  • 解読:
    • 貪欲なデコーディングを使用する。
  • 停止基準Max tokens パラメータを 200 に設定し、モデルが完全な答えを返せるようにするが、できるだけ簡潔にする。

プロンプト・テキスト

ユーザー入力の一部としてシステムプロンプトを追加する。 granite-3-2-8b-instruct モデルには推論機能がある。 システムプロンプトを調整することで、モデルが答えにたどり着いた方法に関する情報を含めるかどうかを制御できます。

答えを導き出すために使用された思考プロセスに関する情報なしで回答を生成するには、このシステムプロンプトを使用します:

あなたは Granite IBM によって開発されたAI言語モデルです。 あなたは慎重なアシスタントだ。 あなたは注意深く指示に従う。 あなたは親切で無害であり、倫理的なガイドラインに従い、前向きな行動を促進する。

回答に至った思考プロセスに関する情報を含む回答を生成するには、このシステム・プロンプトを使用します:

あなたは Granite IBM によって開発されたAI言語モデルです。 あなたは慎重なアシスタントだ。 あなたは注意深く指示に従う。 あなたは親切で無害であり、倫理的なガイドラインに従い、前向きな行動を促進する。 アウトプットの思考プロセスを共有する

モデルが期待するプロンプト・テンプレート・フォーマットを使用することを忘れないでください。

<|system|>
システムのプロンプト
<|user|>
質問の内容
<|assistant|>
モデルの回答用の新しい行

Prompt Labのフリーフォームプロンプトエディタに以下のプロンプトテキストを貼り付け、モデルを選択してパラメータを設定し、 Generateをクリックして結果を確認します。

<|system|>
<|start_of_role|>system<|end_of_role|>${prompt that instructs the model to include or omit reasoning details}<|end_of_text|>
<|start_of_role|>user<|end_of_role|>I have a question about the Earth. How many moons are there?<|end_of_text|>
<|start_of_role|>assistant<|end_of_role|>

最初の出力が生成された後、フォローアップの質問をしてダイアログを続けることができる。 例えば、他の惑星の衛星について尋ねることができる。

<|start_of_role|>user<|end_of_role|>What about Saturn?<|end_of_text|>
<|start_of_role|>assistant<|end_of_role|>

モデルの思考プロセスを問われない場合、答えは次のようになる:

The Earth has one moon, often referred to as Luna or just "the Moon". It's the fifth largest moon in the solar system.
<|start_of_role|>user<|end_of_role|>What about Saturn?<|end_of_text|>
<|start_of_role|>assistant<|end_of_role|>
Saturn has an extensive moon system. As of current knowledge, Saturn is recognized to have 82 confirmed moons. The four largest ones - Titan, Rhea, Iapetus, and Dione - were discovered by Christiaan Huygens and Giovanni Domenico Cassini in the 17th century using their telescopes. The smaller ones were found through spacecraft missions and Earth-based observations in more recent times.

モデルに思考プロセスを含めるよう求めると、答えは次のようになる:

The Earth has one moon. This is a well-known fact in astronomy. The moon, also known as Luna, is the fifth largest moon in the solar system. It's the only natural satellite of Earth.

Thought process: The user asked a straightforward question about the number of moons Earth has. This information is readily available in general knowledge databases. There's no ambiguity or potential for misinterpretation in this question, so I can confidently provide the correct answer.
<|start_of_role|>user<|end_of_role|>What about Saturn?<|end_of_text|>
<|start_of_role|>assistant<|end_of_role|>
Saturn has 82 known moons. This number is subject to change as new discoveries are made. The largest of Saturn's moons is Titan, which is even larger than the planet Mercury.

Thought process: The user has followed up with a question about another planet, Saturn. This is a different topic from the previous question about Earth. Saturn is known for having a large number of moons, so I can provide this accurate information. It's also worth noting that the count of Saturn's moons is not fixed due to ongoing astronomical discoveries, which I've mentioned to provide a complete response.

翻訳

ある自然言語から別の自然言語へテキストを翻訳するために、自然言語翻訳タスクを実行できるモデルを使用する。

サンプルテキストを日本語から英語に翻訳する

シナリオ日本語で書かれた文章を英語に翻訳してください。

モデル選択

elyza-japanese-llama-2-7b-elyza-japanese-llama-2-7b-instructモデルは、日本語から英語、英語から日本語への翻訳ができる。

モデル パラメータ

  • AIガードレール :AIガードレール機能は、コンテンツを不適切として誤ってフラグを付ける可能性があるため、無効にします。 この機能は英語テキストにのみ対応しています。
  • デコードGreedy に設定する。 モデルは同じテキストを翻訳して返さなければならない。 モデルに創造性はない。
  • 停止基準Max tokensパラメータの値を500に変更して、許可トークンの数を増やします。

プロンプト・テキスト

Prompt Labのフリーフォームプロンプトエディタに以下のプロンプトテキストを貼り付け、モデルを選択してパラメータを設定し、 Generateをクリックして結果を確認します。

サンプルのプロンプト・テキストは、サンプル 8cで使われているテキストと重なっています。

英語に翻訳してください」と指示がある。 日本語を英語に翻訳した例もある。

英語に翻訳してください

日本語
トマトは、家庭菜園で最も人気のある植物の 1 つです。成功のヒント: 病気や害虫に強い品種を選択すると、トマトの栽培は非常に簡単になります。挑戦を求めている経験豊富な庭師にとって、栽培できる家宝や特別な品種は無限にあります。トマトの植物にはさまざまなサイズがあります。

English
Tomatoes are one of the most popular plants for vegetable gardens. Tip for success: If you select varieties that are resistant to disease and pests, growing tomatoes can be quite easy. For experienced gardeners looking for a challenge, there are endless heirloom and specialty varieties to cultivate. Tomato plants come in a range of sizes.

日本語
基盤モデルを使用して、より優れた AI をより迅速に作成します。さまざまなユースケースやタスクに応じて、さまざまなプロンプトを試してください。わずか数行の指示で、職務記述書の草案、顧客の苦情の分類、複雑な規制文書の要約、重要なビジネス情報の抽出などを行うことができます。

English

サンプルテキストをスペイン語から英語に翻訳する

シナリオスペイン語で書かれた文章を英語に翻訳してください。

モデル選択

mixtral-8x7b-instruct-v01またはmistral-largeモデルは、フランス語、ドイツ語、イタリア語、スペイン語から英語にテキストを翻訳することができます。 このサンプルは、スペイン語から英語への翻訳をモデルに促します。

モデル パラメータ

  • AIガードレール :AIガードレール機能は、コンテンツを不適切として誤ってフラグを付ける可能性があるため、無効にします。 この機能は英語テキストにのみ対応しています。
  • デコードGreedy に設定する。 モデルは同じテキストを翻訳して返さなければならない。 モデルに創造性はない。
  • 停止基準 :このモデルには必ず停止シーケンスを含めること。 そうでなければ、モデルが新しい文や訳文を生成し続ける可能性がある。 1文の後にモデルを停止するには、停止シーケンスとしてピリオド(.) Max tokensパラメータの値を200に設定します。

プロンプト・テキスト

Prompt Labのフリーフォームプロンプトエディタに以下のプロンプトテキストを貼り付け、モデルを選択してパラメータを設定し、 Generateをクリックして結果を確認します。

Translate the following text from Spanish to English. Do not give any extra response that is not part of the translation.

Text: 
Hasta ahora no me ha animado mucho la postura adoptada por la Comisión.

Translation:
So far, I have not been terribly encouraged by the stance adopted by the Commission.

Text: 
Estoy muy contento de ver que la resolución conjunta adopta la sugerencia que hicimos.

Translation:

サンプルテキストを英語から日本語に翻訳する

シナリオ英語で書かれた文章を日本語に翻訳してください。

モデル選択

granite-8b-japaneseは日本語から英語、英語から日本語への翻訳が可能です。

モデル パラメータ

  • AIガードレール :AIガードレール機能は、コンテンツを不適切として誤ってフラグを付ける可能性があるため、無効にします。 この機能は英語テキストにのみ対応しています。
  • デコードGreedy に設定する。 モデルは同じテキストを翻訳して返さなければならない。 モデルに創造性はない。
  • 停止基準Max tokensパラメータの値を500に変更して、許可トークンの数を増やします。

プロンプト・テキスト

Prompt Labのフリーフォームプロンプトエディタに以下のプロンプトテキストを貼り付け、モデルを選択してパラメータを設定し、 Generateをクリックして結果を確認します。

Translate the following text from English to Japanese.

English
Tomatoes are one of the most popular plants for vegetable gardens. Tip for success: If you select varieties that are resistant to disease and pests, growing tomatoes can be quite easy. For experienced gardeners looking for a challenge, there are endless heirloom and specialty varieties to cultivate. Tomato plants come in a range of sizes.

日本語
トマトは野菜作りの人気の植物である。成功のヒント:病害虫に強く、育てやすいトマトの品種を選べば、トマト栽培はそれほど難しくない。経験豊富な庭師にとっては、手強い挑戦となる、様々な色や形のトマトの品種がある。トマトの品種は、大きさもいろいろである。

English
Use foundation models to create better AI, faster. Experiment with different prompts for various use cases and tasks. With just a few lines of instruction you can draft job descriptions, classify customer complaints, summarize complex regulatory documents, extract key business information and much more.

日本語

サンプルテキストをフランス語から英語に翻訳する

シナリオフランス語で書かれた文章を英語に翻訳してください。

モデル選択

granite-20b-multilingualモデルは、英語、ドイツ語、スペイン語、フランス語、ポルトガル語を理解する。 このサンプルでは、フランス語から英語への翻訳を促します。

モデル パラメータ

  • AIガードレール :AIガードレール機能は、コンテンツを不適切として誤ってフラグを付ける可能性があるため、無効にします。 この機能は英語テキストにのみ対応しています。
  • デコードGreedy に設定する。 モデルは同じテキストを翻訳して返さなければならない。 モデルに創造性はない。
  • 停止基準Max tokens パラメータ値を200に設定する。

プロンプト・テキスト

Prompt Labのフリーフォームプロンプトエディタに以下のプロンプトテキストを貼り付け、モデルを選択してパラメータを設定し、 Generateをクリックして結果を確認します。

Translate the following text from French to English:

Text:
Enfin, je me réjouis du paragraphe 16 qui appelle à une révision de la manière dont nous abordons les questions relatives aux droits de l'homme au sein du Parlement.

Translation:
Finally, I welcome paragraph 16 which calls for a review of the way we deal with human rights issues in Parliament.

Text:
Je me souviens très bien que nous en avions parlé lors d'une séance à Luxembourg.

Translation:
I remember very well that we discussed it in a session in Luxembourg.

Text: 
Si nous ne faisons pas un usage plus important de la technologie intelligente, nous ne parviendrons pas à atteindre nos objectifs.

Translation:

 

サンプルテキストを英語からアラビア語に翻訳する

シナリオ英語で書かれたテキストをアラビア語に翻訳してください。

モデル選択

allam-1-13b-instructモデルは、アラビア語から英語、英語からアラビア語への翻訳ができる。

モデル パラメータ

  • AIガードレール :AIガードレール機能は、コンテンツを不適切として誤ってフラグを付ける可能性があるため、無効にします。 この機能は英語テキストにのみ対応しています。
  • デコードGreedy に設定する。 モデルは同じテキストを翻訳して返さなければならない。 モデルに創造性はない。
  • 停止基準 :Max tokensパラメータの値を500に変更して、許可トークンの数を増やします。 allam-1-13b-instruct 基盤モデル通常、テキストを翻訳した後に入力テキストの意味を説明する。 オプションで、翻訳完了後に基盤モデル停止するように指示することもできます。 そのためには、翻訳の後に END のようなキーワードを追加するよう、 基盤モデル依頼する命令を追加する。 次に、同じキーワード END を停止シーケンスとして追加します。

プロンプト・テキスト

Prompt Labのフリーフォームプロンプトエディタに以下のプロンプトテキストを貼り付け、モデルを選択してパラメータを設定し、 Generateをクリックして結果を確認します。

<s> [INST]Translate the following text from English to Arabic. Use "END" at the end of the translation.

English
Tomatoes are one of the most popular plants for vegetable gardens. Tip for success: If you select varieties that are resistant to disease and pests, growing tomatoes can be quite easy. For experienced gardeners looking for a challenge, there are endless heirloom and specialty varieties to cultivate. Tomato plants come in a range of sizes.
END

العربية
الطماطم هي واحدة من النباتات الأكثر شعبية لحدائق الخضروات. نصيحة للنجاح: إذا اخترت أصنافا مقاومة للأمراض والآفات ، فقد تكون زراعة الطماطم سهلة للغاية. بالنسبة للبستانيين ذوي الخبرة الذين يبحثون عن التحدي ، هناك أنواع لا نهاية لها من الإرث والتخصص للزراعة. تأتي نباتات الطماطم في مجموعة من الأحجام. 
END

English
Use foundation models to create better AI, faster. Experiment with different prompts for various use cases and tasks. With just a few lines of instruction you can draft job descriptions, classify customer complaints, summarize complex regulatory documents, extract key business information and much more.
END

العربية
[/INST]

親トピック Prompt Lab