Skip to main content

Welcome to a Grasp lesson

Create a free account to keep studying and create your own study path.

Lesson 3

Few-Shot Prompting for Controlled Responses

Recommended resources

In our last lesson, we established the foundational skill of zero-shot prompting—giving Claude clear, direct instructions to perform a task. This is the art of telling the AI what to do. Now, we'll build on that by learning how to show the AI what you want.

This lesson introduces few-shot prompting, a powerful technique for controlling the specific style, format, and tone of Claude's output. Instead of merely describing your desired result, you will provide concrete examples to guide the model. For your work in consulting, where maintaining a consistent voice and adhering to structured reporting formats is crucial, this skill moves you from getting acceptable results to getting precisely the results you need, every time.

1. From Telling to Showing: The Power of Examples

In the previous lesson, we saw that a detailed zero-shot prompt can produce good results for common tasks. However, when you need a very specific or nuanced output—like matching your firm's unique communication style or formatting data in a non-standard way—instructions alone can be ambiguous. The model is left to guess what you mean by "professional tone" or "structured summary."

Few-shot prompting eliminates this guesswork. By providing 2-5 high-quality examples of the input-to-output transformation you want, you are effectively training the model on the fly for your specific task.

The following guide provides an excellent, intuitive breakdown of this concept.

Zero-Shot, One-Shot, and Few-Shot Prompting Explained: The 3 Patterns Every AI User Needs [Prompt Engineering Course Lesson 3]

This article from Gen AI Unplugged clearly defines and contrasts zero-shot, one-shot, and few-shot prompting.

Please read the introduction, the definition of few-shot prompting, and the Quick Comparison and Teacher Analogy sections. Pay close attention to the analogy about teaching students to write subject lines; it perfectly illustrates why showing examples is often more effective than giving abstract instructions.

As the article explains, few-shot prompting is your go-to method for specialized tasks, enforcing a brand voice, or teaching the AI complex patterns. You're moving from being a manager who gives instructions to a mentor who provides a clear template for success.


2. Crafting an Effective Few-Shot Prompt

A few-shot prompt's effectiveness depends entirely on the quality and structure of the examples you provide. This technique is not about quantity; it's about clarity and consistency.

The Core Structure

The basic format is simple: you provide a series of "demonstrations" before making your actual request. Each demonstration consists of a sample input and its corresponding ideal output.

This powerful idea is highlighted in another guide, which calls few-shot prompting the single most important basic technique.

Complete LLM Prompting Mastery Guide | Claude

This guide, based on a podcast with a prompt engineering expert, frames few-shot prompting as the cornerstone of effective AI interaction.

Read the section 1. Few-Shot Prompting. The 'BEFORE' and 'AFTER' examples for email writing and customer support vividly demonstrate how concrete examples outperform vague descriptions. Notice the simple Q: and A: or Customer: and Response: structure used to format the examples.

The key is to create a clear, repeatable pattern that Claude can identify and replicate. This leads us to some best practices for selecting your examples.

Zero-Shot, One-Shot, and Few-Shot Prompting Explained: The 3 Patterns Every AI User Needs [Prompt Engineering Course Lesson 3]

We return to the Gen AI Unplugged article for tactical advice on building your prompt.

Focus on two key sections: How Many Examples Do You Need? This section provides a simple rule of thumb: start with two and add more only if needed. How to Write Few-Shot Prompts That Actually Work. This part gives three critical rules for selecting good examples: ensure they are diverse, high-quality, and match your desired output length.

To summarize the rules for creating powerful few-shot prompts:

  • Start with 2-3 examples. This is usually the sweet spot for teaching a pattern without consuming too much of the context window.
  • Use diverse but principled examples. Your examples should showcase different inputs but all resolve to outputs that follow the same underlying structure and style.
  • Use realistic, high-quality content. Your examples are the benchmark. If they are lazy or poorly written, the AI's output will be too.
  • Match the length and format. The AI will infer the desired length and structure from your examples. If you want a one-sentence output, provide one-sentence examples.

The following image shows how "Examples" fit within a comprehensive prompt structure, reinforcing that they are a key component alongside the task description, rules, and formatting instructions.

This diagram shows the ten key components of a well-structured prompt, with 'Examples' listed as a central element for guiding the AI's response.

3. A Practical Consulting Use Case: Standardizing Meeting Summaries

Let's apply this to a common consulting task: distilling unstructured meeting notes into a standardized summary for stakeholders. Your goal is to extract key decisions and action items and present them in a clean, consistent format.

Attempt 1: Zero-Shot Prompt

Let's say we have the following meeting notes:
"Okay team, quick debrief on Project Alpha. Mike said the user interviews are done, results were mixed. Some users love the new dashboard, others are confused by the navigation. Sarah mentioned the timeline for Q3 is looking tight, especially with the marketing launch dependency. We decided to push the go-live by one week to be safe. John needs to confirm the new launch date with the client. And Sarah, can you please update the project plan? Let's circle back next week."

A zero-shot prompt might be:

Summarize the key decisions and action items from the meeting notes above.

Claude might produce something decent, but potentially unstructured:

The main decision was to delay the Project Alpha go-live date by one week. The action items are for John to confirm this new date with the client and for Sarah to update the project plan accordingly.

This is correct, but it doesn't follow a specific format that you could reliably use across dozens of projects.

Attempt 2: Few-Shot Prompt

Now, let's enforce a specific format using few-shot prompting. We'll provide two examples of notes and their ideal outputs before giving Claude our new notes.

Here is the complete prompt you would use:

You are a senior project manager responsible for creating concise meeting summaries. Your task is to extract Key Decisions and Action Items from raw meeting notes and format them as shown in the examples.

Example 1:
Input: "Met with the tech team. The API integration is failing on the staging server. We think it's a credential issue. Decided to roll back the deployment for now. Alex will investigate the server logs and report back by EOD. Maria will notify the QA team about the rollback."
Output:
Key Decisions:

  • Roll back the recent API deployment from the staging server.
    Action Items:
  • Investigate server logs for credential issue. (Owner: Alex, Due: EOD)
  • Notify QA team of the deployment rollback. (Owner: Maria, Due: Today)

Example 2:
Input: "Client call was good. They love the mockups. They did ask if we could add a data export feature. We agreed it's a good idea but will need to scope it for Phase 2. For now, we are approved to proceed with the current designs. I need to send them the final SOW for signature."
Output:
Key Decisions:

  • Client has approved the current design mockups.
  • The data export feature will be scoped for Phase 2, not current implementation.
    Action Items:
  • Send the final Statement of Work (SOW) to the client for signature. (Owner: Me, Due: ASAP)

New Task:
Input: "Okay team, quick debrief on Project Alpha. Mike said the user interviews are done, results were mixed. Some users love the new dashboard, others are confused by the navigation. Sarah mentioned the timeline for Q3 is looking tight, especially with the marketing launch dependency. We decided to push the go-live by one week to be safe. John needs to confirm the new launch date with the client. And Sarah, can you please update the project plan? Let's circle back next week."
Output:

By providing these examples, you've shown Claude the exact structure (Key Decisions:, Action Items:), formatting (bullet points), and level of detail (including owners and due dates where possible) you require. The model will now generate an output that precisely matches this pattern for the new task.

The result is moving your prompt from potentially "too vague" to "just right," as illustrated below. The examples provide the necessary calibration.

This image contrasts 'Too specific', 'Just right', and 'Too vague' prompts. Few-shot examples are a key tool to move a prompt from the 'Too vague' end of the spectrum to the 'Just right' sweet spot.

Conclusion

In this lesson, you've added a crucial technique to your prompt engineering toolkit. You've seen how to move beyond simply telling an AI what to do and instead show it what excellence looks like.

Key Takeaways:

  • Few-shot prompting uses examples to guide the AI, making it ideal for tasks requiring specific styles, formats, or nuanced understanding.
  • "Show, don't just tell" is the guiding principle. Concrete examples are less ambiguous than abstract descriptions.
  • The quality of your examples is paramount. Use 2-3 diverse, realistic, and well-structured examples to teach the model the desired input-output pattern.
  • This technique is foundational for creating reliable, repeatable, and high-quality outputs, a necessity for professional workflows in fields like consulting.

You are now equipped to control not just what Claude does, but how it does it. In our next lesson, we will explore chain-of-thought prompting. This technique focuses on guiding the AI's reasoning process, teaching it to "think step-by-step" to solve complex, multi-stage problems.