Traditional Model Example

This lesson preview is part of the The Basics of Prompt Engineering course and can be unlocked immediately with a \newline Pro subscription or a single-time purchase. Already have access to this course? Log in here.

This video is available to students only
Unlock This Course

Get unlimited access to The Basics of Prompt Engineering, plus 80+ \newline books, guides and courses with the \newline Pro subscription.

Thumbnail for the \newline course The Basics of Prompt Engineering
  • [00:00 - 00:17] Now, let's actually walk through an example. I'm gonna open one of the many LLMs that are on the market and how about transforming a Wikipedia, wiki formatted article and putting it as a JSON to be easily consumed by a front end.

    [00:18 - 00:24] Okay, good idea, let's do that. I'll take a random Wikipedia article.

    [00:25 - 00:35] There's usually a random article button. (silence) Let's do Billy Joe.

    [00:36 - 00:49] Now, let's do what we, let's follow the first advice we gave and try this with that over prompting. Let's see if we can do this with a really uncomplicated prompt.

    [00:50 - 01:26] So, let's say, can you turn the Billy Joe Wikipedia article into JSON objects. Let's see if we can actually get the Wikipedia article through, okay, so name Billy Joe, birth name, William Martin Joe, birth date, the other birth place, singer-songwriter, pianist, composer.

    [01:27 - 01:32] Okay, so far so good. Oh, 1965 present, is he still making music?

    [01:33 - 01:55] Yes, he is. Okay, so we can see it's taking info from here and it seems to be getting quite a lot of info and this is potentially a usable JSON template, but now let's ask it, just for the sake of argument.

    [01:56 - 02:08] Can you create a JSON object? Wikipedia page for Genghis Tom.

    [02:09 - 02:28] I'm picking a name at random here. Okay, so we have name, birth name, birthday, birth place, death date, death place, titles, rain.

    [02:29 - 02:45] So you can already see that this JSON object is not the same format as Billy Joe's one. Let's try and do something that's going to be more consistent and this hopefully demonstrates the use cases for writing a more complex prompt.

    [02:46 - 02:56] So let's say you are an archivist. Who loves storing knowledge in compatible and reusable formats.

    [02:57 - 03:22] Turn the following Wikipedia articles into JSON objects. And we're going to say Billy Joe, Genghis Tom.

    [03:23 - 03:42] And let's throw it out a fictional character as well. Yeah, bluebirds.

    [03:43 - 03:54] So we've given a bit of detail. We've specified a couple of things we wanted to do.

    [03:55 - 03:59] Now we're going to give more detail. We're going to specify the format.

    [04:00 - 04:08] So the format here is going to be really important, right? Because we want a JSON object, we want it to be compatible with our program, with our API calls.

    [04:09 - 04:18] I'm going to make some assumptions about our API calls. JSON object must have the following fields.

    [04:19 - 04:39] So name, article link, probably important. So these things are not always going to be present.

    [04:40 - 04:45] Not always going to be present. Bluebird is probably not going to have a birth name.

    [04:46 - 05:11] Let's say for articles about humans, the JSON object must contain birth date, death date. This can be a null string.

    [05:12 - 05:25] No, not a null string. This can be alive if the person is still living.

    [05:26 - 05:56] Now we can get a lot more specific with this, but for the sake of time, I'm just going to keep this kind of simple for articles. Animals, JSON object should include the Latin name, and genus.

    [05:57 - 06:04] OK. So we're specifying quite a few things here.

    [06:05 - 06:17] I'm also going to give some context. This is test data for API that is consumed by frontend.

    [06:18 - 06:28] So let's say we have something in the frontend. We have a nice chats in UIR stencil or whatever that's going to take some of these Wikipedia pieces of information from Wikipedia and display them.

    [06:29 - 06:43] Are we missing anything? Yes, we are missing the example of JSON object.

    [06:44 - 07:19] So this is probably not a real-- I forget how JSON formatting works, but it would be something like-- I forget if you have to put a semicolon. I'm going to just put one, even if it's wrong.

    [07:20 - 07:30] Presumably when we're making this prompt, we would check the surname, John Doe. So we specified name.

    [07:31 - 07:53] We specified article link. comma not semicolon.

    [07:54 - 08:05] Thank you. Type, because this is mandatory.

    [08:06 - 08:16] Obviously, if we give conflicting instructions, like we say something is mandatory, and then don't use it in the example, that is not going to help getting consistent records. So this type is a person.

    [08:17 - 08:42] And because it's a person, we also want birth date and death date. Something that's important would form it.

    [08:43 - 08:51] If we're doing anything with dates, it's actually really good to specify the date format. This is one that I often forget, and often annoys me.

    [08:52 - 09:02] And actually, I prefer date format, because I worked with teams that were spread across the US Europe and Asia before. Dates always got really annoying.

    [09:03 - 09:12] So I'm a big proponent of the ISO standard for dates. Nobody actually uses it, but it's nice neutral one, but it's pretty hard to get raw.

    [09:13 - 09:17] OK. Let's say we want to do that.

    [09:18 - 09:33] I don't know if those off that object correctly, but I think it's enough for the lesson. So if you've given a role, we've given instructions to turn through Wikipedia pages.

    [09:34 - 09:38] We've given some detail here. We've given the format.

    [09:39 - 09:44] We've given some pretty specific instructions turned by turn. And we've given a condition here.

    [09:45 - 09:53] Actually, because we're using a tradition model, there's a chance that my trip up here, this actually probably would be a better use case for a reasoning model. But let's see how it does.

    [09:54 - 10:05] OK. Yeah.

    [10:06 - 10:15] We specified the date format there, and it seems to have followed it pretty nicely from the example. Type human article link.

    [10:16 - 10:21] Nuscan, type human, birth date, 1162. I'm going to believe them.

    [10:22 - 10:29] Presumably, this isn't in the full area I'm on date for it, because this actual birth date is unknown. I am not going to check Wikipedia.

    [10:30 - 10:39] I'm going to just presume that's the case. And we have the Latin name and the genus, which I realize now that the genus is usually part of the Latin name.

    [10:40 - 10:46] So this was probably redundant. But we've gotten a very consistent result.

    [10:47 - 11:01] We have gotten a result that presumably can be consumed by our imaginary API. It also didn't make the small mistake I made, which I think I left a comma on the last line of the JSON object.

    [11:02 - 11:07] So now we've gotten something much more specific, right? In some cases, these results would have been fine.

    [11:08 - 11:11] But there's a lot of data. We didn't give it a lot of specificity.

    [11:12 - 11:19] So it took everything it could and put that into a JSON object, right? So in some use cases, this would have been fine.

    [11:20 - 11:29] But if we're using an API, we probably want a rigorous and pretty consistent format. That's what we've achieved by giving a much more specific problems.