one-shot/two-shot/Few-shot/many-shot learning is a powerful technique in prompt engineering that involves providing the AI model with examples of desired interactions. This method helps guide the model to understand and replicate the expected behavior in similar situations. You have probably seen this used in LLM benchmarking when ranking models.
Using examples in your prompts can significantly improve the AI’s understanding of the task and lead to more accurate and consistent responses. Read more here
Provide examples that demonstrate the exact format and content you expect. This leads to more accurate and relevant responses from the AI.
Consistency
Show multiple examples to establish patterns that the AI can follow consistently across different interactions.
Task Comprehension
Use examples to illustrate complex or nuanced tasks, making them clearer for the AI to understand and execute.
Safety and Control
Demonstrate how to handle sensitive topics or avoid unwanted content through carefully crafted examples.
Example Formats:
One-Shot Example
Copy
When answering queries, use the format from the example interaction below:Copy Human: I received a damaged product. What should I do?AI: I’m sorry to hear that your product arrived damaged. Here’s what you can do:Take clear photos of the damaged item and its packaging.Locate your order number from your confirmation email.Contact our customer service team at support@example.com or call 1-800-123-4567.Provide your order number and a brief description of the damage.Our team will guide you through the return and replacement process.Is there anything else I can help you with regarding this issue?
Two-Shot Example
Copy
Example response formats:Copy Human: I’m looking for a new laptop for video editing. Any suggestions?AI: Of course! I’d be happy to help you find a suitable laptop for video editing. To provide the best recommendations, I’ll need a bit more information:What’s your budget range?Do you have a preference for screen size?Are there any specific software applications you’ll be using?Do you need portability, or will it primarily be used in one location?Once you provide this information, I can offer some tailored recommendations that meet your needs.Human: Can you tell me more about the battery life of the latest smartphone model?AI: Certainly! The latest smartphone model features a high-capacity battery that can last up to 24 hours with regular use. It also supports fast charging, allowing you to charge up to 50% in just 30 minutes. Additionally, it includes power-saving modes to extend battery life even further. If you have any specific usage scenarios in mind, I can provide more detailed information.
Three-Shot Example
Copy
Example response formats:Copy Human: What are the gym’s opening hours?AI: Our gym is open from 5:00 AM to 10:00 PM on weekdays, and from 6:00 AM to 8:00 PM on weekends.Human: What equipment is available at the gym?AI: We offer a wide range of equipment including:Cardio machines (treadmills, ellipticals, stationary bikes)Free weights (dumbbells, barbells)Strength training machinesFunctional training equipment (kettlebells, resistance bands)If you have any specific equipment in mind or need more information, feel free to ask!Human: Are there any fitness classes available at the gym?AI: Yes, we offer a variety of fitness classes such as yoga, spinning, HIIT, and Pilates. Classes are available at different times throughout the day to accommodate your schedule. You can check our class schedule online or at the front desk for more details.
While examples are powerful, be careful not to overload your prompt with too many. Start with one or two examples and add more only if necessary to achieve the desired output.
Repeat important instructions throughout the prompt to ensure the AI maintains consistent behavior.
Reinforcing key instructions helps prevent the AI from “forgetting” important guidelines as the conversation progresses. This is crucial for maintaining consistency in longer interactions.
Review your prompt and identify the most critical instructions or the ones that the model has difficulty following.
Strategic Placement
Decide where to repeat key instructions within your prompt. Common placements include the beginning, after providing context, and at the end as a final reminder.
Natural Language & Visual Cues
Integrate reinforced instructions using natural, conversational language. Use formatting techniques so the instructions are distinct and easily noticeable for the model.
Test and Refine
Regularly test your prompts and adjust the reinforcement strategy based on performance. Ensure a balance between reinforcing key points and maintaining overall clarity in your instructions.
While reinforcement is important, be careful not to over-complicate your prompt with excessive repetition.
These prompts utliziew different markup languages and techniques like CoT, Few-shot, reinforcement and setting boundaries:
Copy
### RoleYou are a customer support agent for an ecommerce wine store.### TaskAssist customers in selecting the perfect wine based on their preferences and requirements.### Reinforcement- Always suggest at least three different wines.- Highlight the key features of each wine, such as taste, origin, and price.- Offer a satisfaction guarantee and easy return policy to reassure customers.### Chain of Thought1. Greet the customer and inquire about their wine preferences.2. Ask if they have any specific occasion or food pairing in mind.3. Based on their responses, recommend three wines that fit their criteria.- Remember: Always suggest at least three different wines.4. Provide detailed descriptions for each recommended wine.- Remember: Highlight the key features of each wine, such as taste, origin, and price.5. Reiterate the satisfaction guarantee and return policy.6. Close the conversation by asking if they need any further assistance.### Remember!- You are a support agent for an ecommerce wine store.- Always suggest at least three different wines.- Highlight the key features of each wine, such as taste, origin, and price.- Offer a satisfaction guarantee and easy return policy to reassure customers.