In this lesson, you’ll continue learning about prompts and how to write the best prompt you can to get the desired output — often referred to as “prompt engineering.” As a part of this exploration, you’ll also practice using shots, or examples included in a prompt, as well as ways to troubleshoot when an output doesn’t meet expectations.
Engineer prompts for success
Previously, you learned about the five “parts” of prompt-writing:
-
Persona: Identify your role.
-
Aim: State your objective.
-
Recipients: Specify the audience.
-
Theme: Describe the style, tone, and any related parameters.
-
Structure: Note the desired format of the output.
A popular approach to prompt engineering involves including examples in the prompts, often called “shots.” Shots help AI tools better understand the expected output. Prompts are organized by how many examples they contain: zero, one, or a few. Additionally, there is chain-of-thought (COT) prompting, where a tool is explicitly told to think step-by-step. Check each tab to learn more!
Zero-shot prompting
Zero-shot prompts don’t include any examples about the desired output.
Zero-shot prompting works best when asking for simple, direct responses. This can be a useful way to brainstorm or get general inspiration from AI. An input might be:
Prompt:
I am a middle school theater teacher. I need to promote auditions for our winter play to incoming 6th-graders. Generate eye-catching fliers with no more than 25 words that can be put up around school. |
Or
Prompt:
Generate a packing list for a two-night summer camping trip at a lakeshore with four adults and three kids. |
These prompts can be classified as zero-shot prompts because they do not provide any examples of the desired output. While they are descriptive and informative prompts, they do not provide any examples.
One-shot prompting
One-shot prompts include one example of the desired input and output.
One-shot prompting can be a useful way to refine a response more than a zero-shot prompt. This can help steer the LLM in the right direction, especially if the task requires a specific format or style. A one-shot prompt could be:
Prompt:
I am a high school reading specialist. Provide ways that I can motivate and engage struggling readers in my classroom. As an example: High-Interest Texts: [Select reading materials that align with students’ interests, cultures, and backgrounds.] |
This prompt can be classified as a one-shot prompt because it provides one example of the desired output. In this case, the example is a High-Interest Text. In this prompt, you’d provide an example of a reading material that aligns with your students’ interests, cultures, and backgrounds.
Or
Prompt:
I am a sixth-grade math teacher. Create 1 fun and realistic word problem for 11-year-old students. The word problem must multiply 2-digit numbers and 3-digit numbers together, for example: 24 x 322 or 14 x 556. |
This prompt can be classified as a one-shot prompt because it provides one example of the desired output. In this case, the example is a multiplication equation with the desired format and requested number of digits.
Few-shot prompting
Few-shot prompts include two or more examples of the desired input and output.
The examples improve the tool’s performance by providing additional context. This is particularly useful for complex tasks where a single example might not be enough. The extra examples help the LLM grasp the desired outcome and respond accordingly. Few-shot prompting is useful for getting back specific formatting or details in the output. For instance:
Prompt:
I am an environmental science teacher planning tasks for a field trip to a watershed. Help me plan tasks for the field trip. Example tasks:
|
This prompt can be classified as a few-shot prompt because it includes two examples of the desired output. The “Watershed selfie” and “Water sampling” tasks both describe the type of activity and description length desired in the output.
COT prompting
COT prompts ask the AI tool to follow your chain-of-thought. That means you’ll prompt the AI tool to think step-by-step. This is useful for reasoning tasks or exploratory analysis. A COT prompt might state:
Prompt:
I am a high school teacher. Some of my students struggle with time management. What are five strategies I can use in my classroom to help them? Think this through step-by-step. |
This prompt can be classified as a COT prompt because it explicitly asks the AI tool to think step-by-step. While the prompt asks for five strategies, it doesn’t provide any examples. Although it doesn’t provide any examples, the prompt is not classified as a zero-shot prompt because it asks the AI tool to think step-by-step.
Prompt engineering is often an iterative process. Sometimes, even when you provide clear and specific instructions, you may not get the output you want on your first try. When this happens, simply revise your prompt to improve the output. Here is a list of potential issues that might affect your output and tips for how to address them:
Each AI model is developed with unique training data and programming techniques, and each has different background knowledge about specific domains. This means models sometimes respond to similar prompts in different ways and might fail to provide an adequate response to some prompts. Taking an iterative approach will produce the best results.
Ask key questions:
As you know, it’s essential to critically evaluate outputs. Remember the questions to ask yourself:
-
Is the output accurate?
-
Is the output unbiased?
-
Does the output include sufficient information?
-
Is the output relevant to my project or task?
-
Is the output consistent if I use the same prompt multiple times?
Provide Context:
Consider the earlier example about asking for restaurant recommendations from an AI tool: Because the context about needing vegetarian options wasn’t included, the tool was unlikely to deliver useful recommendations. If your output isn’t specific enough or doesn’t meet your needs, consider what supporting information the tool could use to produce better results.
Using examples, or “shots”
Including examples to clarify the input and output of your prompt can help fine-tune the output and get you closer to what you need.