Lesson Description

The "Personas" Lesson is part of the full, Practical Prompt Engineering course featured in this preview video. Here's what you'd learn in this lesson:

Sabrina explains a technique for assigning a persona to a model. Personals instruct the model to identify with a specific role. They don't give the model extra capabilities but provide a perspective to steer the model toward a subset of data.

Preview
Close

Transcript from the "Personas" Lesson

[00:00:00]
>> Sabrina Goldfarb: I imagine that you all will probably have heard of this, and a lot of people misunderstand it. So personas are simply, you are a role and you give the model a role, right? And most of us have seen this before. And most of us have seen, you are a staff engineer who first worked at Google, then went to Twilio, then went to Microsoft, and then you studied system architecture, and then you also did this other thing.

[00:00:31]
And oh, on the side, you started two startups that are super successful and hit a billion users, right? Like we've all seen the persona prompt that the prompt is like 7,000 words and then the ask is like 3 words and we're like, okay, maybe that's a little excessive. A lot of people have a misunderstanding with personas. A lot of people think that they can make the model smarter by giving it a specific persona, but that's not what's actually happening.

[00:00:59]
It just gives the model a perspective. So when the model is trained, right, the model develops these connections between everything it learns. Same way our neural network makes connections. If I practice guitar every day, right, I'm going to get better at guitar and those connections that help my hand-eye coordination and all that stuff is going to get better because it's related to guitar and then also like knowing all the notes, that's also going to get better.

[00:01:28]
And those connections live in a certain spot within my brain. So every time I play the guitar, it's going to kind of tingle those special connections and they're going to get stronger and stronger and better and better. LLMs are pretty similar. So when we're giving the model a perspective of saying you are a database expert or you are a senior engineer or you are a mathematician, all we're doing is starting to give the model a direction of neurons to look at, right?

[00:01:59]
So we're sending it to a specific area of its brain that it can now look at and take that perspective from. So if I'm saying you're a database expert, then I'm going to be thinking about, right, if it's just me, I'm going to be thinking about database indexes. I'm going to be thinking about all sorts of database terminology and all of those sorts of things, and LLMs are the same. If I say you're a mathematician, I'm more likely to kind of stimulate those neurons that are mathematics-based.

[00:02:31]
And so that's why personas can help us, but they are not actually making the model smarter. You are just steering the model towards a subset of data that it has already been trained on. It also activates relevant knowledge and vocabulary, so this can be extremely helpful to us, right? This works mainly for expertise, for tone, and for style. So if I'm trying to write a research paper, right, for some prompting technique that I came up with, I'm probably going to want to give it a persona that's going to write that research paper more in that tone of someone that's research-based and scientific, right, than I would explain like I'm 5 kind of territory.

[00:03:18]
So these work mainly for expertise, for tone, and for style. So let's go back to my database expert example, right? So maybe you are asking the model to help with a database example and it's just not getting it by saying the words, you are a database expert. Now it's reaching out to all of those parts of training in its brain that are database-related, and you're going to see very different answers than if you just said, what can I do with this kind of database if I utilize this transformation?

[00:03:56]
So again, these are mostly for tone, for style. Also, if you're looking for a very specific perspective, so if I were to say to Claude or GPT, you are a UX/UI designer, right? I'm going to get a very different outlook on things than if I say to Claude or GPT, you are a security engineer, right? Because this role and this persona is just going to activate different things that the model is now looking for.

[00:04:24]
So UI/UX designer is going to be like, hey, you haven't considered accessibility. You haven't considered color blindness. You haven't considered that people are more likely to click buttons that are this color or the size or the shape. But if I say you're a security, you know, a security expert, a security engineer, then you might be more focused on, hey, there's this vulnerability, or maybe you're utilizing an npm package that's really out of date, or those sorts of things, right?

[00:04:51]
Something else to know about personas is you can change them mid-conversation, right? You can always start with one perspective and change the conversation to have a different persona. So maybe you start generically and you add a persona in the middle, and then maybe you add another persona in the middle, and you can start to get different perspectives that way. Let's look really quickly at a couple of really good scenarios for personas.

[00:05:21]
So if I'm doing a code review, I can say you are a senior engineer focused—I'll do this one in Copilot actually, kind of show the full extent of it. You are a senior engineer focused on security and performance. Go through our code and identify any possible concerns. Right, so this is going to be very different than if I would have said you are a UX/UI expert and kind of seeing what that persona takes on.

[00:06:02]
While this runs, we'll talk about some other good use cases, maybe for documentation. You are a technical writer who prioritizes clarity for beginners or for non-technical people or for project managers, right? In debugging, you're a systematic debugger who checks assumptions first. For architecture, you could talk about being a solutions architect who considers scalability and focus on that. So you just kind of have to figure out what persona is going to work for what you need.

[00:06:35]
Okay, so we can see that GPT found a few things, high priority security items, right? Okay, so now we have unbounded content and note sizes. We're relying on innerHTML for structural templates. We have all these things that we could fix because we are in the persona of a senior engineer. If I do this one more time and say, once it's done, you are a UI/UX designer, give us some considerations for our application.

[00:07:10]
And we'll see that likely we'll get something completely different than what we got before just because we're giving a different perspective. Okay, so yeah, so now, here's a structured UI/UX considerations and actionable enhancements for your Prompt Library app to improve clarity, efficiency, delight, and accessibility. Completely different things than what we brought up when we were talking about being security-focused.

[00:07:38]
I personally utilize personas when I'm learning new things, so maybe I'll ask the model to pretend that it's like a JavaScript tutor if I'm learning JavaScript, or maybe I'll say like explain like I'm 5, if there's like something new that I'm trying to do at work that I don't understand, or maybe I've gotten a code review that's really complex and I don't want to bother the person who did the code review.

[00:08:05]
I can be like, hey, you are a staff level engineer who has given this code review, explain kind of easily to me what it could be, right? So adding too much to a persona can definitely make a model too rigid, so we do have to be careful with those super long persona comments that we see of you're a Python expert, but you only use classes and you only do this, and you love this, and you've studied this for 10 years.

[00:08:31]
We want to make sure not to make the models too rigid by adding too much. So they're not adding, they're just kind of restricting you. When researchers analyzed model outputs, they did find that personas primarily affected vocabulary selection, response structure, error checking behavior, which is pretty interesting, so that's why it's helpful for security and confidence in assertions. So you can change these personas mid-conversation if you are a little bit concerned about, okay, like the confidence and assertions and the error checking behavior.

[00:09:08]
Maybe I always want to end my prompts with like you're a security engineer, kind of check this out for any security vulnerabilities. And so that's pretty much it. When we are talking about personas, we just want to make sure that we are giving the model enough priming to get the details we want, the implementations we want, but not so much that we are restricting ourselves to one very strict answer, right?

[00:00:00]
The whole reason that these models are great is because they are great at being generally helpful to us, and so we want to make sure that we give them the availability to do that.

Learn Straight from the Experts Who Shape the Modern Web

  • In-depth Courses
  • Industry Leading Experts
  • Learning Paths
  • Live Interactive Workshops
Get Unlimited Access Now