back to index

OpenAI's ChatGPT API First Look


Chapters

0:0 OpenAI ChatGPT API is here
3:2 Testing the new ChatCompletion endpoint
3:31 Comparing this to ChatGPT app
6:54 More testing of ChatGPT API
8:7 Formatting ChatGPT responses
9:58 Feeding responses back into ChatGPT
11:21 Final thoughts on ChatGPT API

Whisper Transcript | Transcript Only Page

00:00:00.000 | OpenAI have just released their API endpoints for TrackGPT.
00:00:05.060 | What we're going to do is have a quick look at what that looks like
00:00:08.900 | and how we can actually use it.
00:00:10.500 | So they've just announced it in this article here, introducing
00:00:15.200 | TrackGPT and Whisper APIs.
00:00:17.600 | Now, I'm not going to talk about Whisper APIs, but we've covered them before.
00:00:21.500 | So you can go and watch those videos if you're interested.
00:00:24.500 | But what is really exciting is TrackGPT, finally, we can use it through
00:00:29.460 | the API, which is pretty cool.
00:00:31.500 | Now, this article doesn't really cover anything.
00:00:34.000 | They just kind of mentioned this, which is pretty impressive.
00:00:38.100 | So the cost reduction, and if we scroll down, I think they are more
00:00:43.100 | specific about it elsewhere, but we'll cover that in a moment.
00:00:46.700 | But if we scroll down, we just see a couple of use cases, which is pretty cool.
00:00:50.360 | So you have Snapchat using it, these guys who I'm not really familiar
00:00:54.800 | with, Instacart, I think we also have Shopify here, which is pretty cool.
00:00:58.900 | They have TrackGPT, which is providing a chat interface, but they're also
00:01:05.000 | pulling in information from elsewhere.
00:01:06.940 | So, you know, they're doing the whole knowledge base thing here and feeding
00:01:11.040 | that information into the chat interface.
00:01:13.900 | And we see more in-depth example of that here from Toby, who's the CEO of Shopify.
00:01:18.740 | And you see that they're bringing all these other resources and kind of fine
00:01:23.900 | tuning what they're searching for based on that.
00:01:27.100 | Now returning back to the 2ChatGPT, let's come up here and we have somewhere near
00:01:34.300 | the bottom of the article, we have a little bit of code here, and it's just above this
00:01:37.900 | that they mentioned the price difference.
00:01:39.560 | So this is the ChatGPT model.
00:01:41.900 | All right, so if you've used OpenAI's endpoints before, you probably
00:01:45.740 | are familiar with Text Adventure 0.0.3.
00:01:47.600 | Now what we can use is this model, which is apparently pretty easy to migrate
00:01:53.700 | from, small amount of adjustment needed to their prompts.
00:01:56.900 | Yeah, and it's a lot cheaper.
00:01:59.460 | It's a 10 times cheaper than existing GPT 3.5 models, which were
00:02:03.860 | already pretty cheap to start with.
00:02:05.660 | So this is seemingly better performance than this, and it's also 10 times cheaper.
00:02:12.900 | So it's a pretty good upgrade.
00:02:14.540 | Now we have some demo code here, and then we can come to here
00:02:18.460 | to get a more in-depth guide.
00:02:20.340 | So we have chat completions, go down and some code here, right?
00:02:25.240 | I'm going to basically replicate this here.
00:02:27.140 | So we come to here, all I've done here is just pip and sort OpenAI.
00:02:31.540 | I come to here, I set my API key.
00:02:34.540 | Now to get that API key, you need to go to platform.openai.com.
00:02:40.800 | You should see in the top right, there's like a signup or your actual account.
00:02:46.460 | So you go into there, view API keys, and then you just click create
00:02:50.400 | a secret key here and get going.
00:02:52.640 | That secret key would go in here and then we would come to here.
00:02:55.700 | So this is our chat completion, create.
00:02:58.000 | So kind of what you just saw right here.
00:03:00.740 | So let me just copy this and we'll try it.
00:03:04.440 | So this is literally my first time trying this.
00:03:07.760 | So let's run this and just see what we get.
00:03:10.940 | All right.
00:03:11.540 | So finish reason start context.
00:03:14.540 | So we get this.
00:03:15.740 | I haven't read this conversation.
00:03:17.400 | Was it who won the World Series in 2020 Los Angeles Dodgers?
00:03:22.860 | Where was it played?
00:03:24.000 | It was played at Globe Life Field in Arlington.
00:03:28.020 | Okay.
00:03:29.020 | That's pretty cool.
00:03:30.020 | Now what's probably more interesting is if we, you know, I want to see if this
00:03:35.160 | is actually the same model as what we would be getting from ChatGPT, like
00:03:40.460 | through their actual interface.
00:03:42.260 | So I had a quick conversation earlier.
00:03:44.220 | It was, so I just asked, you know, what are sentence transformers?
00:03:47.480 | Gave me a bit of an explanation.
00:03:49.020 | Can you show me how to implement something like this?
00:03:51.220 | For question answering, gave me tip glasses.
00:03:54.160 | You know, it wasn't great.
00:03:55.260 | Give me some models that I, you know, wouldn't recommend using.
00:03:58.960 | So I asked it, can you fix that?
00:04:01.280 | You know, so on.
00:04:01.880 | So I'm going to take these, let's just see how we'd actually implement
00:04:05.980 | this, but through the Python API.
00:04:09.020 | So I'm going to take my first question.
00:04:11.380 | Now here we have web user, so system user assistant, right?
00:04:16.520 | So this system here is like the primer for the model.
00:04:20.120 | So this is kind of like before the chat.
00:04:22.120 | So this is before I even say anything up here.
00:04:24.320 | So we can just leave it as you are a helpful assistant.
00:04:28.220 | I don't know if that's going to produce the same sort of result as what we just
00:04:31.180 | got, but let's try and let's just say, you know, what are sentence transformers?
00:04:36.360 | See what we get.
00:04:37.360 | Okay.
00:04:38.260 | Sentence transformers are a class of deep learning models that are specifically
00:04:42.160 | designed to generate high quality sentence embeddings.
00:04:44.960 | Okay.
00:04:46.220 | And let's compare that to what we've got on the other side.
00:04:48.660 | Okay.
00:04:49.460 | Uh, it's pretty similar, but this one is, I would say significantly longer.
00:04:54.360 | So I imagine it's probably a token limit that we can set up here.
00:04:58.280 | Let's take a look.
00:05:00.020 | So maybe this is what we can, we can add in here.
00:05:05.820 | So this seems to be like a system message that they sometimes
00:05:09.320 | use to prime chat GPT.
00:05:11.260 | So let's replace the first part with that.
00:05:14.460 | Let's put that up here.
00:05:15.260 | Primer.
00:05:16.200 | So knowledge cutoff is I think September.
00:05:22.400 | I don't know if we need to enter this, but September, 2021, and the
00:05:26.400 | current date is March, 2023.
00:05:32.060 | Kind of weird.
00:05:33.860 | All right.
00:05:34.400 | So primer, I'm going to put that in there and I'm going to rerun it and see what we get.
00:05:38.900 | Oops.
00:05:40.300 | I need to also run this.
00:05:42.900 | Okay.
00:05:43.000 | Okay.
00:05:45.440 | So we get like slightly different output.
00:05:47.860 | They're slightly different to what we, what we got initially.
00:05:50.960 | Let's have a quick look at the chat completion and such a limit.
00:05:57.040 | In the case of max tokens, temperature and max tokens are
00:06:01.700 | too many options developers.
00:06:03.360 | Okay.
00:06:03.600 | So I think this is the same as the usual inputs that we provide.
00:06:07.900 | So if we go max tokens and say 500, run this again.
00:06:15.040 | Okay.
00:06:16.060 | So we actually used not that many.
00:06:18.400 | Can I try and force it to go longer?
00:06:22.140 | Probably not.
00:06:22.800 | Yeah, but what we probably can do is make it go shorter if we wanted to.
00:06:29.140 | Okay.
00:06:30.940 | Let's kind of short and let's do 50.
00:06:33.660 | Is that shorter?
00:06:35.940 | Completion tokens, 39, 55.
00:06:39.440 | So it is modifying it.
00:06:40.800 | So you can see the total tokens here, actually.
00:06:42.880 | So if I put that down to 50, we should not go 50, I think.
00:06:47.280 | Okay.
00:06:48.200 | So maybe it's 50 in completion.
00:06:51.440 | Okay.
00:06:52.540 | It's cool.
00:06:53.440 | Right.
00:06:54.680 | So let's carry on that conversation with the other parts I added in there.
00:06:59.640 | So I'm going to increase max tokens.
00:07:02.040 | And what we will do is just copy in the other responses I got.
00:07:06.140 | So the first answer I got was this, pretty long.
00:07:09.840 | Let's pull that in.
00:07:11.440 | So this one's going to be the role will be the assistant.
00:07:16.640 | And the content will be what I just got, but I need to format it a little bit better.
00:07:27.840 | Actually, I can go.
00:07:30.340 | Okay.
00:07:30.640 | It's messy, but it's fine.
00:07:36.940 | We can do that.
00:07:38.240 | And then I'm kind of curious.
00:07:40.340 | What would it do if we fed that in and didn't say anything from the user?
00:07:44.940 | Let's see.
00:07:46.640 | Okay.
00:07:47.340 | So it's literally just like nothing else is needed, which is cool.
00:07:50.840 | So it knows.
00:07:51.440 | Right.
00:07:52.440 | Next one, I'm going to do user again.
00:07:58.940 | And my response to that was this.
00:08:01.040 | Let's see what we get.
00:08:03.340 | Right.
00:08:07.940 | So we get a lot more here.
00:08:10.440 | Let me do response so I can format this a bit nicer.
00:08:14.140 | So we have choices.
00:08:16.040 | First one.
00:08:17.340 | So response choices.
00:08:20.040 | Then we have message.
00:08:28.740 | Let me run that.
00:08:29.840 | Okay, and I'm going to go with content.
00:08:35.040 | And let's print now.
00:08:38.640 | It's also in Markdown.
00:08:42.040 | So we can actually print to Markdown.
00:08:44.340 | Let me have a quick look at how to do that.
00:08:47.040 | Naturally, let's ask chat EPT how to do that.
00:08:49.940 | How do I print Markdown in Jupyter?
00:08:55.440 | Jupyter notebook.
00:08:56.340 | How do I print it with Python?
00:09:01.240 | Via Python.
00:09:06.040 | All right, cool.
00:09:09.440 | So we do this.
00:09:10.740 | Okay, let's try that.
00:09:16.640 | Perfect.
00:09:17.940 | So then we come to here and I'm going to display.
00:09:21.340 | Markdown.
00:09:24.840 | Let's see what we get.
00:09:27.840 | Right.
00:09:28.540 | It looks pretty cool.
00:09:30.040 | Implement sentence transformer of question answering.
00:09:35.540 | Okay.
00:09:38.840 | Okay.
00:09:39.340 | We using Squad 2.
00:09:40.340 | It's better than the one I got before actually, which was like this.
00:09:47.740 | Which is like NLI meet tokens.
00:09:50.940 | I wonder if this one is more up to date.
00:09:52.540 | Curious.
00:09:54.340 | Okay, cool.
00:09:55.040 | So let me ask a similar question to this.
00:09:57.840 | I wonder here if we can go choices.
00:10:00.840 | Zero message.
00:10:04.840 | Can we feed this directly back into it?
00:10:08.040 | So we have content.
00:10:09.040 | We have role.
00:10:10.140 | I think maybe we can.
00:10:11.340 | All right, so we'll just call it response one.
00:10:14.240 | Right.
00:10:16.340 | And what I'm going to do is come to here and I'm going to put response one.
00:10:22.440 | And then I'll put my next question.
00:10:24.940 | She has to be role user content.
00:10:30.040 | I would say do you have any other model was better suited to Q&A?
00:10:34.540 | Right.
00:10:35.740 | Okay.
00:10:36.240 | See what we get.
00:10:37.740 | Response.
00:10:39.740 | Yes, there are a number.
00:10:41.240 | Okay, so that works.
00:10:42.040 | You can feed the responses directly back into there using these.
00:10:46.140 | I can't remember what it says.
00:10:47.140 | It's like a I shouldn't do that.
00:10:49.140 | Should do this.
00:10:51.840 | All right.
00:10:52.140 | So using this opening, I object cool.
00:10:55.640 | It's good to know.
00:10:56.940 | Yes, there are a number of training models and then, you know, see we can
00:11:00.040 | we can take that out again.
00:11:01.640 | What was it?
00:11:02.340 | It's like choices.
00:11:03.840 | Zero message.
00:11:07.140 | I think yeah message and then it was content.
00:11:10.940 | So then we just display markdown.
00:11:14.740 | Let's have a look.
00:11:16.640 | All right, nice.
00:11:17.640 | So Berkeley way Albert electric you a DPR nice.
00:11:21.840 | All right.
00:11:22.240 | So that I think looks pretty cool just as a you know, it's just a very
00:11:27.040 | quick intro to chat GP as I mentioned.
00:11:29.940 | This is the first time I'm using it as well, but it looks very cool.
00:11:33.140 | It's pretty promising.
00:11:34.140 | I would like to try this with a few other things see how does the
00:11:37.140 | instructions and so on but we'll do that in another video for now.
00:11:40.640 | I'll leave it there.
00:11:41.340 | So I hope this has been interesting.
00:11:43.640 | Thank you very much for watching and I will see you again in the next one.
00:11:57.640 | (gentle music)