0:01Hi, everybody. This is Jeremy Howard from Fast.ai, and I'm here with Johno.
0:10Johno is going to be demonstrating some really cool stuff later today.
0:13So look out for that. But maybe before we get started, I should tell you a bit about who we are very briefly and hopefully convince you that we are worth listening to.
0:23So we're going to be talking about how to solve it with code. And this is the first lesson. So if you haven't heard of Fast AI, we are the world's longest running deep learning and AI
0:38education provider and also an R&D lab. Over the last, gosh, I don't know how many years, nearly a decade now, lots and lots of people, alumni of Fast AI have gone on to big things. I asked Grok before we started to jot down anything it found and it's listed a few examples of people who, as far as I know, every major research lab in the world now has alumni from Fast AI there. Some interesting examples, Suhail. Wait, you used to work for Suhail, Johno.
1:12Yeah, yeah, I joined them He's the CEO of Playground AI alumni. Got a nice message from somebody saying he just got a job as an applied researcher. He's saying he's just a high school grad, no college, just Fast AI. Vice president at one of the world's top pharma companies of AI. Says all of our folks
1:35go through Fast AI. Christine McCleavy, who I think she leads Voice and stuff at OpenAI is another great alumni. She's amazing. John Wu recently just became a tenure track professor and has documented his background in Fast AI. Lots of folks, so if you are part of this community, you are amongst good company. With our students, we've done some really cool things together. We broke some world records in creating the world's fastest model training systems.
2:12And as well as our teaching, our research has also been very significant. Most famously, this is a family tree of LLMs. This one here called ULMFiT, which goes there, was created by me,
2:29actually during a course. And as you'll see, it is the very last one before the explosion. And that's because ULMFiT was actually the world's first modern LLM, as popularly understood, using this three-stage process of pre-training a language model, fine-tuning a language model, and then doing a classification type process at the end. So all of this is to say, hopefully, we are worth listening to. We will do our best to say things that are useful.
3:02We're not going to try too hard to convince you that you should be. So we're going to be trying to help you improve at your craft, where that craft is generally doing things with code or about code. But we're also going to cover quite a bit of stuff about writing prose, about reading, about learning. And at no stage, really, are we going to say, OK, in order to do this, just ask an AI to do it for you and come back half an hour later.
3:31Some of the things that we're going to practice you could ask an AI to do for you when you could come back later. But it's becoming quite clear that outsourcing too much to AI is causing a lot of problems for people's careers, for organizations, for people's mental health.
3:53I'm not going to try to convince you. But if you're interested in learning about why you shouldn't just join a course that says how to outsource everything in your life to AI. You might want to watch some of these videos, such as Andrej Karpathy, Chris Latner, or even me. So as Andrej said, when you build something from scratch, you're forced to come to terms with what you don't understand. And you don't know that you don't understand it. It always
4:21leads to a deeper understanding. It's the only way to build it. So if you're literally outsourcing, trying to outsource all of your building to AI, you're never going to get the deeper understanding. And so you're going to simply get a crater in terms of your competence and also your confidence because you won't have that experience of doing something yourself.
4:44We're going to show you how to do stuff on our platform called Solveit. We created Solveit specifically for human agent work, so for stuff where you are driving the process and it's designed so that you're learning as you go more about what it is you're building and how to
5:05build it and learning skills and improving at your craft. Sadly, nobody else seems to have tried to build something with that focus. And therefore, there is nothing else in the world right now, which is as good for the Solve It method compared to this platform. But you don't have to use it to use the Solve It method. It'll just be a little less convenient. So I would say, like,
5:38don't stress too much about how to bring your problems into Solveit and bring the solutions back into your native environment. If you're doing a bit of copying and pasting or whatever, it's OK. You don't have to have perfect efficiency in which your computer does everything all the time. We'll be showing you how to automate stuff a lot more in terms of that stuff. But a lot of people coming into Solveit are very focused on, this isn't the exact same environment I use at work. So how can I use it? I can't use it because it has to be exactly what we have at work. So don't worry about that too much for now.
6:13There's also going to be this piece of the thing that's actually showing on the screen is going to be the interface and the code that Jeremy's typing. But the most important of the two pieces is more the method and the thinking and the approach. And so one role I'm going to play is if you've got questions in the chat or if I've got questions like, why did you do it that way?
6:31What did you break it up? Those are the ones we really want you to take away. And the kind of like which buttons to click, sure are secondary to that overall approach that we're going to be showing.
6:42And when we say we're going to show you how to solve problems, that includes problems like, how do I write this article? How do I read and understand this paper?
6:49How do I add this feature to some software? How do I spin up a Linux server? Like, we're using it in a very general sense. And interestingly, you can actually reorient all of these questions as being, I want to learn to do something. I want to learn how to write this article. I want to learn how to read this paper. You know, at some point, the definition of where is learning finish and doing start really starts to get gray. And as I'm sure
7:18Johno has very much noticed in my life, that's particularly true. Pretty much everything I do, I tackle with a learning mindset. And I think you do as well, wouldn't you say Johno on the whole?
7:30Definitely, and it's a lot more fun that way.
7:36Okay, but here's kind of one interesting way of thinking about it. How do you leverage Solveit?
7:39You know, even if it's not integrated into your workplaces, you know, enterprise platform, it takes a moment to copy something in and set up some test data and takes a moment to take the result and put it back. None of that's going to be useful if you don't have problems worth solving, by which I mean a lot of people tell me, Jeremy, what's the point? I don't need it because I just create boilerplate. I code, but it's just boilerplate. And people are like,
8:08well, why don't you use agents? Because agents can write all the boilerplate. OK, you have a problem to solve. Your problem to solve is you have too much boilerplate. If you're coding, you should be able to read your code clearly and briefly and see exactly what's going on.
8:24So let me give you an example. I tend to try to do things that are very current. So for example, I mentioned John Wu earlier. That's because he got his tenure track professorship two days ago.
8:36So everything I'm doing, I tend to be very current. So two days ago also, well, last week we added a new feature to Solveit, which is kind of Git integration and versioning. And before we deployed it, we realized like, wait, we've got a problem, which is that we actually need our Git program to run under a different username to what the
9:00web app's running at. And the Git Python library doesn't support that. What are we going to do? So what approach would be like, lots of boilerplate, write sudo minus u Solveit git hundreds of times, you know? And I was like, OK, no, we're going to delete Git Python entirely. We're going to remove the library we were using. And I replaced it with a single function.
9:23So this is actual code from Solveit I'm showing you here. And so as you can see, we're writing Solveit in Solveit here. And you can see I haven't changed this from, I can't remember, might have been Tommy who wrote this from how it was first written, which is, you know, we have these inline documentation. This is how we write stuff in our workplace. And I wrote a little thing when I modified Tommy's code to add core git. And it's very simple, just calls subprocess.run and
9:51it's running sudo and some arguments. And also git minus c, which means it runs it in some particular folder or path. I say, cool. So now, for example, in order to find out what is if we're inside a git repo, what's the top level of that git repo, we can say call git with the folder we're in,
10:16rev-parse show-toplevel. That's how you do it in git. And cool, that was starting to look good and I was like, hmm, there's still quite a lot of boilerplate in all this call git folder, bizzo. So after I was doing that for a while, I added this little class called git,
10:37where I can now create a git object. I can pass in the directory and I can do things like a property called exists, which checks whether top, which does that top level thing is none. And I added a call to it. Don't worry if you don't know all this somewhat Python specialist syntax, but this allows me to treat it exactly like there's a method called revparse. So now, rather than having to
11:03call git revparse, I can just go self.revparse. And rather than calling git init, I can now just say g.init. So you can see, and again, this is our real code. So you can see in our code base, we immediately add a test just to make sure everything's working and also to show the reader how to use it. And we're not creating thousands of lines of code. I've created, what is this, about
11:3220 lines if you exclude the tests. And it worked. It took, I don't know, an hour, half an hour. And the other thing to mention is I did all of this, as I do most of my work, with a friend. So I did this with my friend named Curtis, who works with me. And you might be like, wow, two people, what a waste of time. We can't afford two people. But like, we're not trying to make every minute
11:59as efficient as possible. You know, by doing it this way, I remember, for example, Curtis noticed something that in hindsight, I guess it was pretty obvious, which I was always trying to use this top thing to find where the top level was and then CD to it to make sure I was in the correct directory.
12:14And Curtis reminded me like, no, Jeremy, you don't have to do that. Git always knows which repo it's in. And it's like, oh, that's right. So a lot of the ways in which we work at Answer AI is super different to most companies. But also, if you go and have a look at our web page, we have nine people in total. That's it. We don't have marketing staff and advertising staff and PR staff and finance. Whatever. Nine people, including me, and I think we're pretty efficient.
12:51After that, later on, I noticed that I kept on saying, get.log, get the last one in a particular format. So it's like, that's how I get my last commit. So I added a property later on called last commit. And then I can just go, OK, get, init, assert, get, ignore, in, last commit. Print g.branch. And then later on, start adding some tests, more tests, which is kind
13:18of like a documentation to take the reader and the computer through the whole process. Yeah, so what do you think, Johno? It's a bit different to, I guess, other ways that companies tend to work.
13:30It is, and it requires some very careful like reframing and training. And I keep having to like, re-remind myself with these pieces because you showed an example there where, okay, so first of all, there was a library that did mostly what we want, right? And then there was a version that you wrote that worked like it was technically fine. And so there's this short-term calculation where you say, okay, it's gonna take me, you know, some hours to rewrite this.
13:56And is it really gonna like save time? It's probably gonna save me a few keystrokes here and there. And so the very short term version is to say it's a waste of time, right? To do the second version where you were digging a bit deeper using some of the Python internals and messing around with Curtis. It's like two people wasting two hours, you know, wasting. And that's like, if you frame it that way and you're focusing on the deliverable by the end of the day, it's like one inefficient way to work. But the next day when you wanna add additional features
14:25with Git and it's just a pleasure to use and a joy and it's a little tiny bit of code. And then the next month when you have to come back to it and you go like, I remember I made this nice Git thing. I can do that. You know, that like compounding interest of that initial extra two hours or four hours of dev at the start means that months later you're still reaping, it's such a joy to like come fiddle with the way we do Git because we spent that time to do that third rewrite or that fourth rewrite or that minor refactor that made things a little cleaner to work with.
14:51And even if not, you know, even if it was only one to one or even half, it's like, well, I've learnt something new. I've done some deliberate practice. I've had a nice time. I've done a cool project with my friend Curtis. Like this all has a lot of value. And actually the thing I care most about in our staff is that they are continually developing their craft, you know, because if Johno never learnt anything new for the next five years. That'd be so sad for him, for me, for the company.
15:26That's definitely not what's happening, right? So, yeah. Okay, so shall we dive in to some examples?
15:37Yeah, yeah, let's start showing the approach in action and to maybe frame the background for everybody. The way we're going to try and run this course is to illustrate these examples. And the one I just gave of saying, like in a month's time, this is where we'll start to see the sort of appreciation and the enjoyment. Obviously we have to fiddle these examples into an hour or two of a lesson. And so some of the pieces are going to be very small. The problem Jeremy's about to start on is going to be a very small problem. But
16:04hopefully the preamble that we've just given and some of the later showcases and examples we'll show will convince you that this works up and down the hierarchy. This is not just a 15 minute problem approach. This is what we generally use for everything that we do.
16:22I think I'm going to start with a simple problem solving exercise. Just like primary school children can use calculators to do times tables, we encourage them to learn them and practice.
16:36Same for something like learning to solve basic problems with code. I think it's a great idea and I enjoy doing it. Advent of Code's a nice place. These numbers, as they go up, they get harder and harder. So you can generally, most people, would have thought, watching this, will be able to handle day one, or at least the start of day one. And if you find that a challenge, no worries. You
17:03can go back to previous years, 2023, 2022, do day one. If it's so easy that it's pointless, go to try day 20. As I show you, though, you can actually learn a lot, even from day one.
17:17So I'm going to do this in Solveit. So yeah, when you go to the dashboard, you'll see that you can just hit the Connect button, and that will pop you into Solveit. And from there, you can create a dialogue. So what's a dialogue? A dialogue is a
17:45conversation between you, the computer, and an AI. Sometimes it will only involve the computer, i.e. code. Sometimes it will only involve the AI. I find for most of the time, it's got both.
18:01So I'll say advent of code. And this is number one of 2024. Create. And so when we create a dialogue, you basically see we end up here with something that looks a lot like ChatGPT. And indeed, if I hit the prompt button, everything's got keyboard shortcuts. So this is Command Shift
18:27L on a Mac or Control Shift L on PC. So we're pretty lazy here. We used C to mean both. So I can say like... Hi there, I would like to try doing an advent of code problem. And a very minor thing, I think it's a great idea to have a high quality voice interface available, particularly when you're chatting to an AI. It's just so much less overhead to type. Here I'm using
18:57MacWhisper, which I like a lot. You can see it's sitting up here in my menu bar. The default one that comes with the Mac is terrible. The default one that comes with Windows is not too bad.
19:11Johno, you probably use the Windows one more than me recently. Do you think it's all right? Or have you used it much?
19:16I've just been dogfooding Mac. But the Windows one, I think it's the Windows key and the H to start recording. Yeah, it's solid for just inputting a piece of text without having to move these meaty sausages around.
19:29Okay. Yeah, it is. So as you can see, I can ask it for help. And what I'm going to do is I'm just going to go ahead and copy the Advent of Code problem I'm going to solve in. Generally speaking,
19:46LLMs quite like Markdown. So to convert stuff to Markdown, one easy way is to use something called r.jina.ai. Anything I do more than a couple of times, I like to automate. So I've added a button up here in my toolbar, which Solveit can help you create this if you want to. It just goes JavaScript location href is r.jina.ai. So I'll hit that button. And now it's markdown. So I'll grab all that. And so as well as a prompt, you can also create a note, which is just a bunch of markdown.
20:22Now you'll see that when you start typing, the thing you type into is very small. And it's kind of trying to gently encourage you not to do too much at once. But as soon as you start typing more, it'll grow automatically. If you want it even bigger, you can hit Command-shift X or click this button to use up nearly the whole thing. So that all looks pretty good.
20:51For anyone watching who's a little confused by references to elves and chief historians and so on. The advent of code is a delightful series of programming puzzles, often written around a theme. They come out once a day during December, so the new ones will be starting in a month and we'll get to try them out. And so that's the context here is we have this kind of like little Christmas themed or fairy themed story about elves and lists, but at the end of the day, there's going to be a puzzle hidden within there where we need to somehow figure out an answer and submit it to help the elves out on their journey.
21:21Thank you, Johno. There's a lot of little tricks. This is quite a sophisticated system. You don't have to know any of them, but for example, one thing I like to do is turn this into a little scrolling area rather than take up heaps of room. So that's Shift-I, I for input. You can change the scrolling area of the output with Shift-O. And we can see here our problem. We'll read it in a moment, but I just want to point something out to you. I can say... This is the problem that I would like to solve. I am fairly new to Python, but I know the basic idea of programming.
21:59So normally an LLM would just go and give you pages and pages to tell you exactly how to answer it. But Solveit's very much designed to not do that, as you see. So it encouraged me earlier on to tell it about my background, and now I've done so, and it's telling me, you know, giving me some basic directions to get started. The problem here says, that let's not worry too
22:28much about the elves and the chief historian. But basically what we need to do is we need, we've got two lists and we need to see if we can see how similar they are. They need to reconcile their lists. So here's an example of a list. So it says pair up the numbers and measure how far apart they are. Pair up the smallest on the left list, so that'd be one, with the smallest on the
22:54right list. That would be three. So this is what I always do first to solve a problem, is I do it in my head, properly. The advent of code is very good at giving this practice of always having a small example problem, working fully through the example problem, and only then going onto the big problem.
23:13I find most people, as soon as they leave advent of code, forget all that. And as soon as they have a big problem, they start to try tackling the big problem straight away. They're like, we have 14 terabytes of data. Step one, how do I load 14 terabytes of data into my table? So,
23:28you know start with 10 rows and then once you've got 10 rows start with one row. We're going to be doing a bit of stuff with Advent of Code so it's a good idea to learn to be efficient with it. There is a thing called advent-of-code-data which is pre-installed in your environment. And I won't show you don't worry about this pip install it's already installed but you are going to need this key that you can copy once you've logged in to Advent of Code, which you can do by logging in.
24:04And it says here, say, export and then put the key. Now you actually don't need to do that.
24:09All you need to do is grab that text, Advent of Code session, AOC session, and over here create a secret and paste in your code here following the directions. And you'll see I've actually, I already got mine. So having done so, it will end up just as if I typed that export thing,
24:33but it'll be there all the time, which is very handy. And so, yeah, there's a bit of information here about how to use it. So maybe we'll just start by copying. Nothing wrong with copying.
24:48So we're going to have 2024. Day one. Yeah. So even learning how to use the advent of code data, we can start to learn some things about how to work in this kind of environment. So.
25:06Python is nearly uniquely good as a modern programming language at its ability to work in this kind of dynamic environment. So you can do just about everything. So for example, you can type underscore, underscore dict on anything to find out all of the stuff it contains, for instance. Or you can type dot and immediately see all the things you can do. And you'll notice
25:35none of this requires any typing or hints or anything like this. This is much more accurate and correct than any kind of annotations or type hints or anything like that because it's actually looking inside the interpreter and asking it, hey, what can you do? And so I can see here, one of the things it can do is examples. And so this is what I do. I start to play, right? And so I can see it's a list with one example in. So that means I can get zero. So I often do a lot of this, just going back and gradually adding more stuff. It's like, oh, there's my example. Cool.
26:10So then I'd probably give this a name. And then you can just pop the symbol afterwards and both define it and see it. And great. So we've got some input data. So I'd put that into here.
26:28Data. And so you can see everything popping up automatically. These are always perfectly correct, for the reasons I just mentioned. So the way I'm submitting, I'm doing everything with the keyboard. So submit you can see is command or control enter. But actually there's a number of ways you can do this. I tend to use alt or option enter. So if I do that
26:52right now. You'll see not only did it submit it, but it created another one underneath and popped the focus down here. So this is how I can just add lots of code or prompts in a row. So that's key that alt or option enter. Great. So if I wanted to switch over to being a prompt, I can now say like, okay, I think I've got basically everything set up now. Does that look right?
27:23And also, if you wanted to spend a bit more time thinking before it answers, you can just hit the Use Thinking button, which is Command-Shift-D. And if you do that, you'll see it just takes a little longer. Well, it has to think first. So it's showing me what should you try and do. And so you know, how you go from here if you don't already know
27:50how to split each line is you could go to the Python docs. You can just ask it. Tell me how do I split each line? Or maybe you know. So I know. So I'm just going to go lines equals input.splitlines. Or you can just start typing, you know, and.
28:11Also, Jeremy, I wanted to ask, it's one thing to say, okay, how do I know whether I should split these lines into pieces? But more generally, like, how have you even got to the stage where you were looking at the problem and now you wanted to split the lines? Is there a point at which you're looking at the whole thing, or is this still the like, I'd like to dive in and just poke at the data and get it to the point where I have everything loaded and then I'll make a formal plan? What's the like thought process when you're choosing even like what is the first piece of code to run?
28:37Yeah, you know, I don't tend to plan a lot. I tend to just think about what's the single step I could do that could get this into a slightly better shape than it is now. So, you know, currently the input data, you know, it's a string. And it's like, hmm, can't do much with that. So a list of lines would be a little bit better. So that's kind of my thinking is just to be like, OK, let's make it a little bit better. And if you haven't used split lines before or not for
29:05a while and you can't remember what it takes, you can just hit Shift-Tab inside the parentheses, and it'll tell you that it's got a parameter called keep ends. Breaking it line boundaries.
29:16Line boundaries are not included unless keep ends is given. That sounds pretty good. You know, so I'm just like, that sounds a bit better. So I'm just going to like, go ahead and type. You know, that's a bit more convenient than it was before. And then I'm like, well, better still would be
29:39if each of these was split themselves. So I might be like, split lines equals and
29:54well. Or we could just do it, possibly. So now I'm starting to think about, my head's just thinking, what could I do? So I need to actually add up the difference between the sorted versions of the two lists, basically, to find the smallest in each, the second smallest. I need to sort them. So yeah, I do need them to be in two lists, actually. So here's where, if you're fairly new to Python,
30:23you might start typing X's equals here and then start typing a for loop And so forth and this is where I'd be like, you know, can you learn something new today. So I could be like, okay, I know how I could create the two lists using a for loop and creating an empty list first.
30:52But I'm wondering is there a more concise way to do this. I'd like to try to learn some new Python tricks today. So I just let it know that you're looking to learn new things and Solveit's generally going to encourage you to try to learn things anyway.
31:10So this is exactly what I had in mind. So that's great. So I'm not going to show you this Python right now. And the thing is, that's the nice thing about teaching in this environment, I don't have to teach you everything because in this environment, you can just ask, right?
31:31And you don't have to be embarrassed about asking. You never have to be embarrassed about asking, but particularly when you ask a computer. The computer's not going to judge you, I promise. So I'm going to say line.split. And nice little trick, if you didn't know it, in Python is that split actually by default, when set to the default,
31:56it will split on any whitespace, which is exactly what we want. So x's comma y's. There it is, right? And so now I'm basically ready, I think, to solve it. I just need to sort these. So they're currently not integers. So we'd want those to be integers. Then I can sort them.
32:29There's another piece here, Jeremy, that you did implicitly, and I'm just going to call it out for those watching. You didn't just write the line of code that created those two lists. You then printed them out, right? Just by typing the names of the symbols so that you can see them there. And then you looked at that and you said, yeah, that looks right. In other words, you've seen what the original list is. And then if you look at the first one in each, it's like, the first one in the first line was a three, the first one in the second line was a four,
32:54then a two, and then a one, and then a three. And then you can see, okay, that's exactly what we wanted and that's exactly what we got. And at every stage we're doing this, it's not just like, I know the code to do this. I'm going to type it out. It's like, I know the code to do this. I'm going to type it out. And then I'm going to inspect the output to say, am I proceeding on my track? Right? Like it's not just theoretically, I would hope that this would put it in a nicer formulation. It's that no, no, no, I can see straight away. I can see the output and check. Yes, I have in fact moved a step towards where I'm wanting to go.
33:25Thanks, Johno. Yeah, and you know, maybe then you might be like, OK, I'd be interested in learning some more Fast AI tricks, like fastcore has a neat little thing called L. And so then you might be like, I could just grab those, and I could make each of one of those an int, for example.
33:45And then I could possibly sort that. I wonder if that would work. So it could be like, hmm, have a look at x's. So this is where I kind of tend to type, interesting, I could have a sorted. Oh, that's nice, cool. So then I'd be like, okay. So often I'll kind of like play around on the next message to kind of get a feel for what I want and then kind of go back and it's fine to
34:12have little bits of duplicate code. You know, I don't have to have everything perfectly factored away. I can just copy and paste that. And so then I can have a look and say my x's and my y's and
34:29that's all looking pretty good. So then I just kind of say like, okay, I think I'm done. So I can now say res equals zero for x comma, well, there's a few ways to do this. And again, I'll try and show you something a bit new. If you don't already know, this is nice little trick is to use zip x's comma y's. Otherwise you could do for i in range. Length, x's, index into it.
34:57I want for x y in zip.
35:00Thank you. This is why you want pair programmers. Res plus equals absolute value of x minus y. And then hopefully that should be 11. So I tend to think what it should be before I run it.
35:24Otherwise you can kind of convince yourself. And this is where, all right, now I want to run this on the whole input. So in advent of code, they give you the examples. And then they also say, all right, now run it on the whole input. And the further you get, the more running it on the whole input without running out of time for the rest of the universe's lifespan gets harder and harder.
35:50So there's a few ways to do this. And so this is where we've designed the system to make this convenient. So one thing I'm going to do here is I want to split this import out. So I'm going to press Control Shift hyphen to split it into two cells. And I can basically see I need to
36:12start here and then gradually do all the stuff. I'm going to put it into a single function. So there's a button here called Copy. Sorry, that's the wrong one. I need my Copy. Is there a button for it? Maybe it's just the keyboard shortcut. I don't know the keyboard shortcuts because I use them so much. So comma copies the input and full stop copies the output. Normally our input output versions are next to each other on the keyboard. And as soon as I hit copy, you'll see,
36:41I just hit comma. Do you see how this is now flashing down here? So it immediately gets me ready to paste. So I can paste, right? And then I can scroll down a bit. What else do I want? Yeah, I want this one as well. So I'm going to hit comma again. So, comma and then paste. And yeah, I also want, I think actually this button's wrong. I think this is the comma one. I'm
37:09just going to try a copy. Yeah, it is. That's actually not C. That's the comma one. That's good. And yep. And this is the last stage. Copy. And so you see how it made it really easy for me specifically to take bits of stuff I've built gradually and combine it into a single thing.
37:28So these are all the little things we're trying to do to help you use the solve-it method, which is all about small steps, seeing what you're doing as you go. So I'm going to create a function here called calculate 1A, because this is part A of day one, and I'm going to give it some input. And so then we can hit Alt-right square bracket and then we can check that calc 1A.
37:58I'm giggling because I've seen a bug. If you're watching, see if you can spot it.
38:01on my input. Now I'm curious. I didn't return anything.
38:10So I can see by doing it straight away. So this is the nice thing about this approach is I'm terrible at coding. I make mistakes all the time. But my mistakes are either in four or less lines of code or in just combining bits of code I already wrote.
38:27So generally speaking, it is within my capability to manage debugging that.
38:37So there's a great question in the chat, Jeremy, which is someone asking, do you now go and clean up this whole notebook? Is there a phase where you're going to delete all the experimentation and keep this? I think they asked it before you started building this function. But yeah, what is your thoughts on copying and pasting those lines from earlier down here versus trying to maybe combine all the earlier ones and erase the process?
38:59Yeah, it's a great question. Let's just see if I get the right answer, shall I? Calc 1A. My one's not working, so I'll switch to the other keyboard. So I think I should be able to now go to my puzzle. And there should be a input data. There we go. And maybe before we use that, let's hit escape. And I just want to add something above this. So it's A to add
39:25above. And I just want to have a quick look to see what that looks like. Okay, so that's it. Yeah, that looks good. It's just a string. That's what I was hoping for.
39:36So I just hit X to delete that. And then I press full stop to copy the output. And everybody gets different puzzle data. So you won't have the same answer as me. And I don't know if this is correct. Fingers crossed. It is. OK, and after you've done that, it'll give you part B, part two.
40:00So we tackle this question a lot within Answer AI and there's no one single answer. Generally speaking, if something was difficult enough that you needed to spend a little bit of time exploring it, which is like anything that's not totally trivial, then probably you in six months or your colleagues would feel the same way. And so when they then come to add a feature to this
40:30or debug it, you know, when something changes in the future, it would be much easier for them to work through the line-by-line explanation than to dive straight into the big long code.
40:45So we normally keep it around. And we'll dive into this later in the course, but you can read lots of our code. Our source code is all actually, of everything we write pretty much is all written in Solveit or in Notebooks. And if you look at the code, for example, Claudette, which is a library I
41:08created as an anthropic API wrapper, basically, you can see me, first of all, I'd never used it before. So the first line of code I wrote was to create the object. And then I created a message.
41:21And then I tried sending it. And I looked at the thing I got back. And then I was like, oh, it looks ugly. So I created a little thing to try to make it look a bit prettier. To do that, I needed a few steps, I printed them as I go. And so then when my colleagues later on came and added more features, I didn't have to tell them how my code worked. I just said, OK, colleague,
41:48there's a notebook. And you just dive in. So I think that's the answer. But you can go too far if it's something that's trivial and you really didn't need all that detail. You can delete it.
42:06Do you think that answers the question okay, Johno? I mean it's a bit of a subtle situation.
42:11I think so, yeah. You'll see as the course progresses, as we build up our own notebooks, some of which are going to be single-use exploring, some of which are going to be building pieces that we'll use later, you'll kind of see in practice the mix of little bits of tidying versus keeping the whole artifact. So it's definitely not like a one-size-fits-all, but I think in general, especially because it's so easy to share or to keep a version that has everything, it's really nice to have those steps for later. And so you should probably err on the side of, let me just make another copy and tweak it rather than I should only ever have one perfect function at the end of the day.
42:44So I said like even if you're good at Python and data structures and algorithms, this would have been trivial. But like, you know, you can have fun with stuff like this.
42:53So maybe like, okay, I think I'd like to learn something else new. I've heard about this thing called NumPy. Would that be something I could make this like more concise? I'm keen to see how concise I can make this. And I know it's already fast to run, but I'm kind of wondering whether there's like some theoretically better performance or something. You got any ideas?
43:13And you know for something like this where I'm kind of asking for it to be a bit more thoughtful, I'll often hit the use thinking button.
43:22Because you know, I don't mind if it takes an extra 10 seconds.
43:24So that sounds great, right? So just to give you a sense, I'm going to have a try. So I go from NumPy, import array. Maybe I'll also import sort. Import NumPy as np. I'm just going to have a little bit of fun here. So what I tend to do for this kind of thing is I often build it
43:50up on one line slowly as long as the line ends up feeling reasonably readable. And I tend to assume the person reading it is competent. And competent doesn't necessarily mean they know all the libraries I'm using, but it does mean they know how to look it up. And since they'll be working in a notebook or Solveit, I know they can experiment with it right there. So I can have quite high expectations with my colleagues. Also, because there's people like Johno who are super
44:14smart and tenacious, that helps as well. So I would start with my, you know, my lines. In fact, we start with our input. OK. And yeah, so we did that thing where we went, you know, o dot split
44:37for o in lines. And here's a, let's do it right from the start, input dot split lines. And this is one of these things where it's like people might be like, you can't call it o. What if you forget what it means? Like here, like literally, o is being used only on this line. It disappears as soon as I finish this line. This is a good place to use small symbols. Cool. How do I convert that into an array? Well, actually, you can just do it. So you see how I'm like, I didn't run that.
45:14Array is the problem.
45:17Array I should stop to stop using this keyboard. Okay, so again doesn't matter if you know about numpy and you know arrays and just showing you the idea and so I just I'm not hitting alt enter now I'm hitting shift enter or command enter and then I'm immediately just hitting enter on my keyboard to jump back into
45:36Edit mode and just gradually building it up. It's like I want those to be integers. Okay, great. So now you know, this is a columnar matrix if you like or two columnar matrices. I want there actually to be two rows so I can split it up easily so I use something called a transpose
45:53and it's like there we go. Great so that's my x's and my y's. There we go. So those both need to be sorted. I need to take the absolute values of the differences. So I could say sort x's minus sort y's dot. Oh that's all one thing. Take the absolute value of all that. And then at the end.
46:34Okay, now that was fun, right? You know? And then we can double check that we end up with the same thing. So since there's only two of them, I'm just going to hit C and then I'm going to hit V and then I'm going to hit Shift-M to merge them. And I'm going to delete this. And
46:49so this is my def calc 1A using NumPy with an input. And before Johno starts laughing at me, I'm going to type return. And then we'll see calc1anp input. And then we'll say calc1anp on my puzzle.input. How do I remember what it was called?
47:29That's the same number. So that's it, right? It's like I'm just saying, people are often like, oh, what if I'm just doing something and there's nothing to learn? So I'm just like, well, why are you doing something where there's nothing to learn? Surely you should have automated it if there's nothing to learn. You know exactly what you're doing. So then learn to automate it, or learn to do it faster, or learn to, like you're literally spending time doing a thing. Why?
47:59Anyhow. That's that. I'm going to just quickly show you five minutes, one more example before I jump over, maybe 10, before I jump over to Johno. Anything to add before I move on?
48:14No, this is a good example. The reason we're doing this course and the reason we're doing Advent of Code is not because those solutions themselves are useful to us. It's because it's fun to learn. And so we'll show some examples that are more useful. I think the one you're going to show now is maybe something that people might use in their day-to-day. But the attitude we want to engender in everybody is to get to the end of solving something and then go, huh, I wonder if I can solve that using NumPy instead, to have that kind of curiosity mindset. That's like number one prize for outcome of this course.
48:46All right, so thank you. So this is a problem I recently had to solve, which was I did a really, really interesting chat with Chris Latner, who's an old friend of mine, who I think is one of the greatest computer scientists and software engineers of our generation, and one of the
49:14most significant anybody who's both created LLVM, which is basically at the heart of every piece of software we use today and also created a whole programming language that one uses called Swift and a C++ compiler called Clang, and he's now the CEO of Modular. He's created a new language called Mojo, and he created the platform that just about everybody uses for AI now called MLIR and blah, blah, blah. So, okay, if you want to know what it's like to be good at your craft, Chris is
49:39good at his craft and he can teach us. So I wanted to take my conversation with him and turn it into a written version that respected the value of what he had given me. So I wanted it to be really good. And so is this good? Well, two days ago, you guys all know O'Reilly, right? The most famous technical book company in the world. That's named after a guy called Tim O'Reilly. Guess who
50:06emailed me? Tim O'Reilly emailed me himself direct and said, Jeremy, this is an amazing article. I really want O'Reilly to publish this, please. So I think it's a good piece of writing as judged by somebody who understands technical writing perhaps better than anybody else in the world.
50:25And I created this in Solveit and I started out with a transcript of my chat with Chris.
50:39This is a very interesting starting point. So if you go into AI and say, please write a powerful and compelling description of the power of software craftsmanship and how to do it in the age of AI, you'll get garbage. But if you start with an interview, it's more of what I would describe as a style transfer problem, which is to take words that
51:06are already there and convert them into a slightly different format. And AI is very good at that. But I still actually didn't have AI write my words. So let me show you how I went about this. I started just by telling it I'd like to write an article. And I found this interesting.
51:31It's all about creating software that lasts. So I said, remind me, basically, what are some quotes.
51:39And then I was like, yeah, yeah, yeah, this is good. Yep. I want that to be the main thing. Okay. But there are other things so again, this is saying AI is good at just like list themes list quotes. Right. So there's no chance of AI slop here, right? These are our words. It's copying them and there's no chance of worrying about hallucinations because I was there in the interview. I remember if I said it and it's very easy to check, right?
52:05So I was like, okay, those first two were kind of about the main theme I described. It's like, okay, how do we get through those other themes? So I asked for ideas about narrative paths. And I quite liked the two paths it suggested. And then, Johno, you'll remember I actually jumped onto our internal Discord and I said, guys, which one? What do you think? And so we agreed
52:34on a particular approach, which was more path two oriented. And this is really nice. It's kind of done this work for me of like, my brain's not big enough to keep all these ideas in my head. So it's really helpful for me the way it kind of put these into pieces. So it's like, okay, we chatted, we're going to go this way. Here's why. You know, but maybe I should start like why I decided to talk
53:00to Chris. So if you have a look here, you know, I've like the background. Because literally, why did I call Chris? Because I was upset, nervous, worried, wanted to know what to do about it, see if he had the same feelings. Okay, so again, give me some quotes. And then I just started writing,
53:26right? So I wrote a little markdown cell message here. And in my markdown message, I just put my heading of like what I'm going to call it, which I think I actually kept that title.
53:43And then I started writing. And then I'll say okay you write so write a paragraph about Chris. And interestingly what you see here is not what it told me. And in fact I can do that because if I
54:03copy this and I click here and I click submit then Solveit only sees what's above this message, it doesn't see what's below it. Right? So this I can basically mock exactly what would happen. So this is what actually happened. It's not going to be the same every time because it's not reproducible.
54:25But it's very sloppy. It's overhyped. It's hard to overstate. Lots of dashes. Chris didn't stop there. These aren't one thing. They're another thing. It's horrible. But I'm better at criticizing other people's work than writing my own. So I started there. And then I
54:49hit right square bracket. And that edits the answer. So I then went through and I deleted each paragraph one at a time and I didn't just rewrite its paragraph. I was like, what's the paragraph I want? But I just found it for me. I liked this approach. You know, the alternative is people will tend to be like, no, don't do it this way. Like they'll have a long conversation where they're trying to get the AI to write the thing they want. It's like,
55:16no, just edit the output to be the thing you want. And the other nice thing is now it's going to get better and better at understanding what I want. Right. And so then I wrote the next little bit myself from scratch. And I just wanted kind of little reminders where are we up to, you know, write a bit more. And then again, you know, have it write something, which I then replaced it all.
55:43But one really nice thing here is it's giving me quotes. And if I like the quotes, I just leave them. I don't have to go and find them. So, you know, a bit of a discussion about what could the next section be, what are some quotes there, and again, then I just wrote it myself. So I'm going to just go copy paste here. So I'm going to do the same thing, right? And I'm going to submit here and I'm going to see what happens and hopefully you'll find it's better than the total slop last time and if it is I'll explain why. So I'm saying plus travel, please draft two to three paragraphs.
56:18There's a question in the chat that I think relates to this of someone saying, you know, as chats with AI tends to get longer and longer, they tend to get worse and worse, like how does Solveit address this, you know, and avoid getting bogged down.
56:28Yeah. Sure. So let's just look at this. So this is a lot better, right? I would edit this less.
56:38In fact, it's nearly all quotes, which is actually what I want. It's not just hype-y garbage. And OK, so why is this better than before? Language models are autoregressive. They've actually literally been trained to predict the next word of a sentence or of a document. That's a bit of an oversimplification because they've been fine-tuned. But in the end, the thing they most want to do is to give you the most likely next word of a document based on previous documents,
57:06similar to this one. So if you've got lots of prose written the way you want it to write, then it's going to write more prose that looks like that. So it gets better and better.
57:21And the more you tell it, no, not like that, no, not like that, no, not like that. The more examples it has of things you don't want. And it's going to get really good at creating more crap that you don't want. So this is why you want to be editing the outputs. An even better trick I quite often use is I'll let it do garbage once, I'll tell it why it's garbage and how to fix it, I'll then ask it to do it again, and then I'll edit its output. So now it's got an
57:49example of it doing it correctly after being kind of reoriented. And yeah, I actually don't have too much problem with context bloat, to be honest, I find. Doing things these ways, when doing quite small amounts and it's all carefully controlled, it's basically fine.
58:13And also, there's no garbage in here. The only things in here is the conversation I want, and the actual outputs I like and the transcript I'm working from. If we literally run out of context, then it will start to truncate stuff from the top. Now, obviously, I don't want it to truncate the actual transcript that we're working from, which is why I've clicked this little pin button. See how that's red? So that means, yeah, stay there in the context all the time.
58:52But yeah, I don't know. I don't find it too much of a problem. Johno, do you have much of an issue with that?
58:58I tend to work in much shorter notebooks. I think the times I see people starting to notice it is when they have extremely long dialogues that are, you know, moving around. And so then using the, you can, you can hide certain things from context, pinning the important stuff, you know, like those tricks tend to help. Yeah. Like you, I almost never have an issue with it because I'm almost never working on, you know, a book's worth of content. It's much more like smaller pieces.
59:23Something else that happened here is then I kind of created a draft and I showed it to my team and I showed it to my wife Rachel, the co-founder of Fast AI, and got the same reaction from basically everybody, which is, Jeremy, you've kind of buried the lede. The thing you're most passionate about, you know, that you care the most about, you put too far down and it kind of starts out too dry.
59:51And so what I... What I actually did... Here we are. I've said it. This is my feedback.
1:00:00So it's like they wanted me to be more clear about my concerns, more clear about Chris's position.
1:00:09What are some quotes? Here are some quotes. It's like, OK, help me draft a new opening paragraph.
1:00:18And then I went back and I inserted that opening paragraph back at the top. So then I tell it, I've gone back and made that edit. I just kind of double check. Are there any points he made that we didn't mention, any awkward transitions? And it's like, yeah, there's a bit of an awkward transition. You know, so I asked, okay, help me with it. So then it's like, yeah, it actually did a good job. So I ended up basically copying its suggested transition. And then I wanted
1:00:44something for YouTube, which I didn't care about too much. So I edited it only a little bit. And then a few days later I wanted to send an email to folks about that interview I did at the PyTorch conference to our alumni. So it was kind of nice because I could add now and say like, hey, you know. I wrote an email, and it had all the context of the Chris Latner thing, which is nice.
1:01:12So I could say, hey, what do you think of this email? And actually, the suggestion it had was a good one, which I didn't mention PyTorch. I went back and edited it. Probably most of you received that email. And so now, I want to create another article this week from my PyTorch conference. So
1:01:30I actually duplicated that Chris Latner dialogue entirely. And I have added to the end of it the transcript of my PyTorch chat. And I said, okay, that piece was published. Now I want to write about this. What are the themes? And it's kind of nice because it knows what I'm doing. It's got my
1:02:00voice, you know, and was able to get started a little bit. Anyway, this is as far as I've got, but maybe later on I can show you all. But I think the key thing, like apart from anything else here to remember is like I didn't start with a blank slate, you know? And so something I love doing is when I do have a blank slate, is I'll just grab somebody from my team and I'll say like, can you interview me? Like literally, I'll say, please interview me. And they're like, you want me to
1:02:27interview you about? And I'm like, okay, these are the ideas I have. I want to kind of get out. And so, and then I've kind of found there are certain people who are really good at that. They're genuinely interested and they kind of ask engaging questions. And I record the whole thing. I throw the interview away, but then I go through the same writing process and I find it helps me get my voice. You know, a lot of people when they write, they default to either like some really bland year
1:02:5412 English voice, you know, three part essay voice, or they go into some ridiculous, hype-y salesman voice, but we want to hear how do you sound. So when you talk to a friend, you're going to sound like you. Otherwise your friend's going to be like, Jeremy, don't sound like that, weirdo.
1:03:13And so with those words, then you can just transfer that into an article form. So that's something I found super helpful and it's a way to use Solveit to speed things up, get much more in the flow, avoid writer's block, but not create slop. What do you think, Johno?
1:03:36Yeah. It's funny how similar the overall process looks like the advent of code and the writing is like, okay, here's some context on what I'm doing, right? We copied in the advent of code problem and we voice dictated some description and like, okay, we started with the transcript. Here's what I want to do. Then working in small pieces, looking at the output. Is that what I wanted or not quite? Yeah. So it's the same flow, but for writing.
1:04:00Yeah, it's various people asking how do I get the transcripts? I don't know if you want to talk about that. That's the main question that came up is like, how do we get that starting point?
1:04:07Sure. So there's a few good ways. We're working on a kind of transcript API, which hopefully we'll have maybe by the time people watch this recording. But actually, there's a few good ways to do it. If you use Zoom to record your interview, there's an option you can check in the box in settings to say, create a separate audio file for each participant. You
1:04:32can then drag them into MacWhisper and it'll automatically generate a diarized transcript, a transcript with people's names on it. And in particular, choose the parakeet model. It takes about a minute or less, maybe 30 seconds to do an hour. And then often what I'll then do is I will
1:04:53paste that into Solveit and say, can you please fix up this transcript? It's probably got some errors because it didn't know, you know, like in MacWhisper, you can give it vocab items like I gave it Fast AI, Solveit, stuff like that, fastcore. You probably noticed when I was using my voice prompts before, it all came out quite nicely. But you can always have
1:05:18Solveit fix errors in your transcript. Gemini is pretty good for it as well. You have to cut it up into smaller pieces. YouTube does do an automatic transcript. They're pretty crappy and they won't have that diarized interview format, but again, you can have an AI fix it for you. In the end, you'll probably find it doesn't matter too much. You'd be surprised how garbage AIs can handle.
1:05:52Nice. All right, well, should we move on to the third and final section of the day?
1:05:58Yeah, I'm excited about this. I've seen a preview and it's basically putting all this together into something that's going to blow your mind, I think.
1:06:04All right, yeah, this is a piece that I've been playing with. And actually, first of all, this is running in a Solveit container and it builds up an application. And the goal of this is to give you a bit of a taste for some of the pieces that we'll be expanding later. So don't feel like we're trying to teach you a ton in the next half an hour. It's more like a bit of a showcase.
1:06:27But I'll share this link in the YouTube chat. And the idea here is that we're going to build up this kind of side-by-side arena type voting setup where we'll put two models against each other, and then we'll pick which one we prefer. This one's kind of a tricky distinction, but I'll choose to vote for that one. And then we'll have some live votes that we can see. So feel free to open that up in a different tab while I'm going through this. And you'll see how we build that up in that same way.
1:07:00And so just like with Jeremy, he started with the advent of code, which already had a nice problem description. For this one, I had this idea in my head, so I don't have a nice written description. But I could write down, we're going to build this SVG arena. Two models are going to be pitted head to head. They're going to generate an image based on a prompt, and then we're going to store the results for later. And then I just started going through what are the pieces that I need to make this plan a reality, right? Because I could try and give that whole prompt to AI, but that's obviously not the way we're trying to work. So instead I'm thinking like, okay, what
1:07:29pieces do I need? And these are going to be pieces that some of them at least will come up again as we go through different demos throughout the course. So one of them is calling language models, right? I would like to ask LLMs to produce these pictures. So I need to figure out how to do that.
1:07:42And I thought I'd try something which I haven't used before, which is a tool called OpenRouter, or OpenRouter, I guess, asking the language models to produce SVGs, turning this into images or figuring out how to display them. And then I'd like to create this FastHTML app that actually sets up the user interface, store the votes, show the results, make everything a little pretty. So that's me just laying out like my overall objective. So that as I go through this,
1:08:07both me and Solveit have this context for what we're trying to build. And so I'll work through the pieces bit by bit. Number one was I'd like to call an LLM, or in this case, I'd like to put multiple LLMs against each other. And so I went over to OpenRouter, headed to their docs and right in the quick start there's a piece of code that I can use. And so it was funny when I was talking with Jeremy about this, I was like, oh, okay, what was the decision function for when should you go
1:08:37to the docs? When should you just ask Solveit how to do something? What are the different ways you could approach that? Because you could very easily here say, okay, I'll prompt Solveit to search and show me how to call a model with OpenRouter. I could just as easily have asked it to use its built-in search tool or its general knowledge to go off and find that. But in this case,
1:09:01because this is like the primary... Sorry, I'm showing the wrong tab. This is the primary piece of OpenRouter's functionality is that it lets you do this. I had the intuition that that would be front and center on the docs, if they were good docs and sure enough they were. And so either way, you end up with an example piece of code, but then we can take that and make it our own.
1:09:22So I listed out the models that I wanted to test and we can maybe do some good Solveit hygiene and check that those lists indeed contain what we were hoping for. And then from that example, I just use the keyboard shortcut, you know, control shift and then the minus or hyphen sign to split the cell into different pieces so that I can work through bit by bit and start to inspect like what are the pieces, right? And so even here for this one, this is what it tells you to do.
1:09:51client.chat.completions.create, specify your model and a message, and then pull the result out. And so if you're exploring this, you could start out by just looking at what is this completion thing.
1:10:03So Johno. Often I find my first reaction, and a lot of people's first reaction, is to kind of get AI to do that first bit. And I've realized it's actually almost always less good than going to the web page of, you know, like you did. And just saying like, the way you did went to the docs there is kind of like a bit retro. You know? But actually it's, often, I generally find
1:10:29that the curated first starting point provided by the company that literally or the individual that created the piece of software is generally better than the random thing that AI generates as its first example. So this approach of actually reading the docs is still useful, even today.
1:10:46Highly underrated for sure. Yeah. And you like you probably think, okay, maybe that piece of code wasn't, didn't feel like a giant piece of code, but still, yeah, reading the docs and then taking the pieces and just executing them bit by bit. Right. Like I could inspect what is this client or I get back this completion and I can look at it and say, okay, it's a completion. It's got an ID. It's got a list of choices. They've got finished reasons. I could kind of dig through.
1:11:11And so then by the time it gets to like, okay, this is what we're doing. If I wanted to ask the LLM, you know, what is the best day of the week, whatever, it's some.
1:11:20While you're typing that, I'll just, look at this button, I can press it. There we go. So at what point do we set the libraries we need installed in the environment? Which ones are already pre-installed? So actually Solveit knows which libraries are pre-installed, so you can ask it. The answer is most things that you're likely to need are pre-installed,
1:11:42and it's pretty much everything that we use in the course will be pre-installed. It's fine to install something that was already installed. But by using our version, you'll be assured that you're getting the most recent version and it'll be automatically updated for you. So I would say try not installing it first and if it says not installed, then install it.
1:12:08Okay, so in the same way, I'm going to move through this as a notebook that I've already written, so I'm not going to do too much live coding. But we're going to use some of the same practices that we've already seen of moving through my plan. I've tested out sending a message once in isolation from the example. I can now create a function to quickly wrap that up
1:12:29to prompt, to say create an image based on this description. And I can check that that works. I can look at that completion. And then I can think how might I extract the SVG path. And you know, even sometimes using Solveit, I sometimes switch modes to concise or standard where it's more
1:12:47just giving you a result straight away. But the learning mode is so good in that when you ask a question like this, it's very good at just like hinting to you like maybe this is so obvious you should do it yourself, right? Find the first and last one, you know, using Python's find. Sure. And so in that case, it was kind of like, okay, that's actually enough that I can do that myself. So I can find the first and last, find the piece that I want the starting and ending tags, I can find the string in between,
1:13:16and then I can check if I can display my little whale and I can. So we're doing everything in these small pieces. We're doing everything in this way that as soon as I've run something, I'm inspecting the output and seeing if it's what I expected and whether or not it's working. And then we can wrap that up into a function. So then I can say, here's my function now.
1:13:32Let me just pause for a moment, Johno, because I feel like this is way too amazing, and you just zipped over it. It's not because we did anything impressive here that this works, but because we're leveraging the browser. Browsers are cool, and browsers can draw vector images using a whole language designed for vector images. It's very different to something like Cursor
1:13:59or whatever where you're kind of like switching between things and setting up MCP servers to look at them. I really encourage people to lean into the fact that your browser can play MIDI files, can play WAV files, can record, can draw pictures, can show buttons, can make sliders,
1:14:21and the AI can make it, the AI can look at it, the AI can comment on how you did it. It's, this is so cool what you've done here. Like, you know, you and I, I feel like Johno, we're just, we're so used to it at this point. But there's nothing else like this, right? Because it's, it's running, like it's running on a full Linux server that we've provisioned for you. Like everybody's running their own Linux server. So, you know, it's not just a little mini JavaScript version of something and it's not going to disappear when you're done.
1:14:57Yeah, yeah, that's a good reminder, Jeremy. This is magic technology, right? We have this machine where we have running code, right? In this case, code that's able to execute Python. We have an AI that can see everything that we're doing, and that's super smart and able to just push together some symbols to create a fish. We have a way to share that with people and to inspect it and to view it in new tabs and to render it out. Yeah, I guess thanks for the reminder to like stop and appreciate the scenery here.
1:15:30And just a question on the chat. In the Discord, we have all of the links to Johno's dialogue and so forth. And in the recording, we'll also make sure that's in the YouTube description.
1:15:49Yeah. Okay, so to play on that magic even a little further, I'm now going to show building up the interface for this in Solveit. So this is going to rely on FastHTML, which is a library that we at Answer AI had developed. And again, this isn't like, don't feel overwhelmed that this isn't a FastHTML tutorial. So I might skip over some pieces fairly quickly. What I do want you to see is that the approach we use for building this is also
1:16:14the same iterative small pieces thing. Right, so we're creating a FastHTML application and It's also how Solveit's created, by the way. Solveit's created in FastHTML. Solveit's created in these kind of small steps. You can use this to create much. I think this is already a really cool app that you're creating, but you can use it to create full systems that teams of people spend over a year on.
1:16:37Yeah, and so we can create these little interactive pieces. And then this app is an application running on a port on, in this case, my machine. In the public version, it's
1:16:52the public URL that you can copy. And so if I go over to a new tab and I go to port 8000 and then type slash hello as the URL, you can see we've got our code rendering up in this case, some text or some HTML into the wider world. And that's exactly what's happening for the app itself. This is running live from the, I guess you call it the production version, right? My solveit.com
1:17:20version of the application. And so the neat thing with this is, you've all been playing with the app. I can interact with all the pieces of that. This list of votes are the list of votes that people have sent to the different AIs and which one got voted for and which one didn't get voted for. And this is all something that we can build up in this very incremental way, like one
1:17:45piece at a time, one route at a time, one small piece of user interface at a time. And so that's exactly what this dialogue goes through, just a very incremental, okay, I'd like a form that I can put as my prompt box, right? So here I've got an input to type in the prompt and a button that clicks submit. And at the moment it does nothing. It's just a piece of UI, but I can see, oh, that's starting to look kind of like what I'd want. Then I can generate some SVGs and explore
1:18:12what happens if I try to show them side by side. But in this case, I used the ghost text and it didn't do a very good job of making the kind of user interface I wanted. But that's okay. We're in this environment where Solveit can see what we can see. If you want to include a screenshot, there's a shortcut for that where you go, I think it was command shift comma? And it'll ask if I can share my screen and then it'll include the output of the previous cell. And I can ask it, could you make a
1:18:41nicer version of this piece of user interface that I'm trying to build? And so, yeah, especially as you get more towards this kind of styling side of things, at least for me, it's a zone where I tend to enjoy relying on the AI a little bit, right, for some of these heavier pieces, but also that doesn't preclude then going back to the Solveit, understand it yourself, do it in small pieces. In this case, I guess learning mode is hopefully prompting me to try it myself rather than...
1:19:09So just to explain here, so where it says output included in that prompt, so what that's done is normally the AI can only see the HTML that was generated, but if you see output included, that's because Johno hit this command shift comma and it automatically took a screenshot of the output of the previous message. So it can see that and it's not just now. If Johno did, do you want to try doing a follow up? Johno, would you say, yes, please do it for me?
1:19:39It can still see the picture.
1:19:44You could also just take a screenshot yourself and paste it, right? I'll use that to put in a drawing that I've done or something like that. Okay, it's giving us a very long and complicated one. But for now, I'll show you the version that I got on Concise Mode. And then I'll show you...
1:20:00What I've done is just taken that piece, tweaked it a little bit to check, okay, do I understand what's going on? We've got this big block, which for now I'm treating like a block of magical mystical gibberish. But then we're showing a style and then a div and it's got a heading for the model. And then it's got the SVG and then it's got a button that says vote. Okay. And that's looking, looking brilliant. The first round, it actually didn't look brilliant, but I couldn't see the
1:20:28text for the vote for this. But I could ask the AI, okay, this text is invisible. What should I change? And then it directed me, okay, this is the line you should look at. And so then immediately like this, this first pass of having the AI do a prototype, right? Or some like starting point. It gets you to like, okay, that's either close to or far from what I want. But then this revision to say like, okay, I can change a color, right? And then you start looking and you say,
1:20:57you know, the button has a background color. I can set the foreground color by adding a little piece of extra, you know, I'm not someone who loves CSS, but I can start to see how, you know, some of these pieces play together and make sense. And if you're unsure, you can always ask, right?
1:21:14That's probably the best way to learn CSS is this way is, you know, to experiment with it and see it immediately. While you're typing that in, I just mentioned there was a question from the chat,
1:21:32which is about does Solveit support working with large code bases like Cursor does? The short answer is yes. You can, we'll show all this later, you can use Git, you can clone, you can sync, you can use tools which can read and write to the code base and so forth. Also, like,
1:22:00it doesn't come up for me almost ever because I've learned to create quite nicely decoupled, fairly standalone things that work nicely as dialogues and very little boilerplate, so everything is kind of quite small and self-contained. And so to me, if you've got
1:22:24a code base that requires looking at 15 different files to answer a question, that's a problem to solve. So I could start there. If you're going to have a human-centered development process, then you need to be able to easily keep the structure of your code in your head. And Johno, you'll remember a few months ago, we over invested in agentic AI ourselves and Solveit's
1:22:52code got overly complicated itself and we lost our development velocity. And so we actually stopped creating new features and we said, right, we're not going to create any new features until we've rewound and until we've got everything so we can keep it in our heads and that all of us feel and remember we said like, okay, don't pretend, don't lie, like tell us everybody,
1:23:19are you now comfortable fully working in this environment? And until everybody was like, yes, I can work in this environment, we kind of put things on pause for a few months, didn't we?
1:23:32Yeah. Yeah. And I think it's, it's a lot harder to, you know, tell that to somebody who's maybe just one part of a larger organization or working with existing teams. So I will say there's like, there's degrees to which you can embrace or aim for this. I think at Answer AI, for sure, you know, there's the ideal and then there's the like practicality. And as long as you're aiming for that direction to say, are there ways that today I can make this a little bit more understandable, a little bit less verbose.
1:24:01That's true, yes. Absolutely. But I know in our audience, for example, we have some software directors and CTOs of really large companies. So this is to them also. It's like, you know, embrace a software engineering goal, which is that everybody in your company feels capable of understanding and modifying what's there. And maybe to folks who are earlier in their careers to speak up if things are complicated to follow or we're getting more complicated because it seems like it could be a potential road to extinction for a company heading too far that way.
1:24:41Yeah, yeah, for sure. All right, well, I will just finish showing up the pieces here of this little example. I'm trying to think how best to frame this. Yeah, it's all the same thing, I guess, is the takeaway, right? I'd like to experiment with, once I submit something in the form, having some response come back. So I can make a form that uses htmx,
1:25:06which is something we'll talk about when we get to web apps, to send a prompt off to a new route, which then returns a new UI, and then we can iterate on exactly how we're doing this side by side display. It's OK, that's looking nice. Now it's all hooked up so that it also uses this interactivity to send off to a new route. But even here, I don't know, Jeremy, you're probably looking at this like this feels like the upper bound on how much I'm comfortable doing at a time. And the only reason I'm comfortable with this is because this is a
1:25:36modification of a version of that piece that I'd already done. This is a modification of a version of that function that I've already written. And it still feels like if this was more than a one-off demo for this lesson, I would probably come back and figure out ways to tidy this up even further.
1:25:50If you scroll up a bit, just back to where you were, I mean, I mean, apart from anything else, I'd feel reasonably comfortable with this because it's very obviously duplicate code that we can very easily remove, like because we've got two buttons doing basically the same thing. And I'm very much with a view of like this idea of DRY. Don't repeat yourself can be definitely taken too far. I would say like when you're playing around, just repeat yourself, you know, JRY, just repeat
1:26:19yourself. And at the point that you're repeating, repeating yourself, then it's like, okay, factor it out, put it in a function. But this is, I think, very easy to keep in my head. If I found I had a bug more than once that I forgot to add some attribute, and now I've forgotten to put it in both the two places. And again, I'd be like, okay, pop it in a function. It's also the kind of
1:26:44thing that Solveit's very good at doing for you is just like say, hey, can you refactor those buttons out into a function? You know, a little stuff like that. I try to keep my limited intellectual capacity to where it's useful. So for something like this, yeah, I wouldn't mind it, you know, and if it doesn't do it perfectly first time, then I just go and do it myself. But I bet that would work. And we haven't told people, you could now hit W, Johno, do you want to tell people about W?
1:27:11All right, yeah, there we go. There's the piece again then we want yeah it'll use that pair So do you want to talk about W?
1:27:23Okay, yeah, right. So W is a shortcut that would take any code blocks from the AI output and immediately add them as a new code message. So that was how I was able to very quickly ask for, in this case, a refactor or a new piece of code, and then just hit W to get it and then shift enter to run. So if you are asking for snippets or could you give me an example, SVG, I can use with this, whatever, like small pieces of code you're requesting from the AI. It's a very quick
1:27:50way to get into it and start editing. And then you can always come in and edit further and say, I'd like to clean this up somehow, or, you know, change what order things go, whatever like modifications you want to do, you can go back in and do them.
1:28:05Quick question here. Just I think that the common misunderstanding here is when we're saying keeping things decoupled and reasonably architecturally clear that doesn't mean we do everything in a single dialogue, you know, so Solveit's not a single dialogue. I think it's nine now and we will be teaching you during the course how to structure these things but like I think most pieces of software of Solveit's complexity would be many hundreds of files if not thousands. So nine is not bad.
1:28:37Yeah. Yeah, we have the export functionality that we'll show in future lessons for packaging up just say the core functionality separate to the exploration into a piece that I could reuse.
1:28:50But you'd be surprised how far like a lot like Discord buddy is an example that some of you have interacted with already, right? Discord buddy is a chat bot in our Discord. You can ask it questions. That entire application is written in a dialogue by our colleague Eric. And you can go in and explore. You can see his thought process all the way from like learning the Discord API and interacting with LLMs to like bring all the context together to the full running app is there
1:29:16in the dialogue. And any of us can then go in while it's all live, while it's running, add extra routes, investigate the database, add some new knowledge to the repository that it's drawing from, test something out. So you'd be surprised how far this kind of like dialogue as an artifact scales. And you may have noticed while I was showing mine, I just have the sections collapsed that I'm not working on at that moment. So you can always like organize things by headers. You can...
1:29:41And to be clear, so the question here about can you show the keys we're pressing, we'll show keys in future lessons, but like for this one, we're not trying to provide a documentation of how to use Solveit. We're trying to describe the ideas. And as we get further into the lessons, we'll be driving further and further into the details, including what buttons to press.
1:30:06It's a good, like, if you see some particular action, like, how did he expand that collapse section? What was the keyboard shortcut? Dump that in the chat and whichever of us is not speaking can either answer there or I can say, hey, just by the way, I'm using left and right arrows to expand or collapse the different markdown sections. You know, we'll...
1:30:23And there's also a there's a button in Solveit, you can click that'll show all the keyboard shortcuts. And we added them all for a reason, so they're worth learning.
1:30:28Yeah. Yeah, no. So, but if you see something magic ask, but we'll also, this is lesson one, hopefully like the tasting, you know, amuse-bouche of the menu. And then over the next five weeks, we're going to be expanding some of these examples, spending a lot more time working together, pairing on everything from more advent of code to the pieces. Yeah. So you'll see all these patterns.
1:30:48Yeah, and again, as I mentioned at the very start, it's like this question about, how do you take this and what do you do? We're going to get to all that. OK, so it can all be fully automated. We've got lots of systems in place. Don't worry about it, OK? For now, a bit of copying and pasting or go and Google nbdev. It's all integrated into Solveit. And yeah, all these details we're going to get to. But at the moment, we really want to focus on the techniques that hopefully you can start to use in whatever software you're using.
1:31:23Fantastic. All right. Jeremy, are there other? All right.
1:31:30The final piece. Okay. Let's see. Was there much more that we hadn't covered? All right. Okay. So we're creating a list of votes and a route that takes the winner and loser and prompt and stores the vote. I think in the final section here, just marginally before the lesson went live.
1:31:52So can we see, well, I want to see the, you know, what you got.
1:31:52I quickly asked the AI to help me add a title and some styling, tweak the vote route to show things like how many winners and losers were there. And all of this is stuff that I would really recommend. If you were actually going to use a piece of code like this, and you've now had the AI give you some larger chunk, but this isn't a piece that I built up
1:32:16piece by piece, split this back out, which I was maybe going to do if we had a lot more time. Look at the sorted models list and then look at the tally display and then look at the group together.
1:32:27But this is pretty much all there was to it other than a few like styling tweaks. Right, yes, that's this application here. So I could type in, I don't know, a dog, see what the AIs do.
1:32:43And just to be clear, it's not that you exported this or deployed it or anything. Like anything that's running inside your dialogue is also a running app that other people can use. You just click the share public URL button. And it's kind of really nifty because if Johno, do you want to try it? Johno, change your message and run it. Yeah, this is cool. And I can see the votes appearing right in the app. And if Johno changes one of his messages and runs it, which defines a route, he doesn't have to redo anything.
1:33:15Yeah, so let's change the name of this. Let's rebrand this to drawbotarena. So I'm overwriting the index route. So if I go back to the app and I load it, the live app has changed, everyone, if you visit that public URL, which is the URL of my instance, you see.
1:33:34And there's nothing in the background like regenerate, like because there's no build step here, it's like literally running from the running Python interpreter. It's a really kind of unique way, well, not unique, it goes back to how Lisp and Smalltalk used to work, but it's something that has been slightly lost to time, but it's such a cool way of running apps live and modifying them as you go. And like literally the code's appearing, the results are appearing here in Johno's dialogue in real time.
1:34:06Yeah, yeah, we can watch as new ones roll in. Yeah, so I know, I think this is a somewhat silly example of the category, but this idea of being able to build up dynamic web applications, be able to add functionality on the fly without the app even having to restart, be able to share the source code in a way that someone can make their own version and then deploy it on a public URL without having to worry about setting up and configuring. It's a ton of fun. It's a really enjoyable way to work. And I hope we see you.
1:34:39And so then, yeah, that's great. And so Christopher is asking how long the live URL lives for. It lives as long as you run it. So if you click in the top left on the Solveit button, it closes your dialog. So if you don't click it, it just keeps running forever.
1:34:56And you can create multiple instances, each running with their own app. And we don't actually have any real scores yet, do we? Do we need to make, we need to provide this to the community so that they can all decide which model is best.
1:35:11Yeah, let's see. Okay, so I restarted just before the thing. I think it shows the tallies. The current rankings, GLM 4 plus has four votes, Gemini 2.0 Flash has four. Minimax M01 is only featured in one or two. We'd have to, I think, get a lot more people voting to average those out. But in general... All right, I'll leave my public instance. I'll have to start a new one for a new application so that this can run for a bit and collect some data.
1:35:40All right, so let's get the students doing it. Great. So, yeah, so we're through from here. It's hard, right? Because I've kind of been living in this exploratory programming world for nearly 10 years now. And actually in some ways, ever since I first started using Mathematica like 30 years ago, I've always wanted, this is my thing, I've always wanted is to be able to like craft my code,
1:36:06you know, like I'm molding it and chipping away at it and seeing it happen in front of me. And for anybody following Bret Victor's work, it's very similar to this idea that you're watching what you create and it's right in front of you. But it's so different to the normal IDE, agent,
1:36:27multi-file, build step, whatever. And so that's okay, you know. But hopefully at least it's giving you this idea of like, can you make your steps a bit smaller? Can you make your iterations a bit faster? Can you make the feedback you're getting a bit, you know, more direct, you know, so that
1:36:53you're not going to have weird bugs. Like, I never need a debugger. Like, I'm pretty good at using a debugger. I think they're a very clever piece of technology, but why would I need one? Because if I have an error, it's because the last two lines of code I wrote had a problem. I can immediately see it. So hopefully, I think it's just like, can you bring a little bit of this style into your work,
1:37:17you know, and maybe can you practice it in the Solveit platform with something, you know, maybe you could try to build a little pipeline module or solve an interesting advent of code thing, or, you know, it'd be great. Is there a video out there that you'd love? And wouldn't it be cool if for that person you created a marvelous article version? Like, is there a Fast AI lesson that you think is great, you know, or is there a Lex Fridman interview that you find fascinating?
1:37:49Anything like that is going to be amazing and an opportunity to practice these ideas.
1:37:56As far as concrete homework goes, I think the other thing that I want to mention when we're encouraging that is that it takes a little while to get into it, right? So share your results. But also, especially these first couple of weeks, if you're trying it and finding that, you know, your natural instinct is to go back to four or five lines, line does a bit, then there's four or five steps at a time. It really does require some deliberate practice to
1:38:21unlearn the habits and to learn the new pieces. Hopefully, I see someone commenting, it looks daunting. Yeah. Hopefully, you try it and find that the more you start to practice this approach, the more effortless and natural it feels, but that does take a while. There's a big hump to get over. And so I'd really encourage all of you to go actually try and put these into practice, load up an advent of code or two. Yeah, just really attempt to get your hands dirty with this approach because it's something worth practicing, I think.
1:38:52Thank you, Johno, and thank you everybody for staying with us. Thus ends lesson one. I hope you got something out of it. I had fun, and see you next time. Bye.
1:39:04We'll see you in the discord. Cheers everybody.