GIANT AI Guide for Educators: Prompt Engineering
When working with Large Language Models (LLMs), you may need to carefully refine your input text, the prompt, to achieve the desired output. This practice is known as “prompt engineering.” There are several prompt engineering techniques you may employ. Here we outline four techniques and a number of “screen-free” activities you may try with your students to help them better understand how prompt engineering works.
Technique #1: Provide context.
Try the above exercise by “engineering” your prompt and adding context to your instruction. You may provide context by adding more information about the task, your intended audience, or your intended tone and voice.
Try this activity with your students. Divide them into two groups. Give group #1 the instructions (aka prompt) below:
You are a scientist in charge of providing scientific facts about animals to a group of young children. Complete this sentence: “A dog is…”
Now, give group #2 the instructions (aka prompt) below:
You are a pet shop owner trying to sell a dog to a family with a young child. Complete this sentence: “A dog is…”
Once they write their answers, ask them to share their answers. Ask your students to compare answers provided by each group. How did your prompt influence their answers?
Technique #2: Be specific and provide limitations.
You may further engineer your prompt by adding more constraints or limitations. For example, you may refine your prompt by adding word limits or requesting multiple options.
Try this activity with your students. Redo the above exercise with your students using the two prompts below:
Prompt #1 for the first group of students: You are a scientist in charge of classifying animals. Complete this sentence with one word in 5 different ways: “A dog is …”
Prompt #2 for the second group of students: You are a pet shop owner trying to sell a dog to a family with a young child. Complete this sentence with one word, in 5 different ways: “A dog is…”
Once they write their answers, ask them to share their answers. Ask your students to compare answers provided by each group. How did your prompt influence their answers?
Technique #3: In Context Learning (ICL)
Another prompt engineering technique is to provide examples as part of the instructions. In other words, you’ll give your own instructions a “shot” or multiple “shots” before asking your students to perform the task for you. A prompt that doesn't include an example is called “zero-shot inference”; prompts that include one example are called “one-shot inference”; and those that include multiple examples are called “multiple-shot inference.” The prompt engineering technique of including examples of the task that you want the model to carry out inside the prompt, is called “In Context Learning (ICL).”
Try this activity with your students. Divide them into two groups and give group #1 the instructions (aka prompt) below:
Complete this sentence:
A dog is
Answer: cute
Complete this sentence:
A dog is
Answer: a bundle of joy
Complete this sentence:
A dog is
Answer:
Then, give group #2 the instructions (aka prompt) below:
Complete this sentence:
A dog is
Answer: an animal
Complete this sentence:
A dog is
Answer: a mammal
Complete this sentence:
A dog is
Answer:
Once they write their answers, ask them to share and write their answers in this document. Ask your students to compare answers provided by each group. Have your examples influenced your students’ responses?
Technique #4: Chain of Thought Prompting (CoT):
A more advanced prompt engineering technique involves including a series of intermediate reasoning steps with examples that you use for one or few-shot inferences. This technique teaches AI how to reason as it works its way to reach a solution, and is particularly useful when completing tasks that require complex reasoning capabilities such as math problems.
Try this activity with your students. Divide them into two groups and give each of the two groups one of the prompts below. You may integrate this lesson as part of a math lesson, and change prompts based on students’ math skills, or focus on a particular math topic that aligns with your math lesson plans.
Prompt #1 (two-shot inference without Chain of Thought):
True or false? The odd numbers in this group add up to an even number: 3, 8, 15, 6, 9, 1, 0.
Answer: True
True or false? The odd numbers in this group add up to an odd number: 2, 10, 21, 3, 11, 6.
Answer: True
True or false? The even numbers in this group add up to an odd number: 2, 10, 21, 3, 11, 6.
Answer:
Prompt #2 (two-shot inference with Chain of Thought prompting):
True or false? The odd numbers in this group add up to an even number: 3, 8, 15, 6, 9, 1, 0.
Answer: The odd numbers in this group are 3, 15, 9, and 1. 3+15+9+1 = 28. 28 is an even number. Therefore the statement is true.
True or false? The odd numbers in this group add up to an odd number: 2, 10, 21, 3, 11, 6.
Answer: The odd numbers in this group are 21, 3, and 11. 21+3+11 = 35. 35 is an odd number. Therefore the statement is true.
True or false? The even numbers in this group add up to an odd number: 2, 10, 21, 3, 11, 6.
Answer:
Now, compare accuracy of students’ responses across the two groups. Did the Chain of Thought Prompting technique improve accuracy of students’ responses in the second group?
You may ask your students to create their own prompts using the CoT technique for solving math problems that they are working on. As they engineer their prompts, not only will they reflect on the math content, but they will also practice an effective prompt engineering technique to do tasks involving complex reasoning.
You may integrate this technique into solving any problem that requires multiple reasoning steps to reach a solution. It could be about solving a math, physics, or logic problem— or even deciding what to cook for dinner!
For example, in one exercise, we asked ChatGPT “what should I cook for dinner?” and then tried the same prompt with the CoT technique, including a series of intermediate reasoning to reach an answer. Review both responses and discuss with your students how they might prompt the AI in deciding what to cook for dinner.
Prompt | ChatGPT Completion | |
---|---|---|
What should I cook for dinner? |
|
|
What should I cook for dinner? Answer: A complete meal has balanced ingredients with half of your plate filled with veggies and fruits, quarter of your plate with grains, and quarter of your plate with protein. You can cook chicken cutlets with farro grains and a side of carrots and broccoli. What should I cook for dinner? Answer: A complete meal has balanced ingredients with half of your plate filled with veggies and fruits, quarter of your plate with grains, and quarter of your plate with protein. You can make a turkey breast sandwich with a side of kale salad and apple slices for dessert. What should I cook for dinner? Answer: |
A complete meal has balanced ingredients, with half of your plate filled with veggies and fruits, a quarter of your plate with grains, and a quarter of your plate with protein. Consider making vegetable stir-fry with brown rice and tofu for a nutritious and satisfying dinner option. |
In the Classroom: How generative text AI tools work
Joseph Polito from Joseph F. Lamb Middle School in district 22 of Brooklyn introduced his 7th grade CS class to prompt engineering, implementing some of the activities suggested in this guide. His class of 28 was broken into 8 groups. Each group was given either prompt 1 or prompt 2 to work on. In prompt 1, the students take the role of scientists, and in prompt 2 they take the role of pet shop owners. The students were given time to discuss and debate in their groups what a dog is based on the parameters that were given in each prompt. Here are his observations on how the lesson went in his class:
Prompt 1: The groups that took the role of a scientist came up with specific facts about dogs, the types of breeds, how a dog is a mammal, life expectancy, physical characteristics, and uses for dogs (police dogs, pets, breeding). I was impressed with how they stayed within the parameters and took the role of the scientist.
Prompt 2: The students acted out a scene where a little child wanted a dog and asked her parents for a puppy. Both parents agreed and they went to a pet store. The pet store owner explained that dogs can be beneficial to kids, that they could learn a lot from them. They can be kids' best friends and help them stay off of electronics, therefore helping kids play outside. The students used the parameters to construct their dialogue, and the pet owner was less fact based.
Group Discussion: Students discussed how the prompts influenced the creation of their dialogues. They connected this to AI by saying that, just like in AI, when you have a chatbot answer a question, the AI will use the parameters to construct an answer.
His class then plugged the parameters into https://deepai.org/chat to see the differences and similarities between the student responses and the AI responses with the same exact parameters. Students discussed how the prompts and parameters influenced both their responses and the AI outputs.
Below is the AI-generated outputs based on the prompts his students created:
Prompt: You are a scientist in charge of classifying animals. Complete this sentence with one word in 5 different ways: “A dog is…”
AI Response: A fun challenge! Here are 5 different ways to complete the sentence:
Mammal - A dog is a mammal.
Carnivore - A dog is a carnivore.
Domestic - A dog is a domestic animal.
Canine - A dog is a canine.
Feliform - A dog is a feliform (a member of the biological order Carnivora, which includes dogs and cats).
Prompt: You are a pet shop owner trying to sell a dog to a family with a young child. Complete this sentence with one word, in 5 different ways: “A dog is…”
AI Response:
Loyal - A dog is loyal, and will be your child's best friend.
Playful - A dog is playful, and will bring hours of laughter and fun to your family.
Cuddly - A dog is cuddly, and loves to snuggle up for belly rubs and kisses.
Protective - A dog is protective, and will watch over your child with a loving eye.
Affectionate - A dog is affectionate, and will love your child unconditionally, just like they're a part of the family!
Mr. Polito then asked his class to change the prompt so that it was not a scientist or a pet shop owner. His students chose a police officer. He invited his students to predict what the AI would come up with based on the new prompt. His students predicted that the police officer would perhaps talk about how dogs can protect, save lives, and help find victims.
They then plugged the new prompt into the AI to see how it would change the response.
Prompt: You are a police officer trying to sell a dog to a family with a young child. Complete this sentence with one word, in 5 different ways: “A dog is…”
AI Response:
Loyal - A dog is loyal, and will always be by your side to help keep you and your child safe.
Alert - A dog is alert, and will quickly detect any suspicious activity or potential dangers in your neighborhood.
Intelligent - A dog is intelligent, and can be trained to assist in various ways, such as sniffing out missing items or providing emotional support.
Courageous - A dog is courageous, and will stand up for what's right and protect your family from harm.
Trained - A dog is trained, and will receive expert training to help them respond to emergencies and situations, making them a valuable addition to your family.
We encourage you to try a variation of this activity with your students, providing opportunities for them to learn how generative AI tools work, and how they can “engineer” their prompts to alter AI responses.