Accessing locked lessons and answer keys
This course provides extra resources which are only available to verified teachers.

Customizing Language Models

This unit focuses on practical skills for tailoring AI models using techniques like prompt engineering and retrieval, while promoting transparency through model cards. Students explore how to customize AI chatbots to fit specific use-cases, then create their own chatbot to address a problem they care about.

Just Starting this Unit?

We recommend completing the free Exploring Generative AI Self-Paced Professional Learning Module. The module is designed to take 2-3 hours to complete. No previous computer science or AI experience is required.

We also recommend watching the 5-Part Exploring Generative AI Video Series which introduces key concepts for generative AI. The entire video series takes ~15 minutes to watch.

Finished Teaching This Unit?

Answer this short survey to let the Code.org curriculum team know how the unit went.

(Optional) Foundations in a Day
Lesson 1: (Optional) Introduction to Generative AI

This lesson introduces the learning goals focused on artificial intelligence (AI), transitioning into generative AI. It begins with a discussion on the impact of past technological innovations on society. Students then explore the concept of generative AI through the lens of someone familiar only with its hype, aiming to foster understanding and responsible engagement with AI technology. A key part of the lesson is the introduction of the Input, Storage, Processing, Output (ISPO) framework, essential for understanding generative AI's workings.

This lesson contains no levels.
Customizing Language Models
Lesson 2: Interacting with Language Models

In this lesson, students are presented an overview of the unit and explore the chatbot lab for the first time. Students begin by exploring a chatbot, using a model card to guide their understanding of its capabilities and limitations. Next they learn about the temperature setting in chatbots and how it influences the creativity and reliability of responses. Through hands-on experimentation, students will adjust the temperature to see its effect on the chatbot's answers. Finally, students explore how chatbots can hallucinate to produce incorrect or misleading information. Throughout the unit, students will monitor and document these instances, enhancing their critical awareness of AI's limitations.

Lesson 3: System Prompting - Exploration

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.

Lesson 4: System Prompting - Practice

This Practice lesson builds fluency in designing and applying system prompts, expanding the knowledge students developed in the previous lesson. Through examples and guided practice, students learn to craft prompts that guide not only the content but also the style and appropriateness of AI responses based on different audiences and situations. Students apply these skills through practice scenarios simulating real-life use cases and user-stories, emphasizing how problem-solving with system prompts can be applied to address real-world issues.

Lesson 5: System Prompting - Synthesis

This Synthesis lesson expands on the prompting techniques students have learned in the previous two lessons, and invites them to revisit and reflect on how their skills have grown. Students explore two advanced prompting techniques: (1) chain of reasoning, which helps chatbots deliver more precise and relevant responses by giving explicit steps, and (2) providing examples, which enhances the chatbot's accuracy and context appropriateness. After practicing these skills in specific contexts, students revisit and refine earlier lesson activities using the knowledge they’ve accumulated so far.

Lesson 6: Retrieval - Exploration

This Explore lesson introduces the concept of retrieval and guides students through an investigation on how it impacts a chatbot's behavior. Students start by predicting and discussing how retrieval 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 adding specific information to a chatbot’s knowledge base can significantly improve the accuracy and relevance of its responses. Students will practice adding retrieval information to elicit specific responses from the AI and engage in activities that incorporate personal experiences to see the effect of their retrieval on how the chatbot functions.

Lesson 7: Retrieval - Practice

This Practice lesson builds fluency in designing and applying retrieval statements, expanding the knowledge students developed in the previous lesson. Through examples and guided practice, students explore how retrieval can be used to provide current, specialized, and accurate information, helping to reduce the occurrence of AI hallucinations. Students apply these skills through practice scenarios simulating real-life use cases and user-stories, emphasizing the use of trusted real-world data sources (ie: copy-and-pasting accurate sentences) is an effective strategy to address real-world issues.

Lesson 8: Retrieval - Synthesis

This Synthesis lesson focuses on applying retrieval and system prompting to two complex user scenarios. Students begin by brainstorming and planning how to use these strategies to achieve user goals effectively. They will also explore methods for testing and evaluating chatbots to prevent potential harms. After planning, students will design chatbots tailored to each scenario, deciding strategically between using system prompts or retrieval. The lesson concludes with a reflection on the appropriate use of retrieval versus system prompting and revisits previous tasks, allowing students to apply their new insights to enhance their earlier work.

Lesson 9: Model Cards - Exploration

In this lesson, students are introduced to Model Cards and Foresight in AI charts as tools used to plan for how AI products are used. Students begin by reflecting on what materials are provided to users when we buy a new product, then explore how a Model Card serves a similar purpose for chatbots to clarify and caution how a particular chatbot product should and shouldn’t be used. Then, students explore an example of a Library chatbot and use a Foresight in AI table to examine the intended and unintended users and use-cases for this chatbot. After this example, students create their own model card for a fictitious chatbot, and then analyze each other’s model cards with a Foresight in AI chart.

This lesson contains no levels.
Lesson 10: Model Cards - Practice

In this lesson, students explore how to create model cards as they develop their chatbots. Students start by helping a friend design a chatbot to give more specific recommendations using a series of multiple-choice focus questions. Once these decisions are made, students document these decisions on the model card for the chatbot, emphasizing how a model card can also serve as documentation as you make decisions during chatbot development. After doing an example as a class, students choose a new scenario and repeat this process.

Lesson 11: Project: Create a Personal Chatbot

In this lesson, students create their project for the unit. In the project, students create a chatbot that represents their personality and is an expert on a specific interest they care about. Using their newfound knowledge from this unit, students apply techniques to adjust the temperature, system prompt, and retrieval settings of a chatbot. After testing their chatbot, they create a model card and “publish” it so other users can interact with it.

User-Centered Design
Lesson 12: Issue Statements

In this lesson, students explore a design thinking strategy to help identify core issues in their community and brainstorm ways generative AI can help solve them. Students start with an initial observation of a problem in their community, then use the 5 Why’s strategy to identify the larger core issue that could be addressed. Students then use model cards to brainstorm possible solutions, then discuss four possible solutions provided by other students. These activities act as a “practice run” for skills and processes students will do for their project later in the unit.

This lesson contains no levels.
Lesson 13: User Feedback

This lesson has two central parts - first students explore how to act as user testers for a chatbot app, then students help decide what the next-steps should be for a chatbot based on the testing data. This lesson builds to the project students will complete at the end of the unit, where they will user-test each other’s apps using the same structure in this lesson. Students also wrestle with the responsible use of AI and help decide whether or not a chatbot should be launched publicly even when some flaws are uncovered, emphasizing how humans remain decision-makers for how AI products impact society.

Lesson 14: Fine Tuning - Exploration

In this lesson, students are introduced to the process of fine-tuning as a process for altering the core behavior of a language model. The lesson starts with students reflecting on how inside jokes or slang expressions create connections that are difficult to explain to folks outside the group - they must be experienced to be understood. This idea ties into the lesson as we explore a new chatbot that has been specifically designed to act as a medical expert. Students observe how speaking to the medical expert chatbot is different from the typical chatbot due to how the both has been fine-tuned on additional medical data. Students learn about the fine-tuning process, then explore additional models on the Hugging Face website to see additional fine-tuned examples.

Lesson 15: Chatbots in Society

Students explore the impact of generative AI by participating in a collaborative game. Students take on a persona of someone impacted by generative AI to read a few articles and react in-character. Then, students form groups and are given a scenario involving their persona and generative AI. Working together, they come up with guidelines for how generative AI should be implemented in this scenario that includes the voices and perspectives of all stakeholders. Finally, students share their results with the class and reflect on this process.

This lesson contains no levels.
Lesson 16: Project: Solving Community Problems with Chatbots

In this lesson, students create their project for the unit. In the project, students create a chatbot that addresses a personally relevant issue or an issue in their community. Students rely on the user-centered design strategies they’ve seen throughout the unit to create issue statements, design a chatbot, perform user testing, and reflect on the results. Optionally, students can design a presentation on their project and the problem it was designed to address.

Level TypeLevel DetailsLevel Status
Not startedIn progress
Completed
Assessments / Surveys
Concept
Text
Video
Map
Concept: Not started
Concept: In progress
Concept: Completed (perfect)
N/A
Activity
Unplugged
Lesson Extras
Online
Assessment
Question
Choice level
Activity: Not started
Activity: In progress
Activity: Completed (perfect)
Activity: Submitted