< Customizing Language Models

Lesson 3: System Prompting - Exploration

45 minutes

Overview

This Explore lesson introduces the system prompt and guides students through an investigation on how it impacts a chatbot's behavior. Students start by predicting and discussing how a system prompt can impact a chatbot’s behavior, and then investigate and modify existing chatbots to confirm or expand their initial guesses. Through guided activities, they will learn how the design of a prompt can direct and limit chatbot interactions. Students will practice crafting prompts to elicit specific responses from the AI and engage in activities that incorporate personal experiences to see the effect of their prompt design on how the chatbot functions.

Agenda

Objectives

Students will be able to:
  • Explain how system prompts can influence the behavior of a chatbot
  • Modify system prompts to achieve desired chatbot responses

Preparation

  • Run through the slide deck and videos ahead of time
  • Review the Level Guide Exemplar
  • (Optional) Print out the slide deck with speaker notes as a resource during class. Click here for steps on how to do this.

Links

Heads Up! Please make a copy of any documents you plan to share with students.

For the teachers

Vocabulary

  • System Prompt - A set of instructions that changes the behavior of a language model. Effective system prompts adjust the role, tone, goal, and restrictions of a chatbot.

Teaching Guide

Warm Up (5 minutes)

Slide Lesson Guide
Discuss: Think of a time when the way you asked a question changed the answer you received, whether from a person or a digital assistant. How did the wording of your question influence the response?

Discussion Goal: This question encourages students to recognize the importance of phrasing in everyday communications and how this concept transfers to interactions with AI. For example, when being rude to someone in customer service resulted in them being rude back, or when creating a "compliment sandwich" resulted in a difficult conversation going smooth. The discussion aims to highlight the parallel between human communication and AI interaction, which will be explored in this lesson.
Say: In our interactions with humans, there are subtle tricks to influence conversations with how we phrase things or even small bits of body language. Today, we’ll explore how we can do something similar to chatbots.

Question of the Day: How can we influence how a chatbot behaves?

Activity (35 minutes)

Student Levels

Getting Familiar: These are the levels students will complete throughout the lesson. We recommend briefly exploring the levels yourself before reading the rest of the lesson plan. Some levels are meant to be completed independently by students, but others are meant to motivate class discussion or lead to moments of direct instruction in the slides. Very rarely should students be working through levels completely self-paced.

Teacher Exemplars: Verified teachers can access exemplar responses and "what success looks like" tips for each level in the Links section of the lesson plan. If the resource doesn't appear for you, you may need to become a verified teacher - learn more about this process here.

Teaching with Student Responses: Certain level types are designed to be leveraged with our Student Summary feature, specifically: Predict & Discuss and Mid-Lesson Check-In levels. You can read more about how to leverage student voices during these levels in the Teaching Guide - Incorporating Student Responses in Lessons

Teacher Guide

Teaching Tip

Teaching Tip: Predict & Discuss Levels - The first two levels in this lesson are predict and discuss levels, which are designed to facilitate a discussion led by the teacher. After students lock in their predictions, the teacher leads a discussion asking for students to share their observations and hypotheses. There are no right-or-wrong answers - they’re just predictions. The teacher should avoid validating any predictions - instead, as the lesson progresses, students will get the chance to investigate their hypotheses and see how well their predictions matched with reality. This means the most important part of these discussions are students feeling comfortable sharing their intuitions and forming opinion, and less about "right or wrong" answers. For more information about these levels, please read the Teaching Guide to Incorporating Student Responses in Lessons.

Slide Lesson Guide
Navigate: Go to Lesson 3 Level 1. In this Predict & Discuss level, students see a screenshot of a system prompt and are asked what they notice and what they wonder about the prompt.

Say: We’re going to start by looking at a new feature for our chatbots: a System Prompt. We’ll learn more about this as the lesson progresses, but for right now, I just want you to look at this and write down one thing you Notice and one thing you Wonder. There is no right or wrong answer here - it’s a deliberately open-ended question! You could say "I notice there are 3 sentences" and that would be a totally fine answer, although I hope folks notice some things that are more interesting.

Say: Once you type in your answer, press the Run button to lock it in. This will also change your screen to green. Once most people have their answers locked in, we’ll discuss as a class.

Circulate: Make sure students are answering the questions. If you plan to share student responses using one of the teaching strategies in the Guide to Incorporating Student Responses, then you should be monitoring responses via the Student Summary feature on this level.
Discuss: What do you notice? What do you wonder?

Ask a few students to share what they wrote in their level.

Discussion Goal: This is a purposefully low-floor, open-ended prompt designed to activate student thinking and pay explicit attention to this new feature. Some students may not really know how to respond and will say very obvious things - this is fine and can still be celebrated. Some students may use this as an opportunity to make some interesting observations, such as:
- There are two sections to the prompt. The top one sets a purpose, while the second one sets a restriction
- The prompt is written as if you are talking to the chatbot as if it is a person or entity
- Students may wonder what will really happen if they ask it questions not about Arizona, especially after the previous lesson about hallucinations and temperature.

As students share responses, encourage students to respond non-verbally if they had a similar thought (for example, by snapping their fingers or shaking their hands). After hearing from a few students, continue to the next slide.
Navigate: Go to Lesson 3 Level 2. In this Predict & Discuss level, students see a screenshot of a system prompt and are asked to make a prediction of what will happen.

Say: This is the same image from before, but this time I’m asking you to make a formal prediction - what do you think will happen when we interact with this chatbot? What’s a question you might try asking it, and what do you think the response will be?

Circulate: This question is all about students planting their feet and making a prediction that they can test in the next few levels. Make sure students come up with at least one question that they can test. If you plan to share student responses using one of the teaching strategies in the Guide to Incorporating Student Responses, then you should be monitoring responses via the Student Summary feature on this level.
Discuss: Try to predict how this chatbot will behave when you ask it questions. What's a question you might ask, and what answer would you expect?

Discussion Goal: There is still no right-or-wrong answer here, since students are just making predictions based on their intuition. What’s more important is that students lock-in an expectation that they can test in the next few levels. When listening to responses, try not to give anything away or validate responses as "on the right track" - letting students discover if their prediction is right-or-wrong in the next levels is an engagement strategy that hooks students into the lesson.

As students share responses, encourage students to respond non-verbally if they had a similar thought (for example, by snapping their fingers or shaking their hands). After hearing from a few students, continue to the next slide.
Navigate: Go to Lesson 3 Level 3. In this Investigate level, students can now interact with the chatbot they’ve seen screenshots of in the last few levels

Do This:
1) Investigate: Test the chatbot with at least 4 different messages
2) Discuss: What worked like you expected? What surprised you?

Students can complete this level with a neighbor and have the discussion as a small group rather than a full class.

Circulate: Listen for students comparing the results of their investigation to their predictions, or the predictions of classmates. If a student seems stuck, have them try the question they wrote in for Level 2 and see how it responds. Students can also try the example prompts provided in the instructions.
Navigate: Go to Lesson 3 Level 4. In this Investigate level, the system prompt has expanded to include additional instructions.

Do This: 1) Investigate: Test the chatbot with at least 4 different messages. You can use the same ones as before.
2) Discuss: How are the responses different? How do you think the new system prompt is updating the responses?

After students have experimented with the chatbot, regroup for a full class discussion.

Discussion Goal: This is an opportunity for students to unpack how well their predictions aligned with reality, possibly sharing how their hypotheses were updated once they had a chance to play with the chatbot. Students should notice that there are now four sections to this prompt each controlling an aspect of how the chatbot responds. They should notice some sentences affect the responses more than others depending on the questions being asked.
Say: We saw in the last lesson that language models have these additional settings, like temperature, that let us change how a model behaves.

Click the animation

Say: Another one of these settings is the System Prompt. This is a set of instructions we can provide to a language model to affect its behavior. It’s one of the most powerful settings we can change on a model!

Click the animation

Say: That’s because the system prompt is connected to the input layer of a language model. When we set a system prompt, we’re essentially making this the very first instruction that a model sees, which affects everything else that we type in to the model.
Teaching Tip

Teaching Tip: Reminder of the Input Layer - If students need a refresher on this diagram and the input layer of a language model, consider showing the Generative AI: Input & Pre-Training video

Say: The system prompt in this example highlights four areas where system prompts can the behavior of a chatbot:

Click the animation

Say: Role, Goal, Tone, and Restriction. In the next level, you can choose aspects of this prompt to modify to change some of these behaviors.
Navigate: Go to Lesson 3 Level 5. In this Modify level, students choose levels that modify the system prompt from the last level to change the behavior of the chatbot.

Do This:
1) Choose at least 2 levels to complete
2) Follow the instructions on each level

Circulate: Check in on students as they complete each level. Each level is designed so only one aspect of the prompt needs to be changed to complete the level, rather than generating an entirely new prompt on each level.
Teaching Tip

Teaching Tip: Exemplar Prompts - Verified teachers can access a resource on the lesson plan page that provides exemplar prompts that address each of the levels in this lesson. Consider reviewing these prompts or having them available for yourself during the lesson while circulating and checking with students. This resource also includes "teaching tips" for certain individual levels, which offers guidance and tips if a student is stuck on a particular level. This resource is only visible to verified teachers - click here to learn more about becoming a verified teacher.

Navigate: Go to Lesson 3 Level 6. This is a free response level where students answer a question checking-in on their understanding of system prompting.

Do This: Based on what you observed in the last few levels, answer the question on the level.
Assessment Opportunity

Assessment Opportunity: Formative Assessment - This is an open-ended question designed to let students share how they’re conceptualizing system prompts at this moment. Any response that connects the idea of role, goal, tone, and restriction to the scenario they envision is an appropriate response. It may be worth checking in with students who struggle to describe system prompts or struggle to describe how it can help solve a problem. Check the Generative AI - Teaching Guide for Student Responses for more information about how to use Code.org’s teacher dashboard to view this data and potentially differentiate your instruction with students.

Navigate: Go to Lesson 3 Level 7. In this Make level, students can choose different personal scenarios to focus on.

Do This:
1) Choose at least 2 levels to complete
2) Follow the instructions on each level

Circulate: Monitor students as they attempt these levels. Students will construct their system prompts from scratch in these levels, and some may struggle without a strong guide to start with. Encourage students to refer to the previous levels for examples, and also to iterate frequently with the system prompt. They can update the prompt and re-try chats as often as they would like as they hone-in on effective prompts.
Teaching Tip

Teaching Tip: What’s the trick? - As students struggle getting the chatbot to respond in a particular way, they may want to know the "trick" or "secret" to getting the chatbot to respond how they want. You can assure students that there is no trick, just a set of strategies that tend to work more often than others but are still unreliable. This is where the warm-up can be useful - strategies for talking to one person may not work with someone else, and it takes time to figure out the right way to "unlock" certain conversations. The same is true for system prompts, where the best way to get what you’re looking for is to just keep trying different phrases until it seems to work.

Wrap Up (5 minutes)

Slide Lesson Guide
Discuss: Reflect on these three prompts related to today:
1) What’s something you already knew about chatbots before class started?
2) What’s something you learned in class today about chatbots?
3) What’s something you still wonder about chatbots based on today’s class?

These could be discussed in small groups, but can also serve as an exit ticket or personal reflection that is checked after class.
Question of the Day: How can we influence how a chatbot behaves?
Vocabulary: The key vocabulary from this lesson is provided on this slide and in the lesson plan.

Pilot Feedback

Please let us know how this lesson went!

Creative Commons License (CC BY-NC-SA 4.0).

This work is available under a Creative Commons License (CC BY-NC-SA 4.0).

If you are interested in licensing Code.org materials for commercial purposes contact us.