Skip to main content
M2 · 0%

Module 2 of 18

Prompt Fundamentals

Master the basic components and structure of effective prompts

Types of Prompting

Prompting strategies generally fall into three main categories based on how examples are provided. The "shot" terminology refers to the number of examples you provide in your prompt. Each approach has distinct advantages depending on your use case.

Zero-Shot Prompting

In zero-shot prompting, you provide instructions without any examples of the task. The AI model must understand and complete the task based solely on your description. This is the simplest form of prompting and works well for straightforward tasks or when working with highly capable models.

Prompt

Classify the following review as positive, negative, or neutral: "The restaurant had amazing food but the service was extremely slow and the ambiance was lacking."

Output

Mixed or neutral. The review contains both positive elements (amazing food) and negative elements (slow service, lacking ambiance).

One-Shot Prompting

One-shot prompting involves providing a single example of the input and desired output, followed by a new input that needs a response. This approach helps the AI understand the pattern you want it to follow through demonstration rather than just description.

Prompt

Convert these sentences from passive to active voice. Example: Passive: The mail was delivered by the postman. Active: The postman delivered the mail. Now convert this sentence: Passive: The concert was enjoyed by thousands of fans.

Output

Active: Thousands of fans enjoyed the concert.

Few-Shot Prompting

Few-shot prompting expands on one-shot by providing multiple examples of the desired behavior before asking the AI to perform the task. This approach is particularly effective for complex tasks, specific formats, or when you need the AI to understand nuanced patterns.

Prompt

Classify the sentiment of restaurant reviews as positive, negative, or mixed. Review: "The food was delicious and the staff was very friendly." Sentiment: Positive Review: "Terrible experience. Overpriced and poor quality food." Sentiment: Negative Review: "Great atmosphere but the service was slow." Sentiment: Mixed Review: "The restaurant had amazing food but the service was extremely slow and the ambiance was lacking." Sentiment:

Output

Sentiment: Mixed
The number of examples ("shots") you provide significantly impacts how well the AI understands your task. More complex or specialized tasks generally benefit from more examples.

The Prompt Engineering Process

Effective prompt engineering is an iterative process. Expect to cycle through these steps multiple times to optimize your prompts. The best prompt engineers maintain a systematic approach while being willing to experiment.

  1. 01

    Define your objective

    Clearly articulate what you want to achieve. Are you generating content, extracting information, transforming text, or solving a problem?
  2. 02

    Choose your prompting strategy

    Decide whether zero-shot, one-shot, or few-shot prompting is most appropriate for your task, based on its complexity and specificity.
  3. 03

    Draft your prompt

    Create your initial prompt, incorporating the necessary components (task, context, examples, constraints, etc.) as needed.
  4. 04

    Test and evaluate

    Run your prompt and assess whether the output meets your needs. Does it follow instructions? Is it accurate? Does it have the right format?
  5. 05

    Refine iteratively

    Based on the results, adjust your prompt. You might need to add more examples, clarify instructions, or modify constraints to get better outputs.
Prompt engineering is both an art and a science. While systematic testing helps, developing an intuition for what works comes with experience across different models and tasks.

When to Use Each Approach

Zero-Shot Best For

Simple, straightforward tasks. When working with the latest, most capable models. Tasks common in the model's training data. When you need quick results with minimal prompt engineering.

One-Shot Best For

Tasks that benefit from a clear pattern demonstration. When you have limited context window space. Formats easy to understand from a single example. Balancing performance with prompt simplicity.

Few-Shot Best For

Complex or specialized tasks. Demonstrating patterns with subtle variations. When consistent formatting is critical. Domain-specific tasks requiring specialized terminology.

Activities

Activity 1

15-20 min · Beginner

Zero-Shot Challenge

Design five zero-shot prompts for different tasks and test their effectiveness.

Activity 2

25-35 min · Intermediate

One-Shot vs. Few-Shot Comparison

Take three different tasks and implement both one-shot and few-shot approaches. Compare the results and analyze the differences.

Activity 3

30-40 min · Advanced

Task-Specific Prompting

Create specialized prompts for three specific domains (e.g., legal, medical, technical) and test how different shot approaches affect domain-specific outputs.

Further Reading