Skip to content

Commit

Permalink
Improve Prompt Engineering - Prompts & Techniques - Links (#7653)
Browse files Browse the repository at this point in the history
* 📃 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 <[email protected]>

* 📃 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 <[email protected]>

* 📃 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 <[email protected]>

* 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 <[email protected]>

* 📃 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 <[email protected]>
  • Loading branch information
iPoetDev authored Nov 1, 2024
1 parent b9fdd0c commit a09704b
Show file tree
Hide file tree
Showing 9 changed files with 99 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
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)
Original file line number Diff line number Diff line change
@@ -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.
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)
Original file line number Diff line number Diff line change
Expand Up @@ -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?_
_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)
Original file line number Diff line number Diff line change
Expand Up @@ -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.
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)
Original file line number Diff line number Diff line change
Expand Up @@ -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.
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)
Original file line number Diff line number Diff line change
Expand Up @@ -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.
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)
Original file line number Diff line number Diff line change
Expand Up @@ -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?
```

Expand All @@ -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.
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)
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Original file line number Diff line number Diff line change
@@ -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.
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)

0 comments on commit a09704b

Please sign in to comment.