We're going to spend a little bit more time with GPT just to try out a few more interesting things.
I want to start with a question that used to be asked of an earlier version of GPT.
I think it was GPT two to show its limitations, and we'll see whether it still has a problem with it.
The famous question was how many rainbows?
Sounding interesting?
How many rainbows does it take to leap from Hawaii to 17?
An interesting question.
And GPT two, I think it was, responded very firmly that it takes three rainbows to leap from Hawaii
to 17, clearly missing the nuance of the question.
Uh, but GPT four has no such problem.
You'll see.
It gives back a witty and fun response, and it even includes a rainbow emoji in its response.
It's astonishing.
So there you have it, a very easy to deal with this kind of trickery and in fact, because GPT four
O, the O stands for Omni, representing that it is multimodal.
We can of course say please generate an image of this.
And it's you know, I know everyone has seen this sort of thing before, but it's funny to think that
just a few years ago, people were debating whether it would ever be possible to have an LLM that would
be able to show some kind of imagination or creativity, and now it's almost a foregone conclusion that
this, this kind of thing can be generated, this astonishing picture of Hawaii, the number 17 and
leaps of rainbows getting there.
I mean, it's honestly it's just amazing.
Absolutely amazing.
Uh, so and it even explains itself and it's, uh.
Yeah, it's so very effective at this kind of creative challenge.
All right, on a different note, let's try out GPT four with canvas.
Another of the newer features that we have from GPT.
Um, and this allows you to work very collaboratively with, uh, with OpenAI.
Um, and let's let's look back to the Python question that I had asked you a while ago.
Let's say, um, please use canvas to work with me with this code.
Uh.
Let's see.
Yield.
From now, I'll do something that's maybe not.
I'll change it a little bit.
Yield from, uh, book get author for book in books, uh, using a list comprehension.
And I'm not telling it what books are or what this means.
I'm just giving it this line of code and seeing what it makes of it.
So let's see what happens now.
So first of all, it opens up this canvas that you'll see on the right hand side, which gives us an
ability to iterate with it on this code.
Uh, okay.
And there it has it.
Um, uh, it's showing the code.
Please, uh, extend this to show an example of this being used And what we'll see now is you'll see
a sort of cursor going through, and it's going to rewrite and embellish, enrich what we had there.
And so now that piece of code has been turned into a generator.
It's got some data that gives an example.
And it's understood that there are books with a title and an author, and it's got like a little test
example of it.
So effective the way you saw it coming through and rewriting.
So now let's say please modify this code so that the generator excludes books with a missing or empty
author.
And you can imagine this might be like a business requirement that comes through.
Uh, and what you'll see there is something that looks really similar to the code I had there.
It went through it, gave some more examples with an empty and a missing book, and then it rewrote
this line.
It's so, so good the way that it that it's able to sort of interactively add to what we've done before.
And so now let's say please update this so that it only yields unique authors.
I'm being sort of loose with my language.
I'm not saying even what what I want it to to to update.
And now through it goes and it's done the job it's gone through.
It's added in another example with the same author, and it's updated this code so that it uses a set
to keep track of what it's seen and only yield unique cases.
Now, this is in fact, I think, a better solution than the one liner that I had.
But it is lengthier.
But there are various reasons why it's probably better to do it that way, but let's still see if I
can't get it.
To rewrite this in a simpler way, let's just say is it possible to rewrite the Yield authors generator?
Let's just say to simplify.
To simplify the let's let it have a shot at that.
Through it goes.
It's not changing that.
And there we go.
And it has indeed done exactly basically, again, slightly better than the code that I had left you
with on a previous slide.
It uses the curly braces to represent the set.
Uh, it could have just said yield from that line, but it's chosen to do it this way, and it looks
very effective to me.
So I am staggered by the whole experience of working with GPT in this way, and the way that you're
able to be so interactive, the way it will do things like build example data and it will update things
and show you what happens.
So yeah, extremely powerful and something which I really encourage you to use as we're going through
this course and you get things that you're stuck with, the trick if it doesn't bring up the canvas,
is to use the words use canvas, and then it will come up and use this as a tool at your disposal to
help explain and work through problems and ideas.