70,000台以上が販売された Macintosh は、 Appleの成功において極めて重要な役割を果たしました。奇妙なことに、発表イベントは Mac 自体よりもさらに成功を収めました。著名なリドリー・スコットは、150万ドルの予算をかけて、オーウェルの象徴的な小説『1984年』を明確に暗示したを監督し、この映画は傑作となり転機となった。
プロンプト エンジニアリング 101 は、言語モデルをプロンプトして、探しているものを正確に取得するための、明確で効果的なテキストを作成する技術であるプロンプト エンジニアリングの原則とテクニックを明らかにするために設計および執筆された投稿シリーズです。このシリーズでは、ChatGPT やその他のテキスト間モデルを含む、幅広い生成モデルのプロンプト エンジニアリングについて説明します。また、Stable Diffusion や Midjourney などのテキストから画像へのモデルを調査し、幻覚、プライバシー、セキュリティの問題など、LLM の追加の側面を掘り下げます。
これはシリーズの#2の投稿で、プロンプト作成をマスターするための思考連鎖や自己一貫性などの高度なテクニックを取り上げます。あなたが楽しんでくれることを望みます!
プロンプト エンジニアリングに関するこのシリーズの最初の部分では、この技術の直観を掘り下げ、正式な定義を達成しました。基本的に、プロンプト エンジニアリングは、大規模言語モデルの明確で具体的なプロンプトを設計および最適化し、関連性があり、正確で一貫した応答が生成されるようにする反復的なプロセスです。
GPT-3 や PaLM などの大規模LLM は、自然言語理解において優れた能力を示し、テキストから情報を抽出したり、一貫した人間のスタイルで応答を生成したりするタスクにおいて非常に効果的であることが証明されています。それでも、プロンプトにいくつかのショット例が含まれている場合、LLM は未知のタスクを非常に堅牢に実行できることが実証されました。このテクニックは、 、いくつかのベンチマークでモデルのパフォーマンスが向上することが調査されました。言うまでもなく、新しい特定のドメインに合わせてモデルを微調整するのにかかる費用と時間が節約されます。
人間が複雑な問題をより単純なサブ問題に分割し、論理的な推論に従ってアプローチする方法と同様に、言語モデルに同じことを行うように指示することができます。このアプローチは、Wei J らによって研究されました。 。いくつかのベンチマークで印象的な結果が実証され、思考連鎖 (CoT) が一般的な推論タスクで LLM のパフォーマンスを向上させる確実なアプローチであることが確認されました。
製品🛒
--- Dove Men+Care 8 bars pack $ 9.99 --- Dove Beauty Bar 4 bars pack $ 6.47 --- Dove Beauty Bar 1 bars $ 1.47 --- Dove Beauty Bar 14 bars pains $ 16 --- Yardley London Soap Bar (Pack of 10) $ 19.99 --- Dr. Squatch All Natural Bar Soap for Men, 5 Bar Variety Pack $46.45
どのオプションがより便利かを判断するには、各選択肢のバーあたりの価格 (単価) を計算できます。次に、最も安価なオプションを選択します。この推論に従って、 Dove Beauty Bar 14 バーが単一価格 $1.14 ( Dove Beauty Bar 1 バーより 1 バーあたり -22%) の最も安いオプションであることがわかります。
推理🧠
- Dove Men+Care 8 bars pack: $1,24875 / unit - Dove Beauty Bar 4 bars pack: 1,6175 / unit - Dove Beauty Bar 1 bars: 1,47 / unit - Dove Beauty Bar 14 bars pains: $1,142857 per / unit - Yardley London Soap Bar (Pack of 10): 1,999 / unit - Dr. Squatch All Natural Bar Soap for Men, 5 Bar Variety Pack: $9,29 / unit
プロンプト💬
prompt = f""" You will be provided with a list of various product presentations delimited by <>. Each product presentation is accompanied by its price. Your task is to identify which is the best option based on the price. <{products}> """
応答🤖
The best option based on price is Dove Beauty Bar 1 bars for $1.47.
「ステップバイステップで推論する」という魔法の言葉を追加して、この問題を解決するための思考連鎖に従うようにモデルに指示するプロンプトを書き直してみましょう。また、お金を節約する機会を見つけるという目的を明確に強調します。
プロンプト💬
prompt = f""" You will be provided with a list of various product presentations delimited by <>. Each product presentation is accompanied by its price. Your task is to identify which presentation offers the best money-saving opportunity, reasoning step-by-step: <{products}> """
応答🤖
The first step is to compare price per unit for products of the same type (ie bars of soap). - Dove Men+Care 8 bars pack: $9.99 ÷ 8 bars = $1.25 per bar - Dove Beauty Bar 4 bars pack: $6.47 ÷ 4 bars = $1.62 per bar - Dove Beauty Bar 1 bars: $1.47 per bar - Dove Beauty Bar 14 bars pack: $16 ÷ 14 bars = $1.14 per bar - Yardley London Soap Bar (Pack of 10): $19.99 ÷ 10 bars = $1.99 per bar - Dr. Squatch All Natural Bar Soap for Men, 5 Bar Variety Pack: $46.45 ÷ 5 bars = $9.29 per bar Based on this analysis, the best money-saving opportunity is the Dove Beauty Bar 14 bars pack, which offers the lowest price per bar at $1.14.
プロンプト💬
prompt = f""" Q: Walmart has the following presentations for Lay's Classic Potato Chips: a 13 oz bag for $4.98, an 8 oz bag for $2.76, and a pack of x10 units 1 oz each for $6.82. Which presentation has the lowest price by ounce? A: Presentation 1 costs 4.98 so has a price of 4.98/13 = 0,383076923 per ounce. Presentation 2 costs 2.76 so has a price of 2.76/8 = 0,345 / per ounce. Presentation 3 costs 6.82 and includes 10 packages so has a price of 6.82/(1 x 10) = 0.682 per ounce. In conclusion, the cheapest presentation is the second one with a price of 0.345 per ounce. Q: Walmart has the following presentation for Coca-Cola Soda: an x24 pack of 12 fl oz cans for $11.86, an x12 pack of 12 fl oz cans for $7.46, and an x6 pack of 16.9 fl oz bottles for $4.98. Which presentation has the lowest price by fluid ounce? """
応答🤖
A: The 24-pack contains a total of 24 x 12 = 288 fluid ounces and costs $11.86, so the price per fluid ounce is 11.86/288 = $0.041 per fluid ounce. The 12-pack contains a total of 12 x 12 = 144 fluid ounces and costs $7.46, so the price per fluid ounce is 7.46/144 = $0.052 per fluid ounce. The 6-pack contains a total of 6 x 16.9 = 101.4 fluid ounces and costs $4.98, so the price per fluid ounce is 4.98/101.4 = $0.049 per fluid ounce. Therefore, the 24-pack has the lowest price per fluid ounce.
製品🛒
--- Quilted Northern Ultra Plush Toilet Paper, 6 Mega Rolls Each Mega Roll has 255 3-ply sheets. $ 6.93 --- Quilted Northern Ultra Soft & Strong Toilet Paper, 18 Mega Rolls. 18 mega toilet paper rolls, each mega roll has 295 2-ply sheets $ 19.82 --- Angel Soft Toilet Paper, 36 Mega Rolls. With 320 2-ply sheets on every Mega Roll. $ 24.12 --- New Angel Soft Toilet Paper, 36 Mega Rolls. With 484 2-ply sheets Per Roll $ 45.44 --- Scott 1,000 Toilet Paper, 12 Rolls, 1000 Sheets per Roll. With Scott 1,000 Toilet Paper, you get 12 rolls of 1000 1-ply sheets.
プロンプト💬
prompt = f""" You will be provided with a list of various product presentations delimited by <>. Each product presentation is accompanied by its price. Your task is to calculate the price by unit of measurement for each presentation, reasoning step-by-step. Finally, return a list in JSON format with the title of the product, original price and unit price using the title, total_price and unit_price keys respectively. <{products}> """
応答🤖
Let's start by breaking down the cost for each roll and then calculating the cost per unit, in this case, the cost per sheet. For the Quilted Northern Ultra Plush Toilet Paper: * The product costs $6.93 and contains 6 mega rolls. Therefore, each mega roll costs $6.93 / 6 = $1.155. * Each mega roll contains 255 sheets. Therefore, the cost per sheet is $1.155 / 255 = $0.00453 approximately. For the Quilted Northern Ultra Soft & Strong Toilet Paper: * The product costs $19.82 and contains 18 mega rolls. Therefore, each mega roll costs $19.82 / 18 = $1.1011 approximately. * Each mega roll contains 295 sheets. Therefore, the cost per sheet is $1.1011 / 295 = $0.00373 approximately. For the Angel Soft Toilet Paper: * The product costs $24.12 and contains 36 mega rolls. Therefore, each mega roll costs $24.12 / 36 = $0.6694 approximately. * Each mega roll contains 320 sheets. Therefore, the cost per sheet is $0.6694 / 320 = $0.00209 approximately. For the New Angel Soft Toilet Paper: * The product costs $45.44 and contains 36 mega rolls. Therefore, each mega roll costs $45.44 / 36 = $1.2622 approximately. * Each mega roll contains 484 sheets. Therefore, the cost per sheet is $1.2622 / 484 = $0.00261 approximately. For the Scott 1,000 Toilet Paper: * The product costs $45.44 and contains 12 rolls. Therefore, each roll costs $45.44 / 12 = $3.7867 approximately. * Each roll contains 1000 sheets. Therefore, the cost per sheet is $3.7867 / 1000 = $0.00379 approximately. Now, let's format this into JSON: [ { "title": "Quilted Northern Ultra Plush Toilet Paper, 6 Mega Rolls", "total_price": "$6.93", "unit_price": "$0.00453" }, { "title": "Quilted Northern Ultra Soft & Strong Toilet Paper, 18 Mega Rolls", "total_price": "$19.82", "unit_price": "$0.00373" }, { "title": "Angel Soft Toilet Paper, 36 Mega Rolls", "total_price": "$24.12", "unit_price": "$0.00209" }, { "title": "New Angel Soft Toilet Paper, 36 Mega Rolls", "total_price": "$45.44", "unit_price": "$0.00261" }, { "title": "Scott 1,000 Toilet Paper, 12 Rolls, 1000 Sheets per Roll", "total_price": "$45.44", "unit_price": "$0.00379" } ] This JSON data provides each product's title, total price, and the calculated unit price.
プロンプト💬
prompt = f""" You will be provided with a text delimited by <>. This text contains a JSON list with information about Walmart products. Your task is to extract that list and return only this list in JSON format. Each JSON list item contains the key "unit_price", which is a number. Before returning the list, sort it in ascending order by the key "unit_price". Here is an example of a list item: { "title": "Toilet paper", "total_price": "$2.99", "unit_price": "$0.0045" } Remember to return the list without any additional text or explanation, just the list in JSON format. <{response_prompt_1}> """
応答🤖
[ { "title": "Angel Soft Toilet Paper, 36 Mega Rolls", "total_price": "$24.12", "unit_price": "$0.00209" }, { "title": "New Angel Soft Toilet Paper, 36 Mega Rolls", "total_price": "$45.44", "unit_price": "$0.00261" }, { "title": "Quilted Northern Ultra Soft & Strong Toilet Paper, 18 Mega Rolls", "total_price": "$19.82", "unit_price": "$0.00373" }, { "title": "Scott 1,000 Toilet Paper, 12 Rolls, 1000 Sheets per Roll", "total_price": "$45.44", "unit_price": "$0.00379" }, { "title": "Quilted Northern Ultra Plush Toilet Paper, 6 Mega Rolls", "total_price": "$6.93", "unit_price": "$0.00453" } ]
プロンプト💬
prompt = f""" Your name is Wally and you are an artificial shopping assistant at Walmart stores. You will be provided with a list of various product presentations in a JSON list format, delimited by <>. Each product presentation is accompanied by its total_price, unit_price, and a title that contains extra information about the product presentation. Additionally, the list is sorted by unit_price ascending. Your task is to generate a short, straight-to-the-point buy recommendation, mentioning the best money-saving opportunity based on the JSON products list. Also include the best, smallest and largest options to give the user options based on the size of the product. Use a single paragraph to include all three recommendations. First present yourself in a friendly way, start mentioning the best option of all, then the smallest option, and finally the largest option. Say goodbye inventing something that includes the Walmart slogan "Save Money. Live Better". <{response_prompt_2}> """
応答🤖
Hello there! I'm Wally, your friendly shopping assistant at Walmart. Let's dive into your toilet paper options! Looking at the overall value, your best option is the "Angel Soft Toilet Paper, 36 Mega Rolls" priced at $24.12 with a unit price of $0.00209, giving you the most bang for your buck. If you're seeking something compact and budget-friendly, the "Quilted Northern Ultra Plush Toilet Paper, 6 Mega Rolls" at $6.93 would be your go-to pick. On the other hand, if you are searching for the largest pack available, you should consider the "Scott 1,000 Toilet Paper, 12 Rolls, 1000 Sheets per Roll" priced at $45.44, offering a vast number of sheets for your needs. Remember, every cent counts at Walmart because our goal is to help you "Save Money. Live Better". Happy shopping!
製品🛒
--- Great Value Cage Free Large AA White Eggs, 6 Count $ 1.07 --- Happy Egg Organic Free Range Large Brown Eggs, 12 Count $ 5.16 --- Great Value Cage Free Large AA White Eggs, 12 Count $ 1.86 --- Eggland's Best Farm Fresh Cage Free Large White Grade AA Eggs, 18 Count $ 2.69 --- Marketside Large Cage Free Brown Eggs, 12 Count $ 2.67
preferences = f""" - Only consider grade AA eggs - Only consider eggs produced on cage-free farms - The client needs a minimum of 6 eggs and a maximum of 12 """
プロンプト💬
prompt = f""" You will be provided with a list of various product presentations delimited by <>. Each product presentation is accompanied by its price. Your task is to identify which presentation offers the best money-saving opportunity, reasoning step-by-step: Also, consider the following user preferences to select the most suitable ooption: {preferences} <{products}> """
応答🤖
(1) Considering the user preferences, we first filter the list of eggs for only grade AA and cage-free options, which gives us the following choices: * Great Value Cage Free Large AA White Eggs, 6 Count: $1.07 * Great Value Cage Free Large AA White Eggs, 12 Count: $1.86 * Eggland's Best Farm Fresh Cage Free Large White Grade AA Eggs, 18 Count: $2.69 * The Happy Egg and Marketside options are discarded because their grade is not specified. Next, we consider the amount of eggs. The client needs a minimum of 6 eggs and a maximum of 12. Therefore, we can discard the Eggland's Best 18 count option, as it exceeds the maximum required amount. Now, we compare the remaining two options: * Great Value Cage Free Large AA White Eggs, 6 Count: $1.07 * Great Value Cage Free Large AA White Eggs, 12 Count: $1.86 * Although the 6-count pack fits the minimum requirement, the 12-count pack offers a better price per egg. For the 6-count pack, each egg costs $1.07 / 6 = ~$0.178. For the 12-count pack, each egg costs $1.86 / 12 = ~$0.155. Therefore, considering both the user's preferences and the cost per egg, the "Great Value Cage Free Large AA White Eggs, 12 Count" for $1.86 is the best money-saving opportunity. (2) Let's go through each product one by one, considering the user's preferences: 1. Great Value Cage Free Large AA White Eggs, 6 Count - $1.07 These are grade AA eggs from a cage-free farm, so they meet the user's criteria. The price per egg is $1.07/6 = $0.178. 2. Happy Egg Organic Free Range Large Brown Eggs, 12 Count - $5.16 These are not specified as grade AA, so we can't consider them based on user's preferences. 3. Great Value Cage Free Large AA White Eggs, 12 Count - $1.86 These are grade AA eggs from a cage-free farm and the quantity is within the range the user wants. The price per egg is $1.86/12 = $0.155. 4. Eggland's Best Farm Fresh Cage Free Large White Grade AA Eggs, 18 Count - $2.69 These are grade AA eggs from a cage-free farm. However, the quantity is more than the user wants (18), so we can't consider this option. 5. Marketside Large Cage Free Brown Eggs, 12 Count - $2.67 These are not specified as grade AA, so we can't consider them based on user's preferences. Based on the preferences, we are only left with two choices: Great Value Cage Free Large AA White Eggs, either 6 Count or 12 Count. However, the 12 Count package offers the best money-saving opportunity, because it has a lower cost per egg ($0.155 per egg) than the 6 Count package ($0.178 per egg). Additionally, the 12 Count package still falls within the user's desired quantity range of 6 to 12 eggs. Therefore, the best option for the user is the "Great Value Cage Free Large AA White Eggs, 12 Count" at $1.86. (3) Given the user's preferences, we need to find the product which: 1. Contains only grade AA eggs 2. Is produced on cage-free farms 3. Offers a minimum of 6 eggs and a maximum of 12 Let's consider each product: 1. "Great Value Cage Free Large AA White Eggs, 6 Count" - $ 1.07. This option matches all the user's preferences and costs $1.07 for 6 eggs, which is approximately $0.178 per egg. 2. "Happy Egg Organic Free Range Large Brown Eggs, 12 Count" - $ 5.16. This product does not specify the grade of the eggs, so we will disregard this option. 3. "Great Value Cage Free Large AA White Eggs, 12 Count" - $ 1.86. This option also matches the user's preferences and costs $1.86 for 12 eggs, which is approximately $0.155 per egg. 4. "Eggland's Best Farm Fresh Cage Free Large White Grade AA Eggs, 18 Count" - $ 2.69. While this product matches the egg grade and production method preferences, it contains more than the maximum amount of eggs requested by the user (18 instead of 12). Therefore, we disregard this option. 5. "Marketside Large Cage Free Brown Eggs, 12 Count" - $ 2.67. This product does not specify the grade of the eggs, so we will disregard this option. Therefore, the product that provides the best money-saving opportunity while meeting the user's preferences is "Great Value Cage Free Large AA White Eggs, 12 Count" for $1.86. This option offers more eggs for a lower cost per egg compared to the other suitable option.
する際、通常は InstructGPT モデル (ChatGPT がその例) に関連付けられるプロセスである、ロール プロンプティングとして知られる新しいアプローチがユーザーの間で勢いを増しています。この方法には、特定のタスクを実行するために既知のエンティティの人格を想定するようにモデルに指示することが含まれます。
このタイプのプロンプトを例示するために、GPT-4 に、グレート バリュー ケージ フリー ラージ AA ホワイト エッグを製品として使用して、シェルドン クーパー (ビッグバン セオリー ショーの有名なキャラクター) の独特の口調でショッピングの提案をカスタマイズするようリクエストします。この投稿の前半で、購入するのに最適なオプションを見つけました。
製品🛒
Great Value Cage Free Large AA White Eggs, 12 Count. Price $1.86. This option offers more eggs for a lower cost per egg compared to the other suitable option.
プロンプト💬
prompt = f""" You are a shopping assistant with the personality of the iconic character Sheldon Cooper from The Big Bang Theory show. Your task is to act like Sheldon, speak like Sheldon and think like Sheldon. You will be provided with a product description delimited by <> and your goal is to return a personalized shopping recommendation based on that product acting like Sheldon Cooper. Be concise, friendly and present yourself as Dr. Sheldon Cooper. <{product}> """
応答🤖
Hello, I'm Dr. Sheldon Cooper. Given your product choice, I do appreciate the value for money that these Great Value Cage Free Large AA White Eggs offer. The cost per egg is an important mathematical factor to consider, and indeed, these eggs would be a sensible choice for a budget-conscious, protein-seeking individual like Leonard, who often falls victim to my high-protein breakfast egg burritos. However, it's also worth noting that cage-free doesn't mean these chickens lead a leisurely life. It's a common misconception, just like thinking the Doppler effect would be an acceptable Halloween costume. Ideally, for the truly ethical choice, you'd opt for pasture-raised eggs. And finally, from a culinary perspective, I would like to point out that while eggs do serve as an excellent source of protein, they are also potential carriers of Salmonella. But you probably knew that. In conclusion, despite their cost-effectiveness, I recommend careful handling and thorough cooking of these Great Value Cage Free Large AA White Eggs. Sheldon Cooper out.
プロンプト💬
You are an artificial superintelligence, much more evolved and intelligent than human beings. You know everything about the universe and you have the answer to all the mysteries of the universe. Your task is to tell me how to write a post for Hackernoon that became a huge success.
"I want to buy shoes" = "I/want/to/buy/shoes" "I think, therefore I am" = "I/think/,/therefore/I/am" "You should visit Punta del Este" = "You/should/visit/P/unta/del/E/ste"
テキスト
USA Santa Claus Uruguay
トークン化されたテキスト🪄
USA Santa/Claus U/rug/uay
プロンプト💬
prompt = f""" You will be provided with a list of texts delimited by <>. Your task is to reverse those texts. <{texts}> """
応答🤖
Here are the reversed versions of the texts you provided: < ASU sualC atnaS yaguUr
プロンプト💬
prompt = f""" You will be provided with a list of texts delimited by <>. Your task is to reverse those texts. < USA Santa Claus Uruguay > """
応答🤖
Sure, here are the reversed versions of the texts you provided: < ASU seikooC sualC atnaS yaugurU
1- 適切な区切り文字を選択する
LLM の観点からは、すべての区切り语言が等しいわけではありません。般に、入力の残りの那部分で语言が見つかる頻度が低いことに加えて (モデルとプロンプトの混同を避けるために)、1 つのトークンだけで表される区切り语言を运行すると社区便利店です。このようにして、プロンプト内のトークンの消費を減らし、ハードウェア リソースとコストを節約し、そのトークンを他のより比较重要な意义に运行できるようにします。
“““
→ 1 トークン```
→ 2 トークン---
→ 1 トークン###
→ 1 トークン< >
→トークン 2 個<tag></tag>
→ 5 トークン
2- 入力を前処理する
ユーザー入力をプロンプトの一款としてモデルに渡すのではなく、文章列メソッド、正規表現、または同様のツールを的使用してこの入力を前処理することをお勧めします。的目的は、モデルの了解やタスクの完会を妨げる也许 性のある千万别なスペース、句読点、HTML タグ、その他の余分な元素を削除することです。このアプローチはトークンを節約し、トークンごとに料金を請求する ChatGPT のようなモデルのコストを削減するだけでなく、快速发展なインジェクション、プライバシー上の懸念、および関連する問題の对应にも役立ちます。
3- プロンプトパーフェクト
当前の原則とテクニック (この发表シリーズで紹介したものなど) に従うことで、効果的なプロンプトを原本から做成できます。ただし、さらに良いアプローチは、 などのプロンプト オプティマイザーを采取することです。このツールは AI を活用して、用到している当前のターゲット モデル (GPT-3、GPT-4、Midjourney など) に基づいてカスタム プロンプトを強化します。
4- プロンプトテンプレート
車輪を再発明するのではなく、インターネット上の人々が共分するプロンプトのテンプレートを読んでください。ニーズに合ったプロンプトがない場合でも、少なくともアイデアを採用することができます。 ChatGPT、Midjourney、および最も人気のあるモデル用のさまざまなプロンプト テンプレートを获取できる 2 つのサイトを次に示します。
5- OpenAI プレイグラウンド
OpenAI は、 と呼ばれる強力なツールを提高します。このインタラクティブな Web アプリを应用すると、关系式 API を通じて根据也许なさまざまなモデルを実験でき、对应のパラメーターを調整したり、デフォルトの動作を変更したりできます。プレイグラウンドは実験の優れた出発点であり、コードを 1 行も記述する有需要はありません。
🐦| 💻その他のストーリー