In the past year, you may have found yourself experimenting with Large Language Models (LLMs) like Chat GPT. They have a wide range of capabilities, from summarizing an article to crafting a cover letter, or even suggesting a travel itinerary. The magic lies in their ability to generate text based on the instructions, or prompts, you provide. The more detailed your instructions, the more specific and targeted the output.

You might be wondering, "Can I use it to practice my target language?" The answer is a resounding yes! However, simply instructing it to “Practice speaking Spanish with me” might not provide the most targeted or personalized learning experience. It's a good start for general practice, but what if you want to optimize the AI model to teach you while you practice?

Good news: We did the hard work for you! This was the exact question we asked ourselves when developing our new Roleplay feature. The instructions we’ve given the LLM to develop this feature are not just a simple command like “Practice speaking Spanish with me.” They’re a complex system of prompts, meticulously developed by a team of engineers, designers, linguists, and product managers. Their goal? To provide you with a targeted, delightful, and useful language learning experience. This feature harnesses the magic of AI by dynamically adapting and reacting to whatever you say, but it always keeps its focus on developing your language skills.

Let's dive deeper into how this feature works and how it can revolutionize your language learning journey.

How does Roleplay work?

LLMs operate based on a series of instructions, known as prompts. When you progress through a Roleplay session in Duolingo, you're having a back-and-forth conversation with one of our world characters. Your first thought might be that there is a single prompt guiding this experience, saying something like, “Your name is Oscar; you’re talking to someone learning Spanish; imagine you’re making plans for the weekend,” and then the LLM runs wild, having a free-flowing conversation with you.

However, that's not how it works! In reality, every time Oscar responds in your conversation, a different prompt is controlling what he says. Each separate prompt is hyper-focused on crafting a very specific type of response for Oscar. For instance, one prompt is optimized for forming questions, another for making statements that entice you to ask for more information, one for changing the subject, and another for pulling the conversation to a close, and so on.

Here's a helpful analogy: Instead of imagining your Roleplay experience as a casual phone conversation, think of it as a series of one-question conversations with different call center representatives. After each time you say something, your call gets transferred to a new representative.

The first representative greets you and asks you a question. After you answer, you're transferred to a new representative, expertly trained to provide the next response in your conversation. This process repeats, with each representative perfectly equipped to continue the conversation in a meaningful way.

Now, imagine that every single representative at the call center is Oscar. Each time he transfers you to another Oscar, he provides a transcript of the conversation so far. This way, the Oscar you're talking to knows exactly where you are in the conversation, and the Oscars trained to ask questions, change the subject, or wrap things up all get to hop in at the right time.

You can think of the "rules" governing which Oscars take over the conversation at a given time as an intricate flow chart. Some Oscars can only speak after the narrator says something, others only after you've given a response, and others only after a certain number of back-and-forths have happened. This ensures a smooth, engaging, and educational conversation every time.

 A flow chart describing the path a user goes through during Roleplay. Step 1 is opening narration, which leads to a question from a character, which gets a learner response. That Learner response gets a statement from the character, then middle narration, then a question from the character again, and then another learner response. Those steps can happen in a loop, until there is finally a conclusion from the character and Roleplay ends with a final narration.

How is this good for learning?

Each Oscar, or prompt, is not only trained to provide a targeted, natural response, but they also all receive general training to ensure the overall learning experience is effective and engaging. Here's how:

1. Carefully crafted scenarios

Every prompt is injected with a scenario that sets the scene. This includes the setting, the character's role, what the character wants to do, and a learning objective appropriate for your CEFR level. This gives each experience a goal and presents you with a real-life situation where you'd need to use your target language. Instead of aimless banter, scenarios guide your conversation towards a specific objective. But remember, you're always free to steer the conversation in any direction you want. Here's what a prompt might look like*:

Learning Objective: decline a request

- The learner and Oscar are friends and the learner is politely declining Oscar’s invitation.
- Oscar wants the learner to watch their needy pet and the learner is politely declining Oscar’s request.

2. CEFR alignment

We understand that learners at different proficiency levels use Roleplay. We aim to strike a balance—we don't want the character to use language that's too difficult, which could be discouraging and confusing. On the other hand, we don't want it to be too easy, as you won't learn much if the character only uses words you already know. Each Roleplay prompt contains information about your CEFR level to keep you in the Zone of Proximal Development.

You must use A1 CEFR Level language

- Only use A1, beginner-level language
- Only use simple grammatical structures
- Only use simple present tense
- While simple, the A1 language must also sound natural and be grammatically correct

3. Character personalities

Every prompt gives the LLM information to make it sound like the Duolingo character you're talking to. For example, when doing a roleplay, you won't hear Lily acting chipper or Eddy sounding discouraged. We feed the model information about the character's general personality, speaking style, background information, and relationships to other characters. This not only makes the experience more fun and on-brand, but it also gives you opportunities to practice talking to different “people” in your target language.

Character: Oscar
Character information:
- He is a 40-something year old man who is passionate about art, fancy restaurants and culture.
- His speech can come off slightly arrogant and snooty.
- He takes great pride in his physical appearance, specifically his mustache.
- He loves the dramatic arts.

4. Narrative arc

You may have noticed that you and the character aren’t the only voices in a roleplay. We also have a narrator who sets up and closes the interaction and can interject with new information in the middle of a session. The narrator sets the scene, communicates the objective, steers the conversation back to the objective at hand, and ties the conversation in a nice bow at the end. Narration adds structure by giving the conversation a beginning, middle, and end to make sure it feels fulfilling. It keeps things moving forward, ensures the experience is bite-sized, and often adds elements of delight.

Here are instructions for your opening the dialogue while acting as the narrator:

- The introduction should set the scene mentioned in the scenario.
- The introduction should establish a dialogue in which the learner can fulfill the Learning Objective.
- The introduction should introduce the character in a way appropriate with their personality.

So… can Chat GPT help me practice?

Yes, you can use a Large Language Model to practice your target language. But if you want an experience that is calibrated to your language level, immerses you in real-life scenarios, lets you engage with characters you know and love, and feels concise and fulfilling, you would need a very specific set of prompts to cater the experience to your needs.

That's where we come in. At Duolingo, we're constantly tinkering with the AI to make your language learning experience more entertaining, more personalized, and most importantly, more effective. We've done the hard work of crafting the prompts and scenarios, so all you have to do is dive in and start talking to our characters. Don’t thank us… just do your lesson!

*These are simplified versions of the prompts and logic we use in our app.