Prompt Fundamentals: Get Started with Prompts PDF
Document Details
Uploaded by FlawlessFantasy4551
Tags
Summary
This document provides a foundational overview of prompt engineering for large language models (LLMs). It uses a cooking analogy to explain how prompts are like detailed instructions that tell LLMs what to create. The document also highlights different prompt use cases, and emphasizes the importance of both instructions and concrete information for optimal results. It covers basic prompt ingredients, like participants and settings.
Full Transcript
Prompt Fundamentals.. Get Started with Prompts.. What’s a Prompt?. If you completed Generative AI Basics, you learned that large language models (LLMs) can help businesses and teams with all sorts of language-based tasks. For example, they can generate a personalized email to a customer, or analyze...
Prompt Fundamentals.. Get Started with Prompts.. What’s a Prompt?. If you completed Generative AI Basics, you learned that large language models (LLMs) can help businesses and teams with all sorts of language-based tasks. For example, they can generate a personalized email to a customer, or analyze customer feedback and extract key insights. But LLMs can’t create great content by themselves. They need some guidance from us in the form of a prompt. To understand how prompts work, imagine you are head chef at a popular bakery. You hire a super-smart assistant to speed things up. The assistant was trained by culinary experts and can use what they’ve learned to create delicious cakes at lightning speed. But they need guidance to create the specific cakes your customers want. So you give them detailed instructions that include all the information they need, such as the cake’s ingredients, the occasion the cake is for, and the steps to make the cake. And that’s what prompts are: detailed instructions that help LLMs generate great output. So, what type of prompts can you give an LLM? Say, as chef, you want to spread the word about your cakes. Here are some simple instructions that you could give an LLM to get a head start. Use Case. Instruction. Drafting a customer email. Write an email to follow up on a cake order. Summarizing a Summarize the key takeaways from a recently recorded conversation. conversation about a potential business partnership. Brainstorming names for a Create a list of names for a new gluten-free cake. new product. Instructions are a good starting point, but they leave many unanswered questions that can lead to less-than-ideal output. For the examples above, what did the cake order include? What do you consider a key takeaway from a conversation? What brand guidelines do you want the cake names to follow? Instructions are only one part of an effective prompt. To ensure high-quality output, you also need to add concrete information and clear constraints to your prompts. This is all part of prompt design, and without it your cake, er output, will definitely fall flat. Add Designer to Your Title.. Marketer/Designer. Small Business Owner/Designer. Admin/Designer. When it comes to prompts, we’re all designers. Prompt design is the process of creating and iterating on your prompts. Just as chefs perfect their recipes by testing and making adjustments, you must review LLM responses and iterate on prompts until you get accurate, high-quality output. Why bother? Well, vague or inaccurate instructions can lead LLMs to produce irrelevant or even biased responses. One way to help ensure effective LLM responses is to “ground” prompts in reality. You do this by giving the LLM data that’s specific to the request you’re making. The data you provide is in addition to the original, generic data that the LLM was trained on. Grounding a prompt with your specific data provides the LLM with information relevant to your business, your products, and your customers. Without that data, an LLM is likely to create content, like your follow-up email, that includes generic or irrelevant details. With that data, your prompts will be truly personal. It’s not only prompts that can influence an LLM’s output. LLMs have settings that influence their responses, too. As you design your prompts, make sure to experiment with the LLM settings to see how different values affect the output. For example, did you know that LLMs are not “deterministic”? That means that their responses will usually vary at least a little, even if you give the same LLM the same prompt twice in a row. But you can use an LLM’s “temperature” settings to reduce or increase the variability of its output. This way an LLM’s responses to the same prompt might be more or less similar, depending on your preference. Finally, keep in mind that LLMs aren’t one-size-fits-all. Different LLMs can and do respond differently to a single prompt. Like culinary assistants, each LLM is trained by different experts, on different data, and using different teaching techniques. For optimal results, always get to know the LLM you’re working with and tailor your prompts to it. Basic Ingredients of a Prompt.. Like a good recipe, effective prompts include both ingredients and instructions. They work together to help LLMs generate great output. The following are some key ingredients you’ll want to include in your prompts. Let’s see how you can use these ingredients to create a blog post. Ingredient. Description. Example. Participants. Describe who’s sending and You are a world-renowned cake receiving the model’s output. decorator. Your customers include families, newlyweds, and children. Setting. Give the model contextual You have a well-loved bakery information. known for its cakes. You also have a popular blog read by your customers. You are writing your latest blog post. Goal. Describe what you hope to You want to capture customers’ achieve with the model’s output. attention while teaching them about novel decorating techniques. Relationships. Describe the relationship between Your customers have a sweet tooth the participants involved. Also and are always curious about new mention how the model’s output cakes you make with fresh relates to the participants. methods. Data. Give the model data to work with. Your bakery has a new line of cakes that you’d like to advertise to customers. After you mention the ingredients, give the LLM clear instructions to follow. Instructions. Tell the LLM what Write an informative article about cake decorating type of content you fundamentals. Include a comprehensive analysis of want and what it different cake decorating techniques. Discuss the must include. tradeoffs and explore the challenges of different techniques. Include a call to action to see the techniques in action by trying my new cake that incorporates all of the techniques discussed in the blog post. Finally, you’ll want to add details to your prompt that clarify or constrain how the LLM responds. This includes any limits, languages, and style guidelines you want the LLM to follow. The more details you add, the more customized the LLM's response will be. Limits. To prevent hallucinating, You must follow the given instructions. You give the model guardrails must not address any content or generate that it must stay within. answers that you don’t have data on or basis for. Language. Tell the model what Write the blog in English. language to generate output in. Style & Give the model style and The blog must be written at an 8th grade Tone. tone guidelines to follow. reading level and use adjectives to evoke imagery in the prose. Use brief, declarative sentences in an active voice. Strictly avoid using filler words, slang, and redundant language. The blog must be less than 600 words. When you put the ingredients, instructions, and additional information together, you get a prompt that looks like this. You are a world-renowned cake decorator and you have a well-loved bakery known for its cakes. You also have a popular blog read by your customers. Your customers include families, newlyweds, and children. Your customers have a sweet tooth and are always curious about new cakes you make with fresh methods. You are writing your latest blog post. You want to capture customers’ attention while teaching them about unique decorating techniques. You must follow the given instructions. You must not address any content or generate answers that you don’t have data on or basis for. Instructions: Write an informative article about cake decorating fundamentals. Include a comprehensive analysis of different cake decorating techniques. Discuss the tradeoffs and explore the challenges of different techniques. Include a call to action to see the techniques in action by trying my new cake that incorporates all of the techniques discussed in the blog post. Write the blog in English. The blog must be written at an 8th grade reading level and leverage adjectives to evoke imagery in the prose. Use brief, declarative sentences in an active voice. Strictly avoid using filler words, slang, and redundant language. The blog must be less than 600 words. Now, write the blog post. Understand Prompt Templates.. What’s a Prompt Template? Congrats! You’ve created a prompt that generates the output you want. But that was a fair bit of work. How do you scale that one prompt so that it can be used over and over again, creating output for different customers and products? The answer is, make your prompt into a prompt template. You can think of prompt templates as basic recipes that can be adjusted to meet a customer’s unique order. As a chef, you start with the same recipe and adjust it for different occasions, to meet different dietary restrictions, and to fit different taste preferences. All you need to do is add the customer’s order details to the basic recipe and you have a new customized recipe that meets the needs of that customer. Essentially, a prompt template is a reusable prompt. Prompt templates include placeholders for specific details about customers, products, and more. And once those placeholders are filled with real, relevant data, the prompt template becomes a truly personalized prompt. The ingredients and instructions are mostly the same, but the output is customized for your business and your target audience. Prompt templates help your teams generate data-driven and consistent output at scale. Using prompt templates is ideal for B2C communications because templates provide both a unified voice and personalization. They also help your teams focus on completing tasks, instead of repeatedly building individual prompts. Create a prompt template once, and generate countless versions of personalized content for your different audiences. Let’s take our prompt from earlier and turn it into a prompt template. You are a world-renowned {role} and you have a popular blog read by millions of readers worldwide. Your readers enjoy learning about {topic} from your blog. You are writing your latest blog post. Your readers include {target audiences}. You want to captivate your readers' attention and spark their interest in learning {topic}. You must follow the given instructions. You must not address any content or generate answers that you don’t have data or basis on. Instructions: Write an informative article about {subtopic}. Include a comprehensive analysis of {subjectA}. Discuss the tradeoffs and explore the challenges of {subjectB}. Include a call to action to try {product} that {description}. Write the blog in English. The blog must be written at an 8th grade reading level and leverage adjectives to evoke imagery in the prose. Use brief, declarative sentences in an active voice. Strictly avoid using filler words, slang, and redundant language. The blog must be less than 600 words. Now, write the blog post. Let’s put it all together. Instructions are what your team types into a generative AI app’s input field. The instructions are added to a prompt template that includes the other ingredients, such as the setting, limits, and real data. The result of that prompt template is the prompt that the LLM uses to generate output. Prompts, the Salesforce Way.. Where does the personalized data come from in your prompts? How do you turn a generic message into one that truly represents your business and connects with each of your customers? This module addresses some future functionality of Salesforce products. Any unreleased services or features referenced here are not currently available and may not be delivered on time or at all. Customers should make their purchase decisions based upon features that are currently available. It’s all about helping the LLM take advantage of your real Salesforce data. Once you’ve created your prompt template, you connect it to your CRM data, targeting and personalizing the output. After all, an LLM is only as good as its data, so you want it to use the most relevant data there is–yours. One way to do this is with merge fields, which we explore more in the next unit. You use merge fields to connect your prompt templates to Salesforce record fields, such as from sales or service records. When you send your prompt to the LLM, the merge fields are replaced with your specific business context and customer data. But merge fields are just the start. As a Salesforce prompt designer, you can also use Flow Builder to create dynamic prompt fragments that go way beyond linking record fields. Flows let you add complex logic to a prompt that helps you include exactly the data you need. For example, you can use a flow like the ones in the Flow Builder Basics module to add data based on the output of a decision tree. If this sounds powerful, you’re right. In the next unit let’s see how a Salesforce customer can combine their CRM data with instructions to create a great prompt template. Plan Your Prompt Template.. Ursa Major Solar is a rising star in the booming business of home and commercial solar. It sells panels and related hardware, does installations, and offers maintenance and support. Business is great, and it’s about to get better! Ursa Major Solar is about to go live with a new solar panel cleaning service. Ursa Major Solar is excited to share the news with its existing customers, but the company wants this campaign’s messaging to be more than a one-size fits all email. It wants each customer to get a tailored email that’s grounded in CRM data, like how long they’ve been a customer and where they’re located. At the same time, Ursa Major Solar wants the messaging to reflect the brand’s voice and tone. This is the perfect time for Lara, an admin, to get started with prompt templates. She needs to generate messaging for the new service targeted to existing customers. This narrow focus lets her start small and learn how to best use prompt templates for future, bigger campaigns. In this unit you see how Lara designs her first prompt template, and how she improves the template over time. Ask the Right Questions.. As you learned in the first unit, a great prompt gives an LLM the directions it needs to create a good output. But what makes a great prompt template? It mostly boils down to having good answers to four big questions. Who is involved, and how are they related?.. [Key Ingredients: Participants, relationships, data].. “Know your audience” is a familiar adage for anyone who writes or presents for a living. It just means that you usually have to change the way you communicate depending on who's reading, watching, or listening. In order for the LLM to know the audience, you must tell it! But even more, you have to tell the LLM who to role-play as. In this case, Lara wants the messaging to sound like it’s written by the account executive to the customer. With the players in mind, she starts the prompt template with this: You are an account executive named {!user.firstname} {!user.lastname} from a company named Ursa Major Solar. You are writing to {!contact.firstname} {!contact.lastname}, who is a {!contact.title} at {!account.name}. They have been a customer of yours since {!account.creationdate}. Notice that Lara is already grounding her prompt template with CRM data by including merge fields. Now the LLM can use the length of the customer relationship to guide the contents. Lara also included the names and roles of the people involved. That brings us to the second major question to answer. What are you trying to accomplish?.. [Key Ingredients: Goal, instructions].. There’s a reason Lara is creating a prompt template, and it’s not just to get a great marketing message generated. At the core of it, Ursa Major Solar wants to persuade existing customers to sign up for the new service. That underlying goal is important information the LLM should know. So Lara continues her prompt template by describing the goal in general terms. You are attempting to persuade {!contact.firstname} {!contact.lastname} to sign up for {!product.name}, which is described as {!product.description}. This is also a good time to include some direction for how to meet the goal. This might be a known strategy for crafting the kind of message you typically send. To that end, Lara includes this: Describe the business value of {!product.name} in the context of organizations based in {!account.location}. Lara uses “describe” as a direct command along with even more CRM data to influence the output. Ursa Major Solar has a lot of proprietary data at hand to work with, so this first template with its few merge fields is a modest beginning to a whole new way of using CRM data to provide useful business context to the LLM. And now she’s ready for the next question. What is the context?.. [Key Ingredients: Setting, tone & style, language].. There are a lot of modes of communication, and each has some expectations tied to it. For example, text messages are usually short, while emails can be a variety of lengths. So, to best guide the LLM, Lara will describe the setting in which the content will be used. Write the message in the form of an email directed toward a single individual, written in English. Lara is ever mindful of international audiences. When Ursa Major Solar begins operations in other countries, Lara can replace “English” with a merge field. Context also determines the style of output, too. Some situations call for a formal writing style, while others benefit from a conversational tone. Lara can describe some linguistic qualities so the output matches Ursa Major’s excitement. The message should evoke enthusiasm with intensifiers, but limit the use of exclamation points. Express casualness using contractions, referring to the recipient in second person, and using discourse markers. There are a lot of style cues Lara can try. Discourse markers, like “Oh,” “well,” or “so” will make the output seem more conversational. Later, Lara can tweak the template, but for now she has one last question to answer. What are the constraints?.. [Key Ingredients: Limits, instructions].. It’s very important to include a few guardrails to tell the LLM the limits of what it can do. For example, you should indicate that the content should not contain guesses if information is missing. It’s worth defining how long the content should be too. Lara does this by adding: Limit the message to about 500 words, and do not address any content or generate answers that you don’t have complete data on. Finally, there’s one more instruction that’s meta. Tell the prompt to only write the email message, and nothing else. This may seem odd, but it will help prevent the LLM from generating a response about the task of writing, instead of just doing the writing. Lara finishes the prompt template like so: Follow these instructions strictly to generate only the message to be sent to the customer. And with that, the prompt template is complete! Lara did a great job with her first attempt by considering these four important questions… 1. Who is involved, and how are they related? 2. What are you trying to accomplish? 3. What is the context? 4. What are the constraints? Altogether, her prompt looks like this:.. You are an account executive named {!user.firstname} {!user.lastname} from a company named Ursa Major Solar. You are writing to {!contact.firstname} {!contact.lastname}, who is a {!contact.title} at {!account.name}. They have been a customer of yours since {!account.creationdate}. You are attempting to persuade {!contact.firstname} {!contact.lastname} to sign up for {!product.name}, which is described as {!product.description}. Describe the business value of {!product.name} in the context of organizations based in {!account.location}. Write the message in the form of an email directed toward a single individual, written in English. The message should evoke enthusiasm with intensifiers, but limit the use of exclamation points. Express casualness using contractions, referring to the recipient in second person, and using discourse markers. Limit the message to about 500 words, and do not address any content or generate answers that you don’t have complete data on. Follow these instructions strictly to generate only the message to be sent to the customer. Her job is not done yet though. Lara knows that prompt designers must test their work, review the LLM output, and revise accordingly. Test and Iterate.. Anyone who’s played with generative AI tools knows that creating a prompt is a bit of an artform. It’s very common to get generated content that’s not quite right, even if the prompt seems clear. When Lara tries her prompt template, she gets a good result because she considered the four big questions thoroughly. Subject: Keep Your Solar Panels in Top Shape with Alpha Solar Hi Denise, I hope this email finds you well. As an account executive at Ursa Major Solar, I have been working with Northern Trail Outfitters for quite some time now, and I have always admired your company’s commitment to sustainability and environmental stewardship. I am reaching out to you today because I believe I have an offer that aligns perfectly with your values and goals. I am excited to introduce you to Alpha Solar, our monthly subscription cleaning service for solar panels. Alpha Solar ensures that your solar panels are in proper condition to maximize energy conversion, which means that you can enjoy higher energy yields and lower electricity bills. Our service is designed to keep your solar panels in top shape, even in the harsh weather conditions that are common in Des Moines, Iowa. What sets Alpha Solar apart from other solar panel cleaning services is our commitment to quality and reliability. We use only the best equipment and cleaning agents to ensure that your solar panels are cleaned thoroughly and safely. Our team of experts is trained to handle all types of solar panels, regardless of their size or complexity. We also offer flexible scheduling options to ensure that our service fits seamlessly into your busy schedule. By signing up for Alpha Solar, you can enjoy a number of benefits that will help your organization save time and money. For example, our service can help you avoid costly repairs and replacements by identifying and addressing potential issues early on. Our cleaning process can also help extend the lifespan of your solar panels, which means that you can enjoy the benefits of solar energy for years to come. I’m confident that Alpha Solar would be a great addition to your organization’s sustainability efforts. If you’re interested in learning more about our service, please don’t hesitate to get in touch. I’d be happy to answer any questions you may have and provide you with a customized quote based on your specific needs. Thank you for your time and consideration. I look forward to hearing back from you soon. Best regards, Cassiopeia Mars Account Executive Ursa Major Solar [Generated with gpt-3.5-turbo-0301] After a careful review, Lara shows examples of the generated content to stakeholders to see what they think. Their overall opinion is that it’s good, but they would like it to include a call to action at the end. So Lara updates the template to include the following instructions as part of the goal: Recommend that the customer attend one of the free webinars offered at {!company.trainingURL__c}. The new output from the updated template is now exactly what management was looking for. And since it’s easy for Lara to create different versions of the template, she can even run her own comparison tests on the output. The information Lara gathers from those tests will help her when it’s time to create a prompt template for the next big marketing campaign. Keep Humans in the Loop.. At this point, Lara briefs her account executives on how to use the template. She reminds them that when they use the template to generate output, they must review the responses every time. This is a best practice known as “human-in-the-loop,” and it’s a requirement for trusted generative AI. The execs acknowledge their role in keeping the responses relevant and unbiased, and they’re eager to start their messaging campaign with highly personalized emails for each customer.