← All AI Engineer talks

AI Engineer World's Fair 2024

Scaling AI in Education: A Khanmigo case study

About this talk

Khan Academy's Shawn Jansepar explains how Khanmigo scales personalized tutoring and teacher assistance through Socratic questioning, stronger mathematical accuracy, context-aware learning, and education-specific interfaces. He demonstrates iterative essay coaching and teacher visibility into student work, shares classroom feedback, describes rapid prototyping as an organizational practice, and discusses efficiently provisioning dedicated compute for fluctuating demand.

Chapters

  1. 0:00Introduction, Khan Academy's mission, and Khanmigo's scale
  2. 1:59Socratic tutoring, teacher assistance, and ChatGPT comparison
  3. 4:44Education-specific interfaces and iterative essay coaching
  4. 8:58Classroom demonstration and student experiences
  5. 10:43Rapid prototyping and iteration
  6. 21:59Compute provisioning and closing challenge

Talk transcript

  1. 0:00

    [upbeat music] All right, thanks so much for coming to my talk. Um, yeah, I'm gonna talk to you today about how we've been scaling AI in the classroom.

  2. 0:17

    Um, so kind of a case study of Khanmigo. Um, my name's Shawn Jansepar. I'm the director of AI, um, and learning at Khan Academy, and [chuckles] I've also been doubling up as a product leader.

  3. 0:26

    So thankfully, when we're trying to decide on features and roadmap, I don't have to negotiate with anyone but myself. There are other product managers, but, uh, it makes that process a lot easier.

  4. 0:37

    So today I'm gonna talk about problems we're solving at Khan Academy, how we're solving those problems, walking through a few demos, uh, how we transformed Khan Academy into an AI-first organization, and some of the technical challenges solved, and what we're focused on next.

  5. 0:53

    So for those of you who don't know, Khan Academy is a nonprofit with a mission to provide a free world-class education for anyone, anywhere. We have a hundred and forty million registered users, seven billion learning minutes just in twenty twenty-one to twenty twenty-two, one point five million very, uh, ler- very active learners who use Khan Academy for

  6. 1:09

    two hours a month. And we, we most recently, we have about two hundred thousand paid Khanmigo learners and teachers, half of which are in school districts, uh, who are getting access in the classroom, half of which who are just paying on their own.

  7. 1:22

    Um, and we're specifically committed to serving historically under-resourced learners in our education system. So we, through our partnerships with districts, tend to try to partner with schools who have a higher percentage of students who are in the free and reduced lunch category.

  8. 1:36

    So we're really trying to, you know, reach the students who, um, normally don't get access to this type of technology and education.

  9. 1:43

    And since the pandemic, outcomes have been worse than ever. So quickly, this is just a kinda graphic showing you that over time, in the third grade, students are largely grade-level proficient, but by the time they get to the eighth grade, the average student is one point one grade levels behind.

  10. 1:59

    So we believe that AI can be used to successfully fill those unfinished learning gaps at s- uh, at scale by democratizing one-on-one tutoring for anyone, anywhere.

  11. 2:09

    So that's where Khanmigo comes in. It's our tutor for learners, and it's our assistant for teachers.

  12. 2:14

    And just even taking a step back for a second, emulating tutors has really actually been our North Star the entire time. But thus far, we've been limited by the technology.

  13. 2:23

    We've been doing, you know, self-paced videos, self-paced practice. Sal famously said in his TED Talk that his cousins preferred the automated version of their cousin to their real cousin.

  14. 2:32

    And LLMs for us are just kind of a tool that help us accelerate towards that vision. We're really not just trying to use AI for AI's sake.

  15. 2:40

    So how are we using AI to solve tutoring and teaching assistance at scale? There was a really great quote from Notion's CEO where they mentioned that this is as much of an interface revolution as it is a technology revolution, and they are really good at interfaces.

  16. 2:53

    We think it's the same for us, but we're really good about building educational technology at scale for millions of learners around the world.

  17. 3:01

    So I'm not gonna go through this whole list, but just generally things we're doing. Building a Socratic tutor that doesn't give away answers, optimizes for the accuracy of math, is context-aware of your work, and is deeply integrated into our content, multilingual, text-to-speech, et cetera.

  18. 3:14

    So I'm gonna go into some screenshots. So one example here is just comparing Khanmigo to ChatGPT, and you'll notice in this screenshot that here there's just kind of this diving into, "All right, you asked me a question, I'm gonna give you the answer," which can be great if you're an older learner and you know how to learn.

  19. 3:32

    But as learners in the classroom, we don't want students just getting access to the answer. We want them to think about it deeply. We want a more of a Socratic method where you're asking leading questions to help guide you to the answer.

  20. 3:43

    So you'll notice here, Khanmigo didn't away, give away the answer. It's asking leading questions. And then on the math accuracy front, you'll notice that ChatGPT said, "You correctly distributed negative four."

  21. 3:55

    In fact, in this example, you did not correctly distribute negative four. It was incorrect. But Khanmigo's noticing that. Uh, it notices that there was a small mistake in the distribution, and then it kind of back, it backs up and tries to help you from there.

  22. 4:10

    So we're also been doing a lot to kind of embed Khanmigo directly into our platform and into our content. So you can immediately just say, "Hey, tutor me, I got this wrong," and then Khanmigo's passed the context in of it has the full understanding of what this question is, what is, what is the step-by-step solution, what is

  23. 4:28

    the, uh, thing that you entered, and then it'll anal-analyze your solution and help you with it, maybe give you helpful tips as to why you might have landed there.

  24. 4:36

    Um, so that's kinda after you got the question wrong. Before you get the ques- before you submitted the question, we wouldn't just dive into this.

  25. 4:44

    Um, things li- you know, general chatbots are great, but there's a lot of, uh, UX affordances that are always, that's very important for education. Things like having a great math input widget for doing complex equations, um, specialized graph rendering, et cetera.

  26. 4:57

    And then also UX for, uh, use cases like essay writing, which I'm gonna dive into. So we've been thinking about how do we go beyond just that traditional chat interface.

  27. 5:06

    Um, I'm sure you all have kinda had the experience when you were writing essays in grade school. You wrote that essay, your teacher marked it, there's some red ink on it.

  28. 5:14

    You never probably reviewed that essay again. You moved on. What I think that education, or what I think LLMs can do in education that is gonna revolutionize the way we think about it is that it's gonna help us shorten feedback loops.

  29. 5:27

    There's never gonna be a situation maybe where in the future you won't be able to submit an essay unless it's at least a B because the teacher will know that you've been iteratively working on that essay with an AI.

  30. 5:38

    And so I know there's a lot of concerns about cheating, so I'll talk about that in a second. But this is just kinda like an early preview into our writing coach.

  31. 5:44

    So it kinda breaks down the essay writing process into these different categories. So in this example here, you're outlining an essay with a AI directly, and you might have questions about how to write that thesis, but it won't let you move on until you've written a pretty strong thesis, and it'll give you that feedback along the way.

  32. 6:02

    And then there's drafting the actual meat of the essay. From there, you can kinda ask helpful, for helpful tips, but if you ask it to write the next paragraph for you, it'll refuse.

  33. 6:12

    And then there's that last step around revision. So it'll give you feedback on axes of evidence, structure, style and tone, and conclusion. And then this is where things get really interesting with the teacher.

  34. 6:23

    So the teacher now has full access to the history of what you built with the AI to kind of validate that you were the one who wrote that with the AI, and it wasn't just something that you copied and pasted from ChatGPT.

  35. 6:35

    So you can kinda get a sense of that by looking at the conversation history. Um, we're building kind of these replay functionalities, and then it'll also say like, "Hey, these, you know, these fifty-four, or they're fifty-six words just show up, showed up out of nowhere."

  36. 6:46

    So we really think that essay writing isn't actually gonna be hurt by generative AI, but we are really gonna revolutionize the way that works.

  37. 6:56

    Similarly for code, we also have a coding platform, and we're planning on doing the same for code writing at some point.

  38. 7:02

    We're also building a lot of fun engagement things. Uh, students love this kind of stuff. You know, you can reclaim energy points to customize Khanmigo. Um, but then there's integration into the classroom.

  39. 7:11

    So, you know, one of the reasons why Khan Academy started focusing on classrooms instead of just focusing on independent learners who find us on Google is because kids who come to us on Google, it's great, but you have to care enough about learning to come to Khan Academy in the first place.

  40. 7:25

    We really wanted to reach those kids who thought they were bad at math, who hated learning. And so it's important for Khan Academy to be integrated into the classroom and have that tight feedback loop between what the student is doing and so that the, uh, with the teacher so that the teacher can get insights into that.

  41. 7:40

    So for instance, we have a moderation feature where if any conversation is kinda going off the rails, is inappropriate, an e- a teacher will be flagged and notified. So we kinda tried to do things when we were launching Khanmigo, uh, to turn some of the fears into actual features.

  42. 7:56

    Um, this is an example of our classroom snapshot where a teacher can say, "Hey, how's my class doing?" And because it has access to all of that rich data about the usage of Khan- Khan Academy in the classroom, it'll give you that overview, and it'll also, um, give you the ability to kinda dive into skills reports and

  43. 8:12

    dive deeper into our graphs. And then from there, as a teacher, you might be able to do things like, "Hey, I wanna write a progress report to Reese's family."

  44. 8:20

    That's gonna save you a huge amount of time because all this data is directly available.

  45. 8:26

    We built a ton of other teacher tools, things like lesson planning, uh, exit tickets, et cetera. I would've loved to demo them, but there's not enough time. Uh, huge shout-out to Microsoft.

  46. 8:35

    They recently sponsored us, bringing these teacher tools to all US teachers in the States, and soon around the world for free. Um, so feel free to check it out.

  47. 8:43

    Anyone can sign up. And oh, actually, I need to plug in the audio.

  48. 8:52

    Instead of kinda talking about the results in the classroom, I thought I would just do a quick fun video showing how that's going.

  49. 8:58

    Welcome to class. How much they love to use it. Let's, let's, let's have them show us.

  50. 9:02

    Yes. Let's do this. Let's go. Hi, Khanmigo.

  51. 9:07

    Miss Gregory's class was so much fun. Students in this class were opening up their imaginations, writing stories, learning about history, and they learned about America's first president.

  52. 9:17

    What are you excited about George Washington?

  53. 9:19

    Another lesson they learned is Khanmigo's here to help, but it's not gonna give you the answer.

  54. 9:24

    No. It just, it just helps you out a bit. It didn't give you the answer, but it helped me out get the answer. It helped me write my stories, and it's so amazing.

  55. 9:34

    Now we're in Ms. Barrera's fifth-grade class. Everybody here say hi to Khanmigo.

  56. 9:41

    Hi, Khanmigo.

  57. 9:41

    In Ms. Barrera's fifth-grade class and Mr. Rodriguez's sixth-grade class, one thing was for sure: Khanmigo was here to help with personalized learning and adaptive feedback.

  58. 9:53

    I feel like maybe it's weird. It's like a little person sitting next to me, like telling you how to do it properly. It helps you figure out certain things that you wouldn't understand, but then he is like a teacher right behind you.

  59. 10:07

    I absolutely love Khan Academy. We're moving into this space. AI is our future, and I can't wait to see how Khan Academy soars in the AI space in education.

  60. 10:19

    All right. So [clears throat] I wanna dive a little bit into how we built Khanmigo and how did we transform Khan Academy into an AI-first organization. Um, you know, it didn't happen overnight.

  61. 10:31

    So, you know, first we kinda wrote up some requirements about like, what would the perfect AI tutor and assistant, what would that be? We estimated the work. Then we wrote up this nice Gantt chart of the timeline.

  62. 10:43

    Just kidding. We didn't do any of that. Uh, [laughs] the keys to our success were really rapid prototyping and iteration. Um, actually, there's a great book that I highly recommend.

  63. 10:53

    It's called "Creative Selection." Um, it was about how the, uh, iPhone was created, um, really kinda driven through this process of iterative development, um, driving it through demos and, you know, feeding the demos that do really well and, you know, putting an end to the demos that don't re- do really well.

  64. 11:08

    And I think what we really learned is that magic really comes from when you pair incredible builders with domain experts who have some unique insight. And ideally, really, these should be members of your team who deeply understand the customer you're building for as opposed to maybe just sending things off to an R&D team.

  65. 11:24

    At least that's been in our experience. Uh, the history of our OpenAI partnership, so it actually all started when OpenAI needed some AP Bio questions to test their new model.

  66. 11:33

    Uh, we got a first sneak peek in September. And then in December, actually between September and December, we didn't have much headway. It was a lot of like, "Well, what are you doing?

  67. 11:42

    What are you doing?" And then we said, "You know what? Let's just do some rapid prototyping together and red team." Um, and then we narrowed down on a few use cases.

  68. 11:49

    And then once we decided that we really liked the way that this tutor felt on our platform, we said, "Hey, let's try to launch something alongside of GPT-4, but let's do a company-wide hackathon to build a lot of new features, see what the team can come up with."

  69. 12:01

    The best ideas from there won. We tried to ship those with GPT-4 in our launch in March. Um, and then we also participated in reinforcement learning, where a few members of our content team were embedded within, um, with OpenAI to kinda train it on a hundred, uh, math tutoring examples.

  70. 12:18

    So I would say some keys to our success, one is that we resisted perfectionism, which I would call an issue [chuckles] of Khan Academy of the past. We didn't let perfect be the enemy of the good.

  71. 12:28

    Uh, we made quick decisions for what we would call two-way door decisions, things you can reverse. But for one-way door decisions, things like trust and safety, we thought deeply about those problems.

  72. 12:37

    Um, we trusted our intuition. We leveraged expertise if learning scientists, um, and educators, uh, kind of wanted to kind of work through that with us instead of us trying to A/B test every single decision.

  73. 12:49

    And then we also iterated rapidly. I mentioned that with demo-driven development. And then we also kind of had some fixed timelines to avoid Parkinson's law, where work can fill all available space.

  74. 13:00

    We also ended up driving forward what we called, at Khan Academy, we have this process called architecture decision records, and then more recently transitioned that to organization decision records.

  75. 13:10

    So whenever we have, like, a big strategic shift at Khan Academy or a big process change at Khan Academy, we document what is the problem we're trying to solve, who is the driver, who is the approver, who's contributing.

  76. 13:20

    And then once we've kind of written that out, all out, we share that with the team so that they can digest it at their own time and pace. But what we did was we changed some of our Khan Academy core values.

  77. 13:28

    So take a stand, we added trusting your intuition, um, we added resisting perfectionism to deliver wow so that that could kind of trickle down in the way we do performance reviews, et cetera, with the team and how we hire.

  78. 13:39

    And then we also did a big change to our product development process. So I'm sure this is probably a tale that many of you have experienced, but we had an old process that we would consider agile.

  79. 13:49

    You'll notice that all these circles on the left, you know, they feel great. There's a lot of arrows moving in certain directions. They look like you can go backwards, but it ended up being, being a very heavyweight process, a lot of like heavy documentation you had to write for every single feature, et cetera.

  80. 14:02

    Which makes sense when you're building something, I think, that you know you're just gonna ship to all users and it has to be high quality. But in our case, we were doing a lot of prototyping, um, and so we kind of created this new process around there's a different level of quality of your code that you should

  81. 14:16

    write depending on your confidence in the feature. So if you're not very confident and you're not sure, that's just a prototype. Go build it, be scrappy. Uh, if it's a kind of you're somewhat confident, then maybe build it as an A/B test or to beta test it with a few subset of users.

  82. 14:33

    And then if you feel really confident in it and you're gonna share it with all users, that's when the quality of the code needs to be higher. We have some checklists for that that people have to kind of go through.

  83. 14:41

    There's a higher level of accessibility required when you get to that stage, et cetera. But then as long as you're following this framework, different teams are empowered to kind of build software in the way that makes sense for them, as opposed to having a one-size-fits-all for every team.

  84. 14:56

    We also added a AI platform team as kind of a glue between our infrastructure team and product team, so there was obviously just a lot of AI platform team chat, so I think a lot of this is familiar.

  85. 15:04

    But it's really this team that owns the AI developer and prompt engineer experience of Khanmigo. Um, so for example, we recently built this component interface in Go that when you as a developer conform to that component interface, it automatically think-- means that things like tracing and Langfus are available as long as you conform.

  86. 15:22

    Um, they own things like the AI router so that you as a product team don't have to worry about that. It just kind of is trans-transparently taken care of for you.

  87. 15:29

    Uh, we have a chat component, um, that has to have APIs and be extensible for product teams. And it's also a team that will consult with other product teams t- when they're building features if they need some, some help and expertise, as well as what we're kind of tentatively calling Khanmigo-as-a-service, where we're trying to work with third-party

  88. 15:46

    companies to embed Khanmigo into their products instead of them having to rebuild a brand-new tutor from scratch.

  89. 15:54

    So what are some of the technical hurdles, uh, what were some of our technical hurdles that we overcame, and what are the challenges ahead?

  90. 16:02

    So on the tutor accuracy side, things we've done, introduced a math agent. So we kind of give the AI the autonomy to defer to a math agent to work through problems, you know, get access to a basic calculator or, you know, Python might do some more advanced things if it's a more advanced math problem.

  91. 16:19

    Um, we're doing something called Chain-of-Thought prompting. So it's not just going directly to the model and saying, you know, "Help the student." We're actually doing things like we have this process that will say, "Write out how a s- how you think the student might have arrived at that answer.

  92. 16:34

    Write out how you think it should have arrived at that answer," and then it kind of feeds that package over to another call to the AI that suppli-supplies that and says, "Using this context, how would you tutor that student?"

  93. 16:46

    We noticed that that helped, um, improve the performance dramatically.

  94. 16:51

    Um, we've been providing it with additional context like steps, step-by-step solutions, additional context via RAG, and we've also been building this tutoring accuracy dashboard monitor, uh, to monitor quality over time.

  95. 17:03

    So we can kind of get a sense of as we're shipping new changes to our prompts, as we're upgrading models, as we're, you know, making any change, we can make sure that, A, we don't have any regressions to the math quality, 'cause that's a really key part of this experience for learners, and we also can, you know,

  96. 17:19

    ultimately just make sure we're trending in the right direction.

  97. 17:24

    In terms of next steps, one thing that we're about to launch very, very soon, um, is a math accuracy benchmark data set. So right now, when you look at data sets that different model providers are grading against, it's often, you know, is it good at doing math?

  98. 17:37

    Is it good at reasoning? But there's nothing that says, "How do I grade whether or not this is an accurate tutor?" So we're gonna be releasing that with a paper shortly.

  99. 17:45

    Um, we're also looking into integration, uh, with tools like Wolfram for some of the more complex math, and then fine-tuning as well.

  100. 17:55

    So prompt engineering. [chuckles] It's been a journey. So where we started was a lot of hacking together prompts really, really quickly. Lots of spaghetti code. I'm sure that's the same at a lot of your organizations.

  101. 18:08

    Um, we had a kind of varied test coverage depending on the activity. So again, we had a lot of really good test coverage for the math portion of it.

  102. 18:16

    How good does it do at math tutoring? But we had a lot of other activities that we were just like testing ideas and throwing things at the wall and see if they stuck.

  103. 18:23

    So things like, you know, talk to a historical figure. We didn't really have any test cases for that. When we wanted to iterate on models, it was really just, you know, somebody on our team who knew it well enough that would just go in and test it.

  104. 18:34

    And a lot of it was also just looking in logs, uh, for completion calls when we had to debug a particular scenario that was a failure case that we wanted to dive deeper into.

  105. 18:44

    Where we're at now is we've refactored that code using the component architecture that I mentioned earlier, so you can kind of have clearly defined inputs and outputs, and it makes it a lot easier to test and know, like, what are sub pieces of the code that are worth testing.

  106. 18:57

    Um, actively developing a kind of minimal viable, uh, test coverage suite across all of our activities, so we have a broad enough set of coverage.

  107. 19:07

    And we have tools, uh, to run these manual test cases really quickly, but still with humans in the loop. Um, and then we're also trying to move in more towards in the direction of model-graded evals to quickly test new models.

  108. 19:18

    But of course, some of that's not possible without humans in the loop, so it really depends on the scenario. And then also, I think I mentioned this already, all stack traces are now available in Langfuse.

  109. 19:28

    If you want to go and see what happened, you can kind of go in, look through that, you know, stack trace and, um, debug from there.

  110. 19:36

    In terms of next steps, this is not something we necessarily have an answer around, but we- we're looking for continued ways to get more reliable model-graded evals. Um, roughly, we find that when we label things ourselves, compare it to the, you know, what the model will grade if we're doing things like, was there any, you know, math

  111. 19:53

    mistakes in this, uh, the AI is catching it roughly seventy percent of the time.

  112. 19:59

    And we also wanna add a lot more languages, but, you know, how do we do that without bloom, uh, ballooning the test and iteration complexity? It's, there's probably not gonna be a way to do that, but we'd like to reduce that complexity.

  113. 20:12

    And then in terms of, this is the last one, uh, in terms of scale, performance, and cost, we need Khanmigo to be reliable enough for teachers and students to use it daily, cheap enough for lower income districts to afford it, and fast enough such that it doesn't lead to user frustration.

  114. 20:26

    So things we've done so far is leveraging multiple models in production for different workflows, uh, fall back to shared capacity when we're reaching limits on our dedicated capacity, and continuing to do things like perceived performance improvements.

  115. 20:39

    Like if you notice in this, uh, bottom screenshot, we added this UI when we actually added a few chains to the experience that made it slower. And I said to the team, "We can't ship this unless we add a perceived perform-performance improvements change so that users know that something's happening here."

  116. 20:54

    And anecdotally, somebody on our team said, "Hey, after we shipped that, my s- my kid was using it," and I said, "Do you think it feels slow?" And that person's, that person's kid said, "No, I don't think so.

  117. 21:03

    Khanmigo's doing math." So that was a win.

  118. 21:08

    And then another one is just we have gotten a sizable donation from Microsoft, um, of Azure LLM Compute to bring Khanmigo, uh, free to all teachers, so that's obviously helping as well.

  119. 21:18

    In terms of next steps, uh, we're planning on doing things like load balancing between OpenAI and Azure for redundancy. Um, we wanna evaluate more efficient models. We're in the middle of evaluating models like GPT-4.0 as well as small language models like Phi-3 and actively kind of working with Microsoft on Phi-3.

  120. 21:34

    They're building what they're calling Phi-3.14, which is a small to medium size, um, language model that's optimized for math tutoring.

  121. 21:44

    And we also wanna get to a point where we can dynamically scale up and down depending on our needs. Uh, when we launched Khanmigo, we needed more throughput than OpenAI could offer on the shared capacity, and we wanted faster performance, so we ended up moving towards a dedicated instance.

  122. 21:59

    But you know, that dedicated instance is great. We need to provision it for the peaks, but it's not doing a whole lot at night. So ideally, we're, we're making more efficient use of our compute.

  123. 22:11

    That's pretty much it. I just challenge us all to leverage artificial intelligence to help us enhance human potential and human intelligence. Thank you. [upbeat music]