From a09704baa2a24e04c109456cb231773e0a36904b Mon Sep 17 00:00:00 2001 From: "Charles J. Fowler" Date: Fri, 1 Nov 2024 12:12:28 +0000 Subject: [PATCH] Improve Prompt Engineering - Prompts & Techniques - Links (#7653) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 📃 docs, data (Image Prompting) Update Topic/Sub Topics - In Place Edits. - intent: Update topic from May 2023 to Oct 2024 - data: src/data/roadmaps/prompt-engineering/content/ - modify - 10X .ms --- Co-authored-by: @iPoetDev * 📃 docs, data (Prompt Engineering Roadmap) Basic Concepts - In Place Edits. - changes: single paragraphs (74-125 words)> - concerns: if any more concise, topics looses fidelity, meaning and utility. - data: src/data/roadmaps/prompt-engineering/content/ - 📂 100-basic-llm - modify: Topic - update content: - index.md - 100-what-are-llm.md - 101-llm-types.md - 102-how-llms-built.md --- Co-authored-by: @iPoetDev * 📃 docs: (Prompt Eng.) Basic LLM Concepts - New Links. - intent: Update topic from May 2023 to Oct 2024 - 📂 100 basic-llm - modify topics: - add links - 100-what-are-llms.md - 101-types-llms.md - 102-how-llms-are-bilt.md BREAKING CHANGE: ❌ --- Co-authored-by: @iPoetDev * docs: (Prompt Eng.) Prompting Introduction - New Links. - intent: Update topic from May 2023 to Oct 2024 - 📂 101-prompting-introduction - modify topics: - add links - index.md - 100-basic-prompting.md - 101-need-for-prompting.md BREAKING CHANGE: ❌ --- Co-authored-by: @iPoetDev * 📃 docs: (Prompt Eng.) Prompting Techniques - New Links. - intent: Update missing links from May 2023 to Oct 2024 - data: src/data/roadmaps/prompt-engineering/content/ - 📂 102-prompts - modify: Links New - prompts/index.md - prompts/100-parts-of-a-prompt.md - 📂 102-prompts/prompting-techniques - modify: Content Modify - added a "Learn more" line to all files ahead of links. - removed duplicated text in a code fence. - 104-least-to-most.md - modify: Links New - 100-role-prompting.md - 101few-shot-prompting.md - 102-chain-of-thought.md - 103-zeroshot-chain-of-thought.md - 104-least-to-most.md - 105-dual-prompt.md - 106-combining-technqiues.md BREAKINGCHANGE: ❌ --- Co-authored-by: @iPoetDev --- .../102-prompts/101-parts-of-a-prompt.md | 9 ++- .../content/102-prompts/index.md | 7 ++- .../100-role-prompting.md | 7 ++- .../101-few-shot-prompting.md | 8 ++- .../102-chain-of-thought.md | 8 ++- .../103-zeroshot-chain-of-thought.md | 9 ++- .../prompting-techniques/104-least-to-most.md | 58 ++++++++++++++----- .../prompting-techniques/105-dual-prompt.md | 5 ++ .../106-combining-techniques.md | 10 +++- 9 files changed, 99 insertions(+), 22 deletions(-) diff --git a/src/data/roadmaps/prompt-engineering/content/102-prompts/101-parts-of-a-prompt.md b/src/data/roadmaps/prompt-engineering/content/102-prompts/101-parts-of-a-prompt.md index 5fb83b3ba15a..b785c7399368 100644 --- a/src/data/roadmaps/prompt-engineering/content/102-prompts/101-parts-of-a-prompt.md +++ b/src/data/roadmaps/prompt-engineering/content/102-prompts/101-parts-of-a-prompt.md @@ -14,4 +14,11 @@ When constructing a prompt, it's essential to understand the different parts tha *Example: To further clarify the email-writing task, you might provide a brief example of the tone or structure you want, such as "Dear [Recipient], Thank you for taking the time to meet with me yesterday. We discussed [topic 1], [topic 2], and [topic 3]. I look forward to our future collaboration."* -By considering these three parts of a prompt — context, instruction, and example — you can create effective and well-formed prompts that produce targeted and accurate responses from the AI. \ No newline at end of file +By considering these three parts of a prompt — context, instruction, and example — you can create effective and well-formed prompts that produce targeted and accurate responses from the AI. + +Learn more from the following resources: + +- [@guides@Understanding Prompt Structure: Key Elements of a Prompt](https://learnprompting.org/docs/basics/formalizing) +- [@guides@Elements of a Prompt | Prompt Engineering Guide](https://www.promptingguide.ai/introduction/elements) +- [@video@Building with Anthropic Claude: Prompt Workshop ](https://youtu.be/hkhDdcM5V94?si=mW-GLSvi7TMg33wx) +- [@guides@General Tips for Designing Prompts | Prompt Engineering Guide](https://www.promptingguide.ai/introduction/tips) \ No newline at end of file diff --git a/src/data/roadmaps/prompt-engineering/content/102-prompts/index.md b/src/data/roadmaps/prompt-engineering/content/102-prompts/index.md index 4220a4c441ca..ae8ee5986136 100644 --- a/src/data/roadmaps/prompt-engineering/content/102-prompts/index.md +++ b/src/data/roadmaps/prompt-engineering/content/102-prompts/index.md @@ -1,3 +1,8 @@ # Prompts -At this point, you probably already know what the Prompts are and the importance of writing good prompts. This section covers the best practices for writing good prompts as well as covering some of the commonly used prompting techniques. \ No newline at end of file +At this point, you probably already know what the Prompts are and the importance of writing good prompts. This section covers the best practices for writing good prompts as well as covering some of the commonly used prompting techniques. + +Learn more from the following resources: + +- [@guides@Prompt Engineering Guide: The Ultimate Guide to Generative AI](https://learnprompting.org/docs/introduction) +- [@guides@Optimizing Prompts | Prompt Engineering Guide](https://www.promptingguide.ai/guides/optimizing-prompts) \ No newline at end of file diff --git a/src/data/roadmaps/prompt-engineering/content/102-prompts/prompting-techniques/100-role-prompting.md b/src/data/roadmaps/prompt-engineering/content/102-prompts/prompting-techniques/100-role-prompting.md index a01b17282b59..27d1e8200abe 100644 --- a/src/data/roadmaps/prompt-engineering/content/102-prompts/prompting-techniques/100-role-prompting.md +++ b/src/data/roadmaps/prompt-engineering/content/102-prompts/prompting-techniques/100-role-prompting.md @@ -14,4 +14,9 @@ Role prompting is a technique used in prompt engineering to encourage the AI to Imagine you want to explore solutions to an environmental problem. You can use role prompting to elicit diverse perspectives and insights. Here's an example prompt with role prompting: -_As a climate scientist, how would you approach the problem of deforestation to minimize its impact on the environment?_ \ No newline at end of file +_As a climate scientist, how would you approach the problem of deforestation to minimize its impact on the environment?_ + +Learn more from the following resources: + +- [@article@Assigning Roles to Chatbots](https://learnprompting.org/docs/basics/roles) +- [@article@Revisiting Roles in Prompting](https://learnprompting.org/docs/intermediate/revisiting_roles) \ No newline at end of file diff --git a/src/data/roadmaps/prompt-engineering/content/102-prompts/prompting-techniques/101-few-shot-prompting.md b/src/data/roadmaps/prompt-engineering/content/102-prompts/prompting-techniques/101-few-shot-prompting.md index c7fd4109b27a..8fbdcb0d7744 100644 --- a/src/data/roadmaps/prompt-engineering/content/102-prompts/prompting-techniques/101-few-shot-prompting.md +++ b/src/data/roadmaps/prompt-engineering/content/102-prompts/prompting-techniques/101-few-shot-prompting.md @@ -29,4 +29,10 @@ The book was hard to put down. - {sentiment_label} This prompt structure assists the model in grasping the sentiment analysis task and increases the likelihood of getting the correct output (i.e., "Positive"). -Remember to experiment with the number of examples and their content to find the optimal balance for your specific task. Additionally, you can use inline instructions to guide the model further, such as asking it to classify the sentiment of a given sentence. \ No newline at end of file +Remember to experiment with the number of examples and their content to find the optimal balance for your specific task. Additionally, you can use inline instructions to guide the model further, such as asking it to classify the sentiment of a given sentence. + +Learn more from the following resources: + +- [@article@Few-Shot Prompting | Prompt Engineering Guide](https://www.promptingguide.ai/techniques/fewshot) +- [@article@Shot-Based Prompting: Zero-Shot, One-Shot, and Few-Shot Prompting](https://learnprompting.org/docs/basics/few_shot) +- [@guides@Introduction to Advanced Few-Shot Prompting Techniques](https://learnprompting.org/docs/advanced/few_shot/introduction) \ No newline at end of file diff --git a/src/data/roadmaps/prompt-engineering/content/102-prompts/prompting-techniques/102-chain-of-thought.md b/src/data/roadmaps/prompt-engineering/content/102-prompts/prompting-techniques/102-chain-of-thought.md index c19af3b9e800..c62df797063a 100644 --- a/src/data/roadmaps/prompt-engineering/content/102-prompts/prompting-techniques/102-chain-of-thought.md +++ b/src/data/roadmaps/prompt-engineering/content/102-prompts/prompting-techniques/102-chain-of-thought.md @@ -21,4 +21,10 @@ We can approach the topic through a series of connected prompts: - "Now, consider the challenges of working from home. Identify three potential disadvantages or negative effects." - "For each of these challenges, discuss how individuals and organizations can mitigate or address them." -By employing the Chain of Thought technique, we have directed the model to provide a thorough and systematic analysis of the subject in question, ultimately resulting in a more meaningful and accurate response. \ No newline at end of file +By employing the Chain of Thought technique, we have directed the model to provide a thorough and systematic analysis of the subject in question, ultimately resulting in a more meaningful and accurate response. + +Learn more from the following resources: + +- [@article@Chain-of-Thought Prompting | Prompt Engineering Guide](https://www.promptingguide.ai/techniques/cot) +- [@article@Chain-of-Thought Prompting](https://learnprompting.org/docs/intermediate/chain_of_thought) +- [@guides@Introduction to Thought Generation Prompting Techniques for LLMs](https://learnprompting.org/docs/advanced/thought_generation/introduction) \ No newline at end of file diff --git a/src/data/roadmaps/prompt-engineering/content/102-prompts/prompting-techniques/103-zeroshot-chain-of-thought.md b/src/data/roadmaps/prompt-engineering/content/102-prompts/prompting-techniques/103-zeroshot-chain-of-thought.md index 0215aaf177c4..5e5afad68d71 100644 --- a/src/data/roadmaps/prompt-engineering/content/102-prompts/prompting-techniques/103-zeroshot-chain-of-thought.md +++ b/src/data/roadmaps/prompt-engineering/content/102-prompts/prompting-techniques/103-zeroshot-chain-of-thought.md @@ -17,4 +17,11 @@ Suppose you want the model to explain how a solar panel works. A zeroshot chain Please explain the process of how a solar panel works, starting with sunlight hitting the panel's surface and ending with electricity being produced. Structure your response as a step-by-step chain of thought, taking care to clarify how each step leads to the next. ``` -By designing prompts that explicitly request step-by-step reasoning, the zeroshot chain of thought technique can lead to more comprehensive and insightful answers that go beyond simple factual statements. \ No newline at end of file +By designing prompts that explicitly request step-by-step reasoning, the zeroshot chain of thought technique can lead to more comprehensive and insightful answers that go beyond simple factual statements. + +Learn more from the following resources: + +- [@article@Zero-Shot Prompting | Prompt Engineering Guide](https://www.promptingguide.ai/techniques/zeroshot) +- [@article@Zero-Shot CoT Prompting: Improving AI with Step-by-Step Reasoning](https://learnprompting.org/docs/intermediate/zero_shot_cot) +- [@article@Shot-Based Prompting: Zero-Shot, One-Shot, and Few-Shot Prompting](https://learnprompting.org/docs/basics/few_shot) +- [@guides@Introduction to Advanced Zero-Shot Prompting Techniques](https://learnprompting.org/docs/advanced/zero_shot/introduction) \ No newline at end of file diff --git a/src/data/roadmaps/prompt-engineering/content/102-prompts/prompting-techniques/104-least-to-most.md b/src/data/roadmaps/prompt-engineering/content/102-prompts/prompting-techniques/104-least-to-most.md index a1cb742d1bd5..f1551acbe0e1 100644 --- a/src/data/roadmaps/prompt-engineering/content/102-prompts/prompting-techniques/104-least-to-most.md +++ b/src/data/roadmaps/prompt-engineering/content/102-prompts/prompting-techniques/104-least-to-most.md @@ -10,30 +10,43 @@ Let's ask a slightly complicated customer service question: ``` CUSTOMER INQUIRY: -I just bought a T-shirt from your Arnold collection on March 1st. I saw that it was on discount, so bought a shirt that was originall $30, and got 40% off. I saw that you have a new discount for shirts at 50%. I'm wondering if I can return the shirt and have enough store credit to buy two of your shirts? +I just bought a T-shirt from your Arnold collection on March 1st. +I saw that it was on discount, so bought a shirt that was originall $30, and got 40% off. +I saw that you have a new discount for shirts at 50%. +I'm wondering if I can return the shirt and have enough store credit to buy two of your shirts? INSTRUCTIONS: -You are a customer service agent tasked with kindly responding to customer inquiries. Returns are allowed within 30 days. Today's date is March 29th. There is currently a 50% discount on all shirts. Shirt prices range from $18-$100 at your store. Do not make up any information about discount policies.CUSTOMER INQUIRY: -I just bought a T-shirt from your Arnold collection on March 1st. I saw that it was on discount, so bought a shirt that was originall $30, and got 40% off. I saw that you have a new discount for shirts at 50%. I'm wondering if I can return the shirt and have enough store credit to buy two of your shirts? - -INSTRUCTIONS: -You are a customer service agent tasked with kindly responding to customer inquiries. Returns are allowed within 30 days. Today's date is March 29th. There is currently a 50% discount on all shirts. Shirt prices range from $18-$100 at your store. Do not make up any information about discount policies. +You are a customer service agent tasked with kindly responding to customer inquiries. +Returns are allowed within 30 days. +Today's date is March 29th. +There is currently a 50% discount on all shirts. Shirt prices range from $18-$100 at your store. +Do not make up any information about discount policies. ``` Output from the model would be: ``` -Thank you for your inquiry. Unfortunately, since you purchased the shirt on March 1st, it is outside of our 30-day return policy. However, we do have a 50% discount on all shirts currently, so you could purchase two shirts with the same amount of store credit. Prices for our shirts range from $18-$100. Please let us know if you have any other questions. +Thank you for your inquiry. Unfortunately, since you purchased the shirt on March 1st, it is outside of our 30-day return policy. +However, we do have a 50% discount on all shirts currently, so you could purchase two shirts with the same amount of store credit. +Prices for our shirts range from $18-$100. Please let us know if you have any other questions. ``` That failed (we are within the return time), so lets try to break it down into subproblems: ``` CUSTOMER INQUIRY: -I just bought a T-shirt from your Arnold collection on March 1st. I saw that it was on discount, so bought a shirt that was originall $30, and got 40% off. I saw that you have a new discount for shirts at 50%. I'm wondering if I can return the shirt and have enough store credit to buy two of your shirts? +I just bought a T-shirt from your Arnold collection on March 1st. +I saw that it was on discount, so bought a shirt that was originall $30, and got 40% off. +I saw that you have a new discount for shirts at 50%. I'm wondering if +I can return the shirt and have enough store credit to buy two of your shirts? INSTRUCTIONS: -You are a customer service agent tasked with kindly responding to customer inquiries. Returns are allowed within 30 days. Today's date is March 29th. There is currently a 50% discount on all shirts. Shirt prices range from $18-$100 at your store. Do not make up any information about discount policies. +You are a customer service agent tasked with kindly responding to customer inquiries. +Returns are allowed within 30 days. +Today's date is March 29th. +There is currently a 50% discount on all shirts. +Shirt prices range from $18-$100 at your store. +Do not make up any information about discount policies. What subproblems must be solved before answering the inquiry? ``` @@ -50,19 +63,34 @@ Let's try to solve the first subproblem: ``` CUSTOMER INQUIRY: -I just bought a T-shirt from your Arnold collection on March 1st. I saw that it was on discount, so bought a shirt that was originally $30, and got 40% off. I saw that you have a new discount for shirts at 50%. I'm wondering if I can return the shirt and have enough store credit to buy two of your shirts? +I just bought a T-shirt from your Arnold collection on March 1st. +I saw that it was on discount, so bought a shirt that was originally $30, and got 40% off. +I saw that you have a new discount for shirts at 50%. +I'm wondering if I can return the shirt and have enough store credit to buy two of your shirts? INSTRUCTIONS: -You are a customer service agent tasked with kindly responding to customer inquiries. Returns are allowed within 30 days. Today's date is March 29th. There is currently a 50% discount on all shirts. Shirt prices range from $18-$100 at your store. Do not make up any information about discount policies. -Determine if the customer is within the 30-day return window. Let's go step by step. +You are a customer service agent tasked with kindly responding to customer inquiries. +Returns are allowed within 30 days. +Today's date is March 29th. +There is currently a 50% discount on all shirts. +Shirt prices range from $18-$100 at your store. +Do not make up any information about discount policies. +Determine if the customer is within the 30-day return window. +Let's go step by step. ``` Output from the model would be: ``` -Yes, the customer is within the 30-day return window. The customer purchased the shirt on March 1st, and today's date is March 29th, which is within the 30-day return window. +Yes, the customer is within the 30-day return window. +The customer purchased the shirt on March 1st, and today's date is March 29th, which is within the 30-day return window. -Therefore, the customer is eligible to return the shirt and receive store credit for the purchase. The customer can use the store credit to purchase two shirts at the current 50% discount. +Therefore, the customer is eligible to return the shirt and receive store credit for the purchase. +The customer can use the store credit to purchase two shirts at the current 50% discount. ``` -By just solving the first subproblem, we were able to solve the entire problem. If GPT-3 did not return an answer immediately, we could have solved the next subproblem and so on until it did return an answer. Note that we use Let's go step by step.. The addition of this phrase is not always necessary, but it helps for this example. \ No newline at end of file +By just solving the first subproblem, we were able to solve the entire problem. If GPT-3 did not return an answer immediately, we could have solved the next subproblem and so on until it did return an answer. Note that we use Let's go step by step.. The addition of this phrase is not always necessary, but it helps for this example. + +Learn more from the following resources: + +- [@article@Least-to-Most Prompting](https://learnprompting.org/docs/intermediate/least_to_most) \ No newline at end of file diff --git a/src/data/roadmaps/prompt-engineering/content/102-prompts/prompting-techniques/105-dual-prompt.md b/src/data/roadmaps/prompt-engineering/content/102-prompts/prompting-techniques/105-dual-prompt.md index 4085b052cc54..1b3c33dc25f8 100644 --- a/src/data/roadmaps/prompt-engineering/content/102-prompts/prompting-techniques/105-dual-prompt.md +++ b/src/data/roadmaps/prompt-engineering/content/102-prompts/prompting-techniques/105-dual-prompt.md @@ -27,3 +27,8 @@ Or you could also combine these prompts into a single prompt as follows: ``` I am writing a guide about SEO. Take the 10 key topics about SEO and write a detailed introduction to each. ``` + +Learn more from the following resources: + +- [@article@Generated Knowledge in Prompts: Boosting AI Accuracy and Reliability](https://learnprompting.org/docs/intermediate/generated_knowledge#dual-prompt-approach) +- [@article@Recitation-augmented and Dual Prompting](https://aimlapi.com/academy-articles/recitation-augmented-and-dual-prompting) \ No newline at end of file diff --git a/src/data/roadmaps/prompt-engineering/content/102-prompts/prompting-techniques/106-combining-techniques.md b/src/data/roadmaps/prompt-engineering/content/102-prompts/prompting-techniques/106-combining-techniques.md index 457f0e50c0e7..4b318fdc33af 100644 --- a/src/data/roadmaps/prompt-engineering/content/102-prompts/prompting-techniques/106-combining-techniques.md +++ b/src/data/roadmaps/prompt-engineering/content/102-prompts/prompting-techniques/106-combining-techniques.md @@ -1,3 +1,11 @@ # Combining Techniques -All the techniques we've covered so far are useful on their own, but they're even more powerful when combined. For example, you can combine "Role Prompting" and any other prompting technique e.g. Chain of Thought, Dual Prompt, etc. to get more specific responses. \ No newline at end of file +All the techniques we've covered so far are useful on their own, but they're even more powerful when combined. For example, you can combine "Role Prompting" and any other prompting technique e.g. Chain of Thought, Dual Prompt, etc. to get more specific responses. + +Learn more from the following resources: + +- [@article@Combining Prompting Techniques: Enhance AI Outputs](https://learnprompting.org/docs/basics/combining_techniques) +- [@course@Combining prompting techniques - Hyperskill](https://hyperskill.org/learn/step/47989) +- [@guides@The Ultimate Guide to LLM Prompting, Fine-tuning, and Data Management ](https://medium.com/@subhraj07/the-ultimate-guide-to-llm-prompting-fine-tuning-and-data-management-933bbd2d05f4) +- [@video@4 Methods of Prompt Engineering - IBM](https://www.youtube.com/watch?v=1c9iyoVIwDs) +