Welcome everyone.
Good morning. Good morning.
2023 companies are in a frenzy. They flooded developers with an interesting request. A way to use generative AI to name pets after their favorite songs sounds absurd. Right.
Well, now, while developers aren't being inundated with requests for pet names, they are really desperate to harness the power of AI for their unique challenges. They want a solution, something adaptable and transformative.
I'm Brooke and together with my co-host, we've already trained over 7000 builders in machine learning on our hit Twitch show. Today, we're going to show you how the underlying tech that could name your pet after your favorite Taylor Swift anthem could be tweaked to solve real world business challenges.
The magic. It's all in the prompt. Let's dive into the world of generative AI.
So I'm Brooke and I'll be covering the ABCs of generative AI.
Fred Gra, I'll be covering how we built it and I'm Ben Cashman. I'll be taking a look at our prompt and how we decided to do what we're doing with our application.
So now, you know, a little bit about us, we would like to know a little bit about you if you haven't been in one of these sessions at Reinvents so far that has live polling.
Uh your job as the audience is to scan the little QR code up on screen and then punch in the code 974591. If you're watching at home and YouTube in the future, welcome, enjoy living in the future. The cha the thing would be up for you but it will be back later.
All right, we've got some votes coming in. That's quick. This is really helpful because I think even a year ago, we would have all answered this quite differently.
Ben and Fred would you have answered this differently as well a year ago?
No, absolutely. That would, I would have been right there at the top two. I would have told you XGBoost is great. I will not accept any XGBoost slander here.
I also like the first one that says I don't use or build with generative AI, I would like to add yet to that one because I think after the announcements that are happening in the keynote with Swami.
Exactly right now. Thank you for your dedication to coming to this. Instead, I think lots of that will change for a lot of people.
So we're about to close out the poll. Please punch it in. If you have not already, the clicker does work.
Uh so the ABCs of generative AI, if we swap back over this started because I speak at conferences all over the world to different developers and lots of people were coming to me and saying that I know I'm a good developer but I just don't know what to google to figure out how to work with generative AI.
There's so much jargon, I don't know where to start and I can't get good and clear definitions for lots of the key concepts. So I can then actually build.
Um and then, so I was just messaging people in DMs different things. Oh, this is what a transformer is.
Um and then, so I just made it as a blog post publicly so you can view that here. We're not gonna go through the full alphabet.
Uh today we will go through some key letters.
Uh but you can see if this address the ABCs of gen AI, it goes through from A is to A is for Attention to Z is for Zero Shot Learning. Yes, I said Z not ZI am from Australia quick.
Yes. So we skipping A, we're going straight to B.
B is for Amazon Bedrock. Bedrock is the easiest way to build and scale generative AI apps with foundation models. So it's a fully managed service from AWS, which I imagine lots of you have heard about during this week and it gives you really easy access to work with foundation models.
Shockingly, foundation models are F which are coming up later in this. But it, we're going to dive into this in much more detail in Ben's section later. So we can move right along from this. But you'll learn all about how to integrate and deploy foundation models into your apps.
C it's for Code Whisperer. Show of hands if you've used Code Whisperer already? Yes, same. Even my cat has because when you're using Code Whisperer, um, you use the arrow keys to go between options and you press tab to lock it in. I've got a tabby cat. So there's a video of the little tabby cat hand pressing the tab key. Now you'll all remember exactly how to use it.
Ah, but it's your AI powered productivity tool for the IDE and command line. So there's, I think at least 15 languages supported. Now, who knows how many that will be by the end of the week. And it's trained on billions of lines of code from Amazon internal code. And also open source takes in all sorts of things, even when your cursor is on the page, um, all sorts of different artifacts to give you what you're going to use.
And when you're using Code Whisper, I've done a lot of demonstrations and sessions about it. The biggest tip that I will give everyone and it's the same tip I gave. Fred cos Fred's gonna be using Code Whisperer later on so what happens is you write your code in plain English.
Um and it then uses generative AI to cont to convert that to code. So you're gonna write your comment, it turns it to code. Think of when you're writing your comments, think of that as the prompt.
So we're gonna talk about prompt engineering later with Ben. Think about how you can prompt it to do what you're trying to do, especially if it's something that you're not sure how to communicate what you're trying to do. Thinking about it as a prompt for me at least helps me to get where I need to be going.
As I promised F is for foundation models. It is not the makeup kind, it is the building kind. So they're pre trained with billions of parameters and they can be applied to all sorts of different tasks. So they're foundation models because the hard work's been done for you, you've got a nice neat foundation then you can build on top of it. That's why it's a building themed name. And it's gonna help you to build generative AI apps quickly and easily because building your foundation model from scratch is incredibly difficult.
And also a lot of developers just won't need to do this for the different types of use cases that they're doing if you would like to train one from scratch to talk to them after the session.
Now, the G word generative AI which I'm sure you've all been counting how many times you've heard that this week?
So this can create new content, like stories, music, conversations, and even videos. And it's powered by machine learning called foundation models. So if you think you've got machine learning models altogether, then there's a subset of that for artificial intelligence, subset of that for deep learning. And then there's ma uh generative AI nested in under that.
Uh if you would like to go on that in more detail, there's a video on my LinkedIn, but this is gonna help you to do content creation without or with minimal human involvement, which is super useful for all sorts of different tasks, even things like code generation and Code Whisperer.
This slide is how you can tell they let me pick my own images.
L is the large language models. So this is a type of foundation model that specializes in language and text obviously. So it can translate, it can predict text that will happen. And they're gonna be using transformer neural networks. If you and Tiffany's session just before us, you would have heard more about transformers. You would like to go into them in detail. T is the transformer in the ABCs of generative AI in that blog post. And they can learn a new task from just a few examples as you'll see in our prompt with them later on
P is for prompt engineering. So it's a process of designing prompts to guide language models. And it involves being really specific about the keywords, the context, the input, even the formatting of what you're putting in so that you can be sure of what you're going to get out. And it's about providing all the context that the model needs so it can perform well even when there might be limited data going in.
Um Ben has a fantastic formula for prompt engineering, specifically for Claude that we're gonna jump into later and uh that will be one to watch as well.
So now I've gone through the ABCs, I'm gonna hand over to Fred, who's gonna talk about what we're going to be building today.
All right, thanks Brooke and definitely take a look at Brooke's blog post. It's amazing, great set of material for, you know, going through all the general AI aspects.
So let's talk about what we're going to build here.
So Brooke has her ABCs. I have my 123.
So number one. So as a developer, right, if you're going to develop an application, so I'm a technical trainer, try to try to keep things simple, right?
So I think of it every time I'm creating an application, remember these three things.
Number one, everything in AWS is an API an application programming interface, right? So basically it's a contract. I'm going, hey, I'm call you and I'm going to send you this information, you're going to process it and you're going to return it to me in a certain format. That's all there is.
So, just remember that everything in AWS is an API. So it doesn't matter if I'm creating an S3 bucket, it doesn't matter if I'm creating a Lambda. It doesn't matter if I'm calling a Bedrock model. All of those things are APIs, you just have to find out what the syntax is.
So, whatever language you're writing it in or if it's a command line, what's the syntax? So that's number one, number two, every API call goes through Identity and Access Management or IAM every API call goes through IAM.
So IAM is where we say, who are you? You're a user, you're an application. Ok? What are one? And so who are you, first of all? Are you allowed to do this thing? So what permissions do we give to that user to that application? All right.
So every one of our API calls, we're going to check. Do you have the rights to do what you're asking to do? Do you have the right to call that Bedrock model? Ok.
Number three, all API calls must be signed with an access key in a secret. So when you make those calls, we s we have a particular signature to make sure that we, there's no man in the middle or anything like that going on. So we say this is a valid sign call the valid set of axis keys and secrets.
So those are my 12 threes. I'm gonna come back to those throughout the next few slides.
So let's talk a little bit about what we created. All right.
So what we did to um for this to, to demonstrate this is we have a front end application written with some javascript embedded in some html that javascript.
Then remember what we have to, let's remember our, our mantra there, right? is that everything is in api so we're eventually gonna be calling our lambda in our second part of this.
So the first thing we have to do is we have to get permissions, we have to get some, some purchases. Now, I could have hard coded my ex's keys and secrets in my, in my html file bad. Don't do that. Don't ever do that, right?
So, no, what I'm gonna do instead. In this case, i use Cognito configured it to say, hey, hey, Cognito, i'm going to use an unauthenticated guest access and i'm going to use, go to IAM and say, hey, IAM give me a role to give me the permissions to do the thing i want to do.
So the thing i want to do is i want to call that lambda. Now lambda is gonna call DynamoDB. It's gonna call our Bedrock model. We're gonna call DynamoDB because i want to s save all of the requests that people, you so you're gonna give us some songs here in a minute.
We're gonna give you back some pet names. i wanna record this. i wanna kind of go back. maybe i wanna audit, you know, um, you know, how, how was, how well was our model working? what were the choices that it made? do we agree with those? were there any of them that we don't, you know, kind of think? are that, are that awesome?
So what can we do to fine tune later on? I'm gonna call Bedrock. We're gonna call the Anthropic model using a prompt. And Ben's going to talk a little more about prompting here in a second, but i'm just calling an api. All right.
So i just need to know what was the syntax for invoking an api? That's it. And then finally CloudWatch for anything that goes bump in the night, any kind of problems i might have or i just want to see, you know, what was the timing between my calls and things like that?
So, anything like that that i would want to log? So, you know, it's a pretty, you know, it's a simple, but it's a nice pattern, right? Because i'm not having to hard code anything in the front end, it's a simple pattern. And later on we'll in our blog post that we have, you can just go to find out how you can actually get access to this code. Very easy to reproduce this in uh in, in, in, in, in your Amazon account.
All right. So again, so what are, you know, again, what other tools do we use? We use CodeWhisper because i'm, i'm a, i'm an application person.
Um by night by day, i'm a trainer. Most of my career has been an IT plumber. So i'm not a software developer. So what i like is i can use CodeWhisper and give it some prompts and say, hey, i just need to create this. i need to create this DynamoDB table. i need to update this DynamoDB table. i need to scan that.
i can just tell it those things. i don't remember that syntax. Let CodeWhisper help me like that syntax
Fred: I'm not a front end developer for sure. So it's awesome to be able to use CodeWhisper to help me on that part. If you haven't, the other thing I used in this demo was the Surplus Application Modeler (SAM). Why would I use SAM? There's a bunch of different ways that you can develop in AWS, but the Service Application Model I like because a couple of things is it's very simple. I put together my code, I say, "Hey, initialize my environment and deploy my code" and then it understands what I'm asking it to do. I give it a template and in that template, when you see that we, I gave it the instructions on, "Hey, what is, I'm trying to do a Lambda. Ok cool. And I want to create a DynamoDB table. Uh huh. Ok. And here's the keys that it needs and here's the role that my Lambda has that says you can go ahead and update that DynamoDB." So it's kind of nice.
So that's why we use SAM. Again, I use the front end using CodeWhisper because I, I am not, you'll see in my demo, I, I, I'm not the best graphic designer or anything like that, but we just wanted a POC, right? So we accomplished what we wanted. My two customers came to me and said "Whoa!" in this application and, and keep it simple because I tried chatbots and I guess no, we didn't need that. We needed something that we could leave behind for you folks. It's easy to reproduce. We have a very needy, very demanding, they're, they're good, good customers, very demanding though.
But we, so now the thing is "Ok, what do we need to put into our application?" Because there's that one part that I didn't know. I can do all the other stuff. I've done it a million times, but that last part about calling Bedrock. So I had to work with Ben because, you know, and I would send Ben things. He's just like "Fred, Fred. No, you're making it too difficult." And so we worked together to come up with the prompt that we're gonna show you and it met our needs, right? So it worked out good.
So we went through multiple iterations of the prompt, create a simple template. You'll see how I just use Python to incorporate your requests and then send that on to our model. And then with Ben's guidance, we decided to use the Anthropic Cloud model for our text generation. Perfect for what we were trying to do. All right. So that's my piece that I'm gonna have. Have Ben come up and talk a little bit more about, you know, how we're going to build it. Thanks Fred.
Ben: All right. So thanks for answering our poll earlier. I'm glad to be helping you all on your first steps in generative AI and taking a look here. I think it's time we introduce the Amazon Bedrock service formally. So, understanding Brooke mentioned foundation models a little bit earlier, I like to think of Bedrock as a hub of a variety of different foundation models that you have available to you at your fingertips. Some of them are good at some things and some are designed to be more specific to certain tasks.
In this specific case, back to what Fred was saying a bit earlier, I'm a huge fan of the "keep it simple" framework if you will. But taking a look, from my experience as a Solutions Architect in the independent software vendor market, that's ISVs, we see folks doing a lot of different tasks. I'll just speak briefly about those for a moment.
We have verticals that are using them in financial. We have folks that are doing them in cybersecurity. So thinking about "I've detected a threat. Ok, so I've classified a threat, but maybe I want to understand why we've classified that threat as a threat, generating an explanation of why it is that way."
Another very common use case I'm seeing is the ability to empower our customers to adopt our services, and I say our services, the independent software vendors services, more easily. How many of you in here are a SQL developer? Ok, just a very sparse number of hands here. Would it be great if we could use natural language to generate SQL queries? Absolutely.
So we can start to understand that some of our ISVs in the database market are also leveraging tools to make their databases and your data, which is where we derive value, more accessible to you as the customers.
Bring it back to Bedrock - you have the opportunity to choose from a variety of foundation models. Specifically in the demo and the POC that we've built out, we're leveraging Anthropic CLAD but I think we should definitely let you be aware of some of the other options that you have available to you.
Something that we can do, we didn't necessarily do it in this POC coming back to the "keep it simple" framework, but you can customize these models with your data. So if you haven't heard it yet, there's a technique called Retrieval Augmented Generation or RAG for short. So we're enhancing the output of these models with data that we feed to the model at time of inference. That's getting a bit more technical and you can connect it to your own data sources as well.
Curious, anyone maybe heard of Amazon Q in the last couple of days here as well? Ok. So these, you can see Amazon is adopting these services, as I was mentioning we're seeing in our ISV space as well.
So let's take a look at what we currently have available for you today in the Bedrock ecosystem. We have our first party models which if you take a look up at the screen right now, we have Amazon's TITAN. We also have access to AI21 Labs. They are what we'll refer to as a third party model. You may see that in some of our blog posts as 3P.
We have Anthropic, Anthropic is actually what I did the prompt engineering for our POC today that we'll be taking a look at. We can talk about prompt engineering here in a moment in our next few slides. It's an iterative process. I'll just keep it at that.
And then we also have access to Cohere models. So you'll have TITAN embedding models, coming back to TITAN for our first party. We also have access to a Cohere embedding model in Bedrock as well.
So if you're not familiar with embeddings, right, what that means is I'm taking my natural language, I'm feeding it through this model and now I'm representing it in numeric format or vectors, then something you know.
So I've mentioned first party, I've mentioned third party models, but we should also be aware of open source as well. So that's where the LLama comes in. Brooke had a slide earlier with the LLama model earlier on. So we should be understanding that LLama is available to you. And if you have any use cases where maybe you're interested in developing marketing collateral, you can do text to image as well with Stability AI.
Ok, our prompt. So I happen to be a big Beatles fan. The genesis of this project was "Ok, what kind of pet names can I come up with if I talk to this large language model and say, you know, my favorite Beatles song is Dear Prudence and CLAD came up and it said Prudy, it's like that's pretty good. Ok, we can develop a simple POC use case which is, you know, as a demanding customer for, you know, we built this thing out."
So prompt engineering is going to be different across your various different models. And I want to point that out because if you take a look at this particular prompt, and I apologize, we probably should have had it at the top and the bottom as well. But if you take a look at this example section here in the middle, it says "Human" and it also says "Assistant." So when it says "Human," this is what I'm expecting my user input to be - so "Dear Prudence by The Beatles."
And then I'm giving it an example in this particular case where I say "Assistant" and when it says "Assistant," this is what I would expect the model to come up with. So any particular prompt that you feed over to Bedrock, if you're using specifically Anthropic CLAD, will need to use "Human" and "Assistant."
And something that I have found to be incredibly effective when leveraging these various different large language models is to tell the model who they are and what they're supposed to be doing. So in this particular case, you can see we've highlighted "role" and in this case, I'm saying "You're a pet naming expert." Ok, but not just any pet naming expert, a pet naming expert based on song titles, the name and the artist that's being provided as well.
Something else that these large language models tend to do very well is they take, they follow rules to say the least. So as an example, Fred, I know we did a Twitch series together. What was your pet's name? Mocha? How could you forget? Uninitiated. We featured Mocha heavily in the series. So, were you watching or just on the show?
Fred: Well, yeah. Yeah. Mocha is a very good short name. That's good. Yeah, absolutely.
Ben: And so if we take a look at rule number three here, I probably don't want a 13 syllable pet name coming out of Dear Prudence frankly. So I can specify that in my rules, I didn't mean to forget. I'm sorry, Fred.
Fred: That's right. But she falls in your category. So we're good. Yeah, absolutely.
Ben: So some other things I'm asking the model to do, I'm saying, "Ok, it's got to be creative. You must provide at least four options," right? So just providing me Prudy, ok, that's great. But maybe I might want some more inspiration there for things for me to choose from and then "Explain your choices."
So giving the model a set of rules and then something Brooke mentioned earlier, zero shot learning, this right here is not zero shot learning. This is actually single shot learning where I've now specified. You know, I'm going to give the model an example.
So coming back to our ISV market thinking about generating SQL queries, it would be really helpful if I could let the model know based on this user input, this would be an expected output, you know, and that may be a very specific SQL query. In this case, Dear Prudence, we've got Prudy, Sunshine, Deary, and Sunny. In my opinion, it would all be decent names for this model to come up with.
Then we need to feed in the user input. So all of these things I have just shared with you are abstracted away from your users. They don't get to see this, right? So, you know, they may see a text box which we'll show here in a little bit with Fred, you'll input some information and you'll generate the output through a really nice user interface.
So you take the user input and at this point, the model should have an understanding of what it's supposed to do and, and something else I've seen across large language models if you give it one more sort of command and I it doesn't highlight it on, on the next slide here. But you know, "Based on the song title and artist provided, give me at least four pet names." It's very well attuned for the final portion of, of the prompt that's being sent over to the model.
All right. So let's get into why we built it this way, Fred. This is I'm extremely online. I make a lot of content. This part, alternate title is pre-answers, lots of comments I would get on social media if we posted about this. So on this architecture, Ben and Fred. Why did you choose Cognito?
Right, I mean, the biggest thing is, is like I wanted to have that security posture again. You don't want to have put your keys and secrets, right? So it just gives you a secure way to have that. Now, the only, only, you know, also, in the other aspect of this is the IAM role that gets served up that's assigned to that unauthenticated guest role through Cognito.
Only can call that Lambda for example, right? So you would have to call the Cognito. So you'll specify your Cognito configuration to your role to your Lambda, right? But the nice thing is, again, it's just those access keys and secrets. I don't have to store anything in that front end. You never want to do that.
And we're not and sorry, one more thing that we use on unauthenticated, we're one step away. If we add authentication to the front of this, then we can just get an authenticated users instead. Right.
Ben: Yeah. And so this is really a proof of concept. This isn't production ready, but that's the point of it. Like we know you're not gonna use this for pets, but it's really about how can I take a prompt and put it on an absolutely minimum viable front end so that you can have the whole piece there.
Fred, I guess if one of your customers wanted to extend this out for production, what are some different considerations they'd need to take into account?
Fred: Yeah, so I mentioned it a little bit earlier, being able to understand what's happening with, you know, the inputs and the outputs of the model. Something I can see being very helpful is keeping track from a security perspective of who's trying to make calls or back to Fred's mantra. What may be making the calls because everything in AWS is an API call that means services can make API calls over to Bedrock.
So something that we don't highlight in this particular architectural diagram is CloudTrail, right? So we can keep an eye on what's happening within the cloud. And I think also that, that if you look at that invoke the Bedrock, you did Anthropic, guess what? So one line change to change a different model. So that's the other aspect of this.
It's pretty simple to try. So you're gonna hear all these announcements this week, take this one swap in um slight changes you wanted to do in the responses and things like that. We'll talk about a little bit when i demo some of the code here. Um but yeah, it's pretty simple to now try a different model. I had before and we simplified it. I had plenty of them that we were trying everything else, but we realized, no, we don't need that. I need to follow what my customers asked for and give them what they asked for. So i did and we will be taking questions at the end. So if you started thinking of something, you would like to keep it in your pocket at the end, right? All right. Oh boy. Excellent. So guess what, folks? It is demo time.
All right. So the first demo i'm going to do is walk you through code whisper and how i use it to come up with the db code that i needed. Ok? We need to swap to your i will. Yes and look at that. All right. There we go. So because i'm a horrible typer. Um and there's no way i was gonna try and code this by hand. So i'm gonna do this via a little quick video here. Hm. All right.
So we're gonna start off here and i'm gonna see that we're gonna just kind of go through, just look on the left hand side. This is vs code running code whisper. So um went through here. So just making sure code whispers on everything else. Uh you, you'll see you have to log in with your code, your builder id and things like that, but now i'm gonna give it a prompt. All right. So i'm thinking of this as a comment as much as a prompt. So the way that in python, the the comment is the hash with the comment. So here i'm asking create just a simple python function and update p table. Now, notice what it did there. It's kind of interesting ah if we can just back up a little bit here. I'm not quick enough on my mouse here. So i am asking it to do that. Here we go. So i'm asking you to create this, this simple function, right? Is it running? Yeah, while this is loading, if you're ever having trouble getting code whisperer to um pop up for you, i think in mac it's option c um and it's something very similar in windows but look that up if that ever just stops where it's not coming up for you. Uh if you're me and for example, swap between several accounts for demo purposes, this can happen. So just option c and your examples will come straight back up. Ok. So we'll just, we'll let it go here. So again, so it's gonna come up with a comment. I backed it up but watch when it pops up. The code that it pops up is for a sql light database. Well, i, i don't want a sql light database. I want a diamond db table, right? So i'm gonna go ahead and uh i'm like, ok, thanks for that, that suggestion, but i don't want to use that suggestion, right? I don't want a sql light table. I want db. So i need to give it another prompt. I'm gonna tell it, hey, give me a prompt to create a table with my model idea is my key and then my date time is my sort key key. Ok? So now i'm giving it, i've been told it what's gonna be passed in as results and everything else. So that here's, you know, let it go ahead and create that code for me now. And you know, this is nice because, you know, as much as i've done, you know, things with dynamo db in the past, you know, i don't do it that often. And sometimes in, you know, now here i'm in python, but maybe i wanted to do this in java or some other language, right? So now here it gives me all of the syntax here and i noticed that it threw me bo three in the day time here. So i'm like, well, i really don't want those in that function. I'm gonna pull those out and put it at the top. Simple, but it still gave me everything i needed, it knew that i didn't have those yet and put those in there, which is pretty cool. All right.
So next thing i wanna do is all right cool. I want to be able to scan the records that i put into this. So let's see if we can ask you to create a uh a function. So you create function to the, to scan that table and return all the items, give it the pet name and the, the thing. And here we go, give me the syntax for scanning and, and that's when i uh i, i messed that up quite a bit. Um the return items piece. I, i've messed that up when i've coded this by hand. So i like that. I like cool. Thank you very much. I just simple python. Now that just says, hey, give me a main function and call both of those things in that order. All right, i can get my little main function. Now watch. I'm gonna be really brave here. It would have been really brave if i had actually been running this and typing it, but i'm not, i'm gonna run it without the buggy. Ok? So let's see what happens. So we should get hello re invent 2023 to come out of here in the response, you know, hopefully it doesn't get cut, cut off too much. Yeah, it's hard to see, but you can see behind my uh my prompt here. The the screen it did return our hello, you know, 2023. Let's do one more though because we want to give a good shout out to code whisperer. So why not? Yeah. So resolution on the screen is a little bit different here, but we should be able to see in the bottom code whisper. This is so cool one more update to our table. Now, this is the code that then i put into our application to then um take all your prompts in. All right.
So this is actually the code that i just really took from this and pasted it into my application. Ok? All right. So that's a real quick code whisperer piece. Let's spend a little bit of time on some of the application pieces here. So if we look at the, this is the front end uh piece. So in here, oh, here we go. So here these are not real identity pools because i wouldn't want to give you my identity pools, but they're hashed out. So this would be the code that you'll get, you know, if you download the app. But here, so you, there's some instructions on how you set this piece up, but this is the call to the api call that i'm gonna make to get the credentials for my front end app. What four or five lines of code, get that thing. So once i've set up my role and i set up cognito now, you know, you can think of this as i've got some temporary access keys and secrets. So now from the front end, go down here, put in our function name, that's our lambda function. And then here's so there's the lambda invoke, that's your api call. Ok? So all i need to know is what in python bo three, what do i have to do to invoke my lambda? And that's it for the front end pretty simple.
Now, probably the most challenging aspect of this stuff. To be honest with you is the return values coming back in the json and manipulating the json. But other than that, because i'm not a front end developer that, but that's nice. Yes, but that was nice to be able to use things like uh uh code whisper to help you with that. So let's look here inside this is the, the the lambda application. Ok. So now this was based on the prompt that my engineer uh gave me here. So this is my way, this is not the only way to invoke this, but this is where we're putting the prompt in. So now i'm coding this into my lambda. This is the thing i'm going to formulate this call, the prompt to send to our um uh anthropic code. And just to spotlight this, if you're used to using ll ms only through a chat interface, and you've wanted to know how to get it going with some sort of a front end. This is the answer here.
So when we're talking about the different abstractions earlier in ben section, yeah, this is really how fred's done this. Yeah. Yeah, exactly. And, and there are like i said, there are many ways we could have sent this in as an entire block you know, from the front end, but then we have to could that. Um so, you know, here we're doing this and then all i'm doing is you'll see i'm sending in titles. So that's gonna, the piece that we're gonna get from you in a minute. We're gonna pass this in here. We're formatting this thing. As ben said, we got the human and assisted aspects of how anthropic re uh wants this call to come in. So, just a real quick little thing here just to this is where i'm kind of formatting it. So it's in that human and assistant format. All right. So i can take that and put it in there because that's what uh anthro is gonna want.
So if this is a different model, you could take the same prompt, but you'd have to specify it differently when you invoke that particular model because they have a different way that they do that. Um so the temperature is interesting. So we've got this thing dialed up to be as creative as, as we want it to be, right? So we want this to be generative and, and, and anything more you want to say on, on some of these uh ben, just some of the choices we made here. So we, we told the model to be creative, but one of the parameters and, and this can be configured. So temperature at one that's we're asking it to be and the way i like to say it is as creative as possible. Now, that's really good for naming a pet frankly, in my opinion, but just coming back to the use case that we talked about a little bit earlier generating sql queries, i really don't want to be creative on that. Not so in that particular case, that one is going to hedge way closer towards zero in that particular case. And this is really important to communicate to your executives and business leaders or people asking you to build things like this.
Um that's what i did for a job before i got my current job. And so much of it is just giving people a shared vocabulary because they might not even have words to fully describe what they're trying to ask you to do. So as a developer, it's a great place to step up. If you give people words to talk about what you're trying to do, they'll be able to talk about it with you and you'll get to a much better response. So if you're starting to get asked about generative a i having conversations about what temperature you wanna set, even things like top p with your executives, that's gonna really bring them into the development process and help to understand what's happening and then even showing them if you change this parameter, this is what's gonna happen. So if i pull this lever, this is what happens, things like that, they're gonna ask you better questions.
Um and it's going to be so much less frustrating for you long-term if you've given them some shared vocabulary. And this is a great place to start for generative a i yeah, i started with the slider things and all kinds of things that, you know, you could pass these in and i'm like, we're gonna keep it simple. The slide is in potty rock in the advanced settings. The very good, good call and here is, guess what another api call. So now this lambda has permissions to invoke bedrock. You know, there's some other things you'll do and it's documented in our blog post and how you get permission to be able to use the bedrock models. Go ahead, ben. Do you have to give api keys or anything there, fred or does bedrock even have api key? Not in this case. No, i didn't need any api calls because i'm just invoking the bedrock api. So that's, that's pretty. So that's just awesome because i mean, i can do this in many different contexts. All i have to do. It's just like any other api, that's what i love about it. To your, to your point, ben. That's absolutely right.
Um yeah, so, so we're following all the same rules. All right. So we're gonna switch back real quick and brooke, you want to take us through this uh section here, we're gonna kind of swap back and forth here a little bit yeah, so we need an input to put in to what we've built now. So another pole. Uh so without your camera again, it's the same address
You just put the different code in this time. Other code is 532328. Um and you'll be able to select your favorite song from a list. Sorry, Fred. No problem scrolling up. So I can see the options. I think this poll is this the one with Hey Jude by The Beatles. Whole Lotta Love by Led Zeppelin. Good Vibrations by The Beach Boys. And I Can't Get No Satisfaction by The Rolling Stones and Purple Haze by Jimi Hendrix.
Um I wasn't born when these songs are out. Maybe you weren't as well, but out of all the things that you can research after reinventing looking up these songs, if you're not familiar with them is a great place to start. Very excited to see how this is gonna turn out because this is a lot closer than I expected. This is good. Yeah.
Do you have a favorite on this list? Ben? I absolutely do Purple Haze by Jimi Hendrix. Right? For the uninitiated. Ben would play his guitar on our Twitch stream when things were running and loading and things like that. So, Ben's really on selling how much of a music fan he is you can watch in a recording.
Do you have a favorite from this list? Fred? Yeah. Good Vibrations. I I'm a Beatles person or a Beach Boys person. That's my era. So, yeah. All right. Two years before that.
Well, it looks like the winner. I'm gonna give you a, this is, oh, I see some cameras coming out to tell they're taking photos of the thing. I'm going to close the poll now because it's settled down. So, Purple Haze by Jimi Hendrix.
Do you want to swap back over Fred? Ok. Here we go. So Purple Haze by Jimi Hendrix. Our screen switch there, Fred, we are good. Come on there. Who hang on. Come on. We are just looking for the one with, we have found it. How good is our front end? When we talked about a proof of concept and minimum bible? This is really able to get your point across so you can show that something happens. Obviously, the way you wrap that up, you can then do with whatever you actually wanted to do for your front end. But this is what we're talking about just having something where you can type the wrong. But you know, I think our model we figure out so we're going to go fetch our names and then it's fetching because it's pet them.
So remember now, what do we do? We went out to Cognito, we got an access key, we signed the call, we call Lamb to Lamb just calling our, our model sending in our prompt and then returning to some results all right. Ok. Do you want to read them out, Fred? We got hazy perps. Indigo. Hang on a second. Indigo is three. If you remember our prompt, it said should be less than two syllables. It didn't say right. This is good. We found this a lot with the different models. Sometimes when there was a really good one, it did more than the two syllables and I was never mad about it, but alright, back to our pool. We everybody good.
The other thing, sorry, just before you switch off this, Fred, it gives you the name and then a description which is really helpful because it helps to understand where the model's coming from. If you're not familiar with the lyrics of the song, some of these would seem a bit wild. Um but it's a good way to see what's happening. And additionally, because we've got four options here to choose from. We're not putting all our eggs in one basket and we really do have different ways to choose from this sometimes for an output, you just need one single output, but this is all about understanding your demanding customers um and working out how you can best serve them because usually from all the tests we've done on this and our extensive application testing. Um we've all been pretty happy with at least one of them on the list. So it's always been really good to see.
Do you want to swap us back over for the next four, one more note on that though brooke. Um so explaining something incredibly helpful, i i mentioned a use case around this for, you know, cyber security, a threat was detected. Great. We've classified that. But why and can the model tell us why? Based on the information we've provided it? Why that is? So it's, you know, why did we pick prudy, you know? Yeah. And just while people are filling out this poll currently, so the code is 528683, being able to answer why is really important.
Um one thing that would happen when i was designing machine learning systems with people, they would always say, could we do this? And i would say, should you like, how far can you actually get with this? Or if you do get the answer, you can predict what you wanted. What are you going to do it? So having this y part is really helpful context when you're working with it.
Look at this. So the option Bohemian Rhapsody by Queen. Oh something moved Born to Run by Bruce Springsteen. Stairway to Heaven by Led Zeppelin and Dream On by Aerosmith.
Fred. Do you have a favorite from this list? Hotel California would have been my mind. So not to, not to, you know, influence the audience at all, but all right. I'm just gonna go with the popular opinion on this one. Bohemian Rhapsody. It's an excellent song and the movie was good too. Bohemian Rhapsody has a lot of cat energy i think. Does anyone have a pet with Born to Run energy? Because yes.
Um but Bohemian Rhapsody, we're gonna pop that into the model in just a second. I'm gonna swap back to you for a screen. He already typed it in which is crazy. Alright, so again we're getting our exes key, we're gonna sign the call, we're gonna call our lamb. Our lamb is going to invoke our model. We're also recording all of this stuff in DynamoDB and all in the CloudWatch and let me get this.
So yeah, here's Galileo again. So do you want to read these out, Fred the option? We got Raps Mama. So that's interesting. Galileo Figaro. That's a pretty good one, right? That would be a i like that the last two more than two syllables. But once again, i'm willing to allow it.
Do you have a favorite from this list? Ben? You know, as far as a pet name goes, Galileo is pretty good. It's a strong name. Yeah, yeah, Figaro is already in uh in a Disney movie, right? So we got that. All right, we have one more i think one more pole.
So the newest code is five. No, that's not a five. That's a three. I know how to read. 324320. So the options for this are Sweet Child of Mind by Guns N Roses. Every Breath You Take by Police are the Police, uh, With or Without You? By You Two Living on a Prayer by Bon Jovi and Eye of a Tiger by Survivor.
Do you have a favorite Ben? From this list? Sweet Child of Mine is pretty good. But the crowd agrees. It seems if you don't agree with Ben, now's your chance to run it. Do you have it? Yeah, i'm gonna stick with the answer. Yes. It's, I had the Tiger, right. You know, for sure. Big Rocky fan. I think in terms of pet names though, like Every Breath You Take when my cat's just watching me sleep or something and i just can never escape. It's very accurate.
Oh, but things are changing. It's getting close if you'd like to choose a side between Sweet Child of Mine and, and Living on a Prat now is your time to shine. But it looks like it's settling down. You get to type in the whole name Fred. You're gonna be so excited about it. Sweet Child. O Mine by Guns N Roses. We will swap over momentarily.
Alrighty. One more time. Let's go fetch those names. Remember our mantra. We're calling our a p a. We're going to go get our access keys. We're going to sign our access, we're going to call our lambda lab. It's going to invoke our function, love his voice.
The other thing i'd like to point out so you can see in this top line of the prompt, uh Guns and Roses is not and it's an n but the model still knew what we were talking about. So depending on the use case that you end up using this for, if you don't use it for your pet names, thinking about where it can and can't figure out what you mean is gonna be a really important edge case depending on how important that result is for your business.
Have you seen any applications of that with your customers? Ban of people bucking with hazy inputs? You know, i've created some hazy inputs and have delighted some folks with them, regardless of my spelling errors, there's a few of them but underlying everything that's going underneath, uh it's the semantic meaning of the words if folks are familiar with that.
Um classic example is king and queen are very similar in meaning in space. And so that's really what's happening with these models is they're, they're understanding your input based on, you know, repre sorry numeric representations of words. And that's how they are able to map those semantic similarities. You can learn more about it. And e is for embeddings and v is for vector databases in the ABCs that will go into that with more detail.
So next steps, I would like to preface this was anyone here early and saw me actively cheering off stage. That's because that was the moment this blog post went live thank you so much to our content team. I absolutely terrorized them this morning.
But everything we've talked about is on a blog post right now. So this is on a blog called AWS community. So it's community dot AWS. Uh it's where i post all of my AWS content, including this one which we co-wrote together. And this is gonna step you through how to build on this.
If you can't scan the QR the address is s 12 d.com/session code bo a 208. If you're watching in the future, maybe this will even be updated a little bit when you see it. Uh but hopefully we'll be able to put the link in the video description for you.
Um this, there's so many different blogs on here from different other people in dere other people in the community. It's a very like underground AWS blog, but it's about, i've been excited about posting my stuff. So there's this post here as well as the ABCs of Generative AI are on this page. I also have a post about how to learn generative AI from scratch.
Um and this and some others. So keep in touch. Um we're gonna answer some questions now. So if you have a question