ChatGPT prompt Guide プロンプトガイド 和訳 by DeepL

ChatGPTに参考になるプロンプトのリンク集です。

■ChatGPTの本家のプロンプトエンジニアリングについてのページです。

https://help.openai.com/en/articles/6654000-best-practices-for-prompt-engineering-with-openai-api



言語は英語ばかりですが、DeepLなどを使えばなんとなくわかるのではないでしょうか?

Get started


https://platform.openai.com/playground?mode=chat

1. Use the latest model/最新モデルの使用

For best results, we generally recommend using the latest, most capable models. As of November 2022, the best options are the “text-davinci-003” model for text generation, and the “code-davinci-002” model for code generation.

最良の結果を得るためには、通常、最新の最も高性能なモデルを使用することをお勧めします。2022年11月現在、テキスト生成には「text-davinci-003」モデル、コード生成には「code-davinci-002」モデルが最適です。


2. Put instructions at the beginning of the prompt and use ### or “”” to separate the instruction and context 指示をプロンプトの先頭に置き、##または”””を使って指示とコンテキストを区切る。

Summarize the text below as a bullet point list of the most important points.
以下の文章を、最も重要な点を箇条書きにして要約しなさい。

Text: """
{text input here}
"""



3.Be specific, descriptive and as detailed as possible about the desired context, outcome, length, format, style, etc 希望する文脈、結果、長さ、形式、スタイルなどについて、具体的かつ説明的で、できるだけ詳しく書いてください。

Write a short inspiring poem about OpenAI, focusing on the recent DALL-E product launch (DALL-E is a text to image ML model) in the style of a {famous poet}

事例:

最近発表されたDALL-E(DALL-Eはテキストから画像へのMLモデル)を中心に、OpenAIに関する感動的な短い詩を{有名な詩人}のスタイルで書いてください。

4. Articulate the desired output format through examples (example 1, example 2).
例(例1、例2)を通して、希望する出力形式を明示する。

Extract the important entities mentioned in the text below. First extract all company names, then extract all people names, then extract specific topics which fit the content and finally extract general overarching themes


以下のテキストに記載されている重要なエンティティを抽出する。まずすべての会社名を抽出し、次にすべての人名を抽出し、次に内容に合った特定のトピックを抽出し、最後に一般的な包括的テーマを抽出する。

望ましい形式
会社名 <comma_separated_list_of_company_names> (コンマで区切られた会社名リスト)
人名: -||-人名
特定のトピック -||-
一般的なテーマ: -||-

テキスト {テキスト}

Desired format:
Company names: <comma_separated_list_of_company_names>
People names: -||-
Specific topics: -||-
General themes: -||-

Text: {text}


5. Start with zero-shot, then few-shot (example), neither of them worked, then fine-tune ゼロショットから始め、次に数ショット(例)、どちらもうまくいかなかった。

✅ Zero-shot ゼロショット

Extract keywords from the below text. 以下のテキストからキーワードを抽出する。

Text: {text}

Keywords:

✅Few-shot – provide a couple of examples フューショット

Extract keywords from the corresponding texts below. 以下の対応するテキストからキーワードを抽出する。

Text 1: Stripe provides APIs that web developers can use to integrate payment processing into their websites and mobile applications. テキスト1:Stripeは、ウェブ開発者がウェブサイトやモバイルアプリケーションに決済処理を統合するために使用できるAPIを提供しています。


Keywords 1: Stripe, payment processing, APIs, web developers, websites, mobile applicationsキーワード1:Stripe、決済処理、API、ウェブ開発者、ウェブサイト、モバイルアプリケーション

##
Text 2: OpenAI has trained cutting-edge language models that are very good at understanding and generating text. Our API provides access to these models and can be used to solve virtually any task that involves processing language.
Keywords 2: OpenAI, language models, text processing, 

テキスト2:OpenAIは、テキストの理解と生成に優れた最先端の言語モデルをトレーニングしています。私たちのAPIは、これらのモデルへのアクセスを提供し、言語処理を伴うほぼすべてのタスクを解決するために使用することができます。
キーワード2:OpenAI、言語モデル、テキスト処理、API。
##

Text 3: {text}
Keywords 3:

プロンプト事例

https://docs.google.com/document/d/1h-GTjNDDKPKU_Rsd0t1lXCAnHltaXTAzQ8K2HRhQf9U/edit#

6. Reduce “fluffy” and imprecise descriptions 「ふわっとした」不明確な記述を減らす。

Less effective ❌:

The description for this product should be fairly short, a few sentences only, and not too much more.
この商品の説明文は、かなり短く、数センテンスのみで、それ以上は書かないこと。

Better ✅:

Use a 3 to 5 sentence paragraph to describe this product. この製品について3~5文で説明してください。

7. Instead of just saying what not to do, say what to do instead

Less effective ❌:

The following is a conversation between an Agent and a Customer. DO NOT ASK USERNAME OR PASSWORD. DO NOT REPEAT.以下は、エージェントとお客様の会話です。ユーザー名やパスワードを尋ねないでください。繰り返さないでください。

Agent:

Customer: I can’t log in to my account. お客様 アカウントにログインできません。
Agent:

Better ✅:

The following is a conversation between an Agent and a Customer. The agent will attempt to diagnose the problem and suggest a solution, whilst refraining from asking any questions related to PII. Instead of asking for PII, such as username or password, refer the user to the help article www.samplewebsite.com/help/faq
以下は、エージェントとお客様の会話です。エージェントは問題の診断と解決策の提案を試みますが、PII に関する質問は控えます。ユーザネームや パスワードのような PII を尋ねる代わりに、ヘルプ記事 www.samplewebsite.com/help/faq を参照してください。

Customer: I can’t log in to my account. お客様 アカウントにログインできません。
Agent:

8. Code Generation Specific – Use “leading words” to nudge the model toward a particular pattern モデルを特定のパターンに誘導するために「リーディングワード」を使用する。

Less effective ❌:

# Write a simple python function that # 簡単なパイソン関数を書く
# 1. Ask me for a number in mile  # 1. マイルで数値を求める
# 2. It converts miles to kilometers # 2. マイルをキロに変換する

In this code example below, adding “import” hints to the model that it should start writing in Python. (Similarly “SELECT” is a good hint for the start of a SQL statement.)以下のコード例では、”import “を追加することで、モデルがPythonで記述し始めることを示唆しています。(同様に “SELECT “はSQL文の開始を示す良いヒントです)。

Better ✅:

# Write a simple python function that # 簡単なパイソン関数を書く
# 1. Ask me for a number in mile # 1. マイルで数値を求める
# 2. It converts miles to kilometers # 2. マイルをキロに変換する
 
 
import  インポート

Parameters パラメーターズ

Generally, we find that model and temperature are the most commonly used parameters to alter the model output. 一般的に、モデル出力を変更するために最もよく使われるパラメータは、モデルと温度であることがわかった。

  1. model Higher performance models are more expensive and have higher latency.
    model – 高性能なモデルはより高価で、レイテンシーが高い。
  2. temperatureA measure of how often the model outputs a less likely token. The higher the temperature, the more random (and usually creative) the output. This, however, is not the same as “truthfulness”. For most factual use cases such as data extraction, and truthful Q&A, the temperature of 0 is best.
    emperature –
    可能性の低いトークンを出力する頻度を示す。温度が高いほど、ランダムな(そして通常は創造的な)出力になる。しかし、これは「真実性」とは異なる。データ抽出や真実のQ&Aなど、ほとんどの事実に基づいたユースケースでは、温度0が最適です。
  3. max_tokens (maximum length) – Does not control the length of the output, but a hard cutoff limit for token generation. Ideally you won’t hit this limit often, as your model will stop either when it thinks it’s finished, or when it hits a stop sequence you defined.
    max_tokens(最大長) – 出力の長さを制御するのではなく、トークン生成のハードカットオフ制限を指定します。理想的には、この制限に頻繁にぶつかることはありません。モデルは、終了したと思ったときか、定義した停止シーケンスにぶつかったときに停止します。
  4. stop (stop sequences) – A set of characters (tokens) that, when generated, will cause the text generation to stop.
    stop (停止シーケンス) – 生成されたときにテキスト生成を停止させる文字(トークン)のセット。

For other parameter descriptions see the API reference. その他のパラメータの説明については、APIリファレンスを参照のこと。
API reference   https://platform.openai.com/docs/api-reference/completions/create

Additional Resources その他のリソース

If you’re interested in additional resources, we recommend: その他のリソースにご興味がおありなら、以下をお勧めする:

  • Guides
    • Text completion – learn how to generate or edit text using our models

      テキスト補完 – 私たちのモデルを使用してテキストを生成または編集する方法を学ぶ

    • Code completion – explore prompt engineering for Codex

      コード補完 – Codexのプロンプトエンジニアリングについて
    • Fine-tuning – Learn how to train a custom model for your use case
      ファインチューニング – ユースケースに合わせたカスタムモデルをトレーニングする方法を学びます。
    • Embeddings – learn how to search, classify, and compare text
      埋め込み – テキストを検索、分類、比較する方法を学ぶ
    • Moderation
      モデレーション
  • OpenAI cookbook repo – contains example code and prompts for accomplishing common tasks with the API, including Question-answering with Embeddings

    OpenAI cookbook repo – Embeddingsを使った質問応答など、APIを使った一般的なタスクを達成するためのサンプルコードとプロンプトが含まれています。
  • Community Forum コミュニティフォーラム

■総合的にプロンプトを学習するのに最適

learnprompting.org

https://learnprompting.org/ja/docs/intro

■コピペですぐに、ChatGPTで実践できるプロンプト

【ChatGPT】駆け出しエンジニア的プロンプト集

https://qiita.com/ysk91_engineer/items/34bd953fb935132dc16e

OpenAIのドキュメントでプロンプトのベストプラクティスを勉強してみた

https://tech-blog.rakus.co.jp/entry/20230425/prompt