Get startedGet started for free

Few-shot prompting and conversation roles

1. Few-shot prompting and conversation roles

Hello, welcome to this video, where we show Claude new ways of generating content by showing, not telling.

2. Conversation roles with message format

Claude's message format lets us simulate realistic conversations. It’s similar to replaying a mini-chat: Claude sees both sides and answers as if it’s the next turn, which is perfect for coaching tone or behavior. In this example, we're showing Claude how to politely decline when it lacks information, so it will likely follow the same pattern for the traffic question.

3. Introduction to few shot prompting

With few-shot prompting, we teach Claude what we want by showing it examples rather than just describing it. We use user and assistant message pairs to demonstrate the exact behavior we're looking for. Claude spots the pattern and mirrors it on new input.

4. Understanding zero-shot vs few-shot vs one-shot

Let's run through all levels of prompting. Zero-shot means we give Claude a task with no examples - just a single prompt asking for what we want. One-shot provides a single example before our actual request. Few-shot gives multiple examples to establish a clear pattern. Generally, more examples lead to better consistency, though there's a point of diminishing returns.

5. Few-shot code example

Here we can see the three approaches in action with a translation task. Zero-shot just asks for the translation directly. One-shot provides a single example, 'Good morning' translating to 'Bonjour'. Few-shot uses multiple examples showing the pattern with 'Good morning' translating to 'Bonjour' and 'Thank you' to 'Merci', before making the real request.

6. Practical few shot applications

Few-shot prompting excels in several areas: format (showing the exact template—email, report, and so on), tone (supplying examples in the target voice), reasoning (walking Claude through multi-step logic), and domain know-how (providing specialized samples). In this example, we give Claude a few polished replies to late-delivery complaints. With these demos, Claude can handle the next case in the same concise and professional style.

7. Best practices for few-shot prompting

Let's wrap up with best practices for effective few-shot prompting. Generally, 2-5 examples work well for most tasks - more than that often doesn't provide additional benefit and uses up context space. The quality of our examples matters more than quantity - each should be a perfect demonstration of what we need. We should vary our examples to show the underlying pattern rather than just repeating the same scenario. Finally, it's important to test our few-shot prompts with edge cases to make sure Claude generalizes correctly and doesn't just memorize the specific examples we provided.

8. Let's practice!

Let's practice with some exercises that will help us master few-shot prompting and conversation roles!

Create Your Free Account

or

By continuing, you accept our Terms of Use, our Privacy Policy and that your data is stored in the USA.