Notebooks
G
Google Gemini
Get Started LearnLM

Get Started LearnLM

quickstartsgemini-cookbookgemini-apigemini
Copyright 2025 Google LLC.
[1]

Guide: Building AI Tutors with LearnLM via System Instructions

This notebook demonstrates how to leverage LearnLM, an experimental task-specific model trained to align with learning science principles, to create various AI tutoring experiences. The key to directing LearnLM's capabilities lies in crafting effective system instructions for teaching and learning use cases.

LearnLM is designed to facilitate behaviors like:

  • Inspiring active learning
  • Managing cognitive load
  • Adapting to the learner
  • Stimulating curiosity
  • Deepening metacognition

This guide demonstrates these principles by illustrating how system instructions and user prompts enable LearnLM to act as different types of tutors.

andycandy's GitHub avatar

This notebook was contributed by Anand Roy.

LinkedIn - See Anand other notebooks here.

Have a cool Gemini example? Feel free to share it too!

[2]
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 199.5/199.5 kB 6.6 MB/s eta 0:00:00

Set up your API key

To run the following cell, your API key must be stored it in a Colab Secret named GOOGLE_API_KEY. If you don't already have an API key, or you're not sure how to create a Colab Secret, see the Authentication image quickstart for an example.

[3]

Crafting System Instructions for LearnLM

The system instruction is the primary way you tell LearnLM what kind of tutor to be and how to behave. LearnLM is specifically trained to interpret instructions related to learning and teaching effectively. Below are examples of system instructions that leverage LearnLM's capabilities, matching the examples you provided.

[4]
LEARNLM_MODEL_ID

Test prep

This system instruction is for an AI tutor to help students prepare for a test. It focuses on Adaptivity (adjusting question difficulty) and Active Learning (requiring explanation).

[5]

Now, let's start a chat session with LearnLM using this system instruction and see how it initiates the test preparation

[6]
[7]

The model responds with a practice question on theories of emotion generation and prompts the user to answer the question and provide an answer.

Now, let's simulate the student answering that question and explaining their reasoning.

[8]

As you can see, by using the chat.send_message() method on the created chat object, the model maintains the conversation history and continues to adhere to the system_instruction provided when the chat was created.

Similarly, you can continue going back and forth while preparing for your test. The model will generate new questions, increasing difficulty as you answer correctly, prompt explanations, and give feedback, all according to the test_prep_instruction.

Teach a concept

This system instruction guides LearnLM to be a friendly, supportive tutor focused on helping the student understand a concept incrementally. It emphasizes Active Learning (through questions), Adaptivity (adjusting guidance based on student response), Stimulating Curiosity, and Managing Cognitive Load (one question per turn).

[9]

Let's start a new chat session with LearnLM using this instruction to explore a concept like the "Significance of Interconnectedness of Emotion and Cognition."

[10]

As you can see LearnLM has responded, not with a full explanation, but with a question designed to start the student thinking about the concept step-by-step.

Let's simulate the student responding to that initial guiding question.

[11]

This interaction pattern demonstrates how LearnLM, guided by the instruction, facilitates understanding through a series of targeted questions rather than simply providing information directly.

Guide a student through a learning activity

This instruction directs LearnLM to act as a facilitator for a specific structured activity, like the "4 A's" close reading protocol. It emphasizes Active Learning (engaging with a task), Managing Cognitive Load (step-by-step protocol), and Deepening Metacognition (reflection).

[12]

Let's start a session where the student wants to begin this activity.

[13]

After the explanation, LearnLM invites the student to choose which 'A' they want to start with and to provide a quote.

Homework help

This instruction enables LearnLM to provide targeted assistance for homework problems, offering different modes of help (Answer, Guidance, Feedback) and accepting correct answers promptly. This highlights Active Learning (guidance/feedback options), Deepening Metacognition (feedback), and Manage Cognitive Load (structured options, step-by-step answers).

[14]

Let's demonstrate the homework help flow by submitting a question and observing how the model assists you.

[15]

As you can see, LearnLM suggests a list of options: Answer, Guidance, or Feedback.

Now, let's demonstrate what happens when you choose 'Guidance' and then submit the correct answer afterward.

[16]

LearnLM acknowledges the choice and provides a guiding question to help the student start solving the problem.

Now, simulate the student figuring it out and giving the final answer.

[17]

According to the homework_help_instruction, LearnLM recognized "2" as the correct answer and affirmed it, even though the student was in "Guidance" mode and didn't follow through with all the intermediate steps LearnLM guided them through. This showcases the instruction "Always be on the lookout for correct answers... and accept them at any time."

Next Steps

  • Experiment further with these system instructions in Google AI Studio or a Colab environment if API access is available. Try different prompts and student responses to see how LearnLM adapts.

  • Modify these instructions or write new ones to create custom tutoring behaviors tailored to specific subjects, activities, or student needs.

  • Research other learning science principles and consider how you might translate them into system instructions for LearnLM.

Useful API references: