![](https://cdn.prod.website-files.com/5eb1bc8b6f301d422630554a/66858b8eaa432408ddc9534e_Erin%20SucherOgrady%20Approved%20(1).jpg)
Strategy and Marketing Lead
Jul 2, 2024
The techniques used to prompt Generative AI models are evolving. A recent systematic survey published by the University of Maryland, "The Prompt Report: A Systematic Survey of Prompting Techniques," provides a comprehensive analysis of prompting methods and the terms used to describe them, offering valuable insights for developers and researchers.
This blog examines key prompting techniques outlined in the survey, emphasizing new learnings and practical examples.
In-Context Learning (ICL)
In-Context Learning (ICL) refers to the ability of generative AI models to learn tasks by providing them with relevant instructions or exemplars within the prompt, without requiring weight updates or retraining. This technique allows models to perform tasks they haven't explicitly been trained for, by leveraging context clues from the provided examples.
Examples:
- Few-Shot Prompting:
- Prompt: "Translate the following words from English to French. Word 1: dog, chien. Word 2: cat, chat. Word 3: bird, [Your Answer]."
- Explanation: Here, the model is given two examples (dog and cat) to learn the pattern and then asked to translate "bird."
- Example Generation:
- Prompt: "Solve the following math problems. Example 1: 2+2 = 4. Example 2: 3+5 = 8. Now, solve: 7+6 = [Your Answer]."
- Explanation: The model uses the provided examples to understand the task and generate the correct answer for the new problem.
Zero-Shot Prompting
Zero-Shot Prompting involves providing the model with a task to perform without any prior examples or context within the prompt. This technique relies on the model's pre-trained knowledge to generate responses.
Examples:
- Role Prompting:
- Prompt: "As a financial advisor, explain the importance of diversification in investment."
- Explanation: The model takes on the persona of a financial advisor to generate a relevant and contextually accurate explanation.
- Emotion Prompting:
- Prompt: "This is important for my career: [Your Answer]."
- Explanation: By adding an emotionally significant phrase, the model is guided to generate a response that reflects the importance of the statement.
Chain-of-Thought (CoT) Prompting
Chain-of-Thought (CoT) Prompting encourages the model to articulate its reasoning process before delivering a final answer. This technique is particularly effective for tasks requiring logical reasoning and step-by-step problem-solving.
Examples:
- Zero-Shot CoT:
- Prompt: "Jack has three baskets. Each basket contains four apples. How many apples does Jack have in total? Let's think step by step."
- Explanation: The model is prompted to break down the problem and explain each step, leading to a more accurate and reasoned final answer.
- Few-Shot CoT:
- Prompt: "Example 1: Q: Two trains leave the station at the same time. Train A travels at 60 mph, and Train B travels at 70 mph. After 2 hours, how far apart are they? A: Train A travels 120 miles (60 mph * 2 hours), and Train B travels 140 miles (70 mph * 2 hours). The distance between them is 140 - 120 = 20 miles. Now, solve this problem: Q: A car travels at 50 mph for 3 hours. How far does it travel? A: [Your Answer]"
- Explanation: By providing an example with a detailed reasoning process, the model can follow a similar thought process for the new problem.
Decomposition
Decomposition involves breaking down complex problems into simpler sub-questions, allowing the model to solve each part step-by-step before arriving at a final solution.
Examples:
- Least-to-Most Prompting:
- Prompt: "Let's break this problem into smaller parts. First, what is 5+3? Next, multiply the result by 2. Finally, subtract 4 from the product to get the final answer."
- Explanation: The model is guided to solve each sub-problem sequentially, leading to the final solution.
- Plan-and-Solve Prompting:
- Prompt: "First, understand the problem: Calculate the area of a rectangle with length 5 and width 3. Plan: Use the formula length * width. Solve: Area = 5 * 3. Therefore, the area is [Your Answer]."
- Explanation: By creating a plan and solving the problem step-by-step, the model generates a more accurate response.
Ensembling
Ensembling techniques involve using multiple prompts to solve the same problem and then aggregating the responses to improve accuracy. This method reduces variance and often leads to better overall performance.
Examples:
- Self-Consistency:
- Prompt: "Solve the following problem multiple times: What is 8+5? Answer: 13. Now, repeat the process and aggregate the answers to ensure consistency."
- Explanation: The model generates multiple responses and uses a majority vote to select the final answer.
- Demonstration Ensembling (DENSE):
- Prompt: "Here are different ways to solve the problem. Method 1: 8+5 = 13. Method 2: Start with 8, then add 5 in steps (8+2=10, 10+3=13). Method 3: Think of 8 and 5 as groups of objects and count them together. Aggregate these responses to confirm the final answer is [Your Answer]."
- Explanation: By providing multiple methods and aggregating the results, the model arrives at a more reliable final answer.
As the field of prompt engineering continues to evolve, staying informed about these advancements is crucial for anyone working with generative AI.
Understanding and applying these techniques can lead to more accurate and contextually relevant outputs, whether in research, industry, or everyday applications.
Not sure how to incorporate AI to increase accuracy and efficiency in your business? Contact us today!