Productivity

·

6 min

Productivity

·

6 min

Productivity

·

6 min

How to Prompt

How to Prompt

How to Prompt

Not all of us have kept up with the generative AI trend well enough to know how to effectively craft...

Not all of us have kept up with the generative AI trend well enough to know how to effectively craft...

Not all of us have kept up with the generative AI trend well enough to know how to effectively craft...

Not all of us have kept up with the generative AI trend well enough to know how to effectively craft a prompt to get the desired result. Even those of us who HAVE been keeping up with the LLMs find ourselves continuously improving what and how we ask the LLMs to respond. There is definitely a “the more you do it, the better you get” aspect to it. However… there are some general items that are pretty consistent and I wish I had known when I first began.

I’m a former English teacher turned IT professional. It isn’t hard to see that, although I might have learned how to diagram a sentence, I’m not much for following the traditional rules for grammar. Just like a sentence ‘must’ contain a Subject and verb, there are two things a prompt must contain as well, an Action and Context.

Action and Context

The Action is what you want the AI to perform for you. It’s the action verb that clearly describes your end goal. Without the action, the AI won’t know what you want it to do. And without Context, the action has no substance. Context is where the details come in to play. It’s the background description that helps to clarify the Action. Context is the contextual details that are necessary for the AI to understand what you are trying to accomplish.

Generate (Action) a week-long meal plan (Context), provide (Action) calories per meal (Context), make (Action) at least one meal per day vegetarian (Context).

In the example above, you can easily see the Action/Context process. For more complex prompts, you can split the tasks into simple subtasks. Don’t hesitate taking complex tasks and write them out in step by step instructions.

Step 1 – Generate a week long meal plan, include at least one vegetarian meal per day

Step 2 – Provide calories for each meal from step 1

Step 3 – Make a kid friendly form of each recipe as well

And that is the required lowest level prompt. Action/Context.

But there is more to life than just breathing… If you plan on taking your prompting to the next level then you might consider including the following:

Examples

Role/Persona

Format

Voice

Examples

You will get responses from the Action/Context prompts, but if you want to refine the answers to your desired expectation, give it some Examples of what you are hoping to get returned to you. In the example above, you could add a favorite recipe to the end of your prompt after adding a line like, please use the following example as your guide”. Examples like that will help the AI to understand what type of information you are looking for. For LLM’s with access to the internet, you can use URLs for examples. This helps in two ways, it gives the AI a guide to follow while also helping to cut down on AI hallucinations, giving you a more concrete and credible response. Something as simple as the following works, “Please use this guide as the basis for the recipes you create, https://www.thekitchn.com/how-to-write-a-recipe-58522

Here's an example of a response using that URL as a guide (I would include a tablespoon of Cumin, 1/4 teaspoon of garlic powder, some onion powder and smoked paprika, myself, but…):

Sure, here's a basic recipe for Classic Chili taking inspiration from various sources and following the guidelines provided:


Title: Classic Chili

Ingredients:

  • 5 Strips of uncooked bacon, chopped

  • 2 tablespoons of vegetable oil

  • 1 large yellow onion, diced

  • 1 red bell pepper, diced

  • 3 cloves of garlic, minced

  • 1 lb. ground beef

  • 1 ½ tablespoons chili powder

  • 1 Jalapeño, finely chopped (optional)

  • 1 can of red kidney beans, drained

  • Salt and pepper to taste

Instructions:

  1. Heat the vegetable oil in a large pot over medium heat. Add the chopped bacon and cook until crispy. Remove the bacon with a slotted spoon and set aside. Save the bacon fat inside the pot.

  2. In the same pot, add your diced onion, diced red bell pepper and minced garlic. Cook for 2-3 minutes until they start to soften.

  3. Once the vegetables are softened, add the ground beef to the pot. Cook until the beef is browned and cooked through.

  4. Add in the chili powder, cooked bacon, and jalapeño if using. Mix until everything is combined.

  5. Add the drained kidney beans to the pot, stir everything together. Allow the chili to simmer on low heat for 15-20 minutes. Season with salt and pepper to taste.

  6. Serve hot with any toppings you prefer like shredded cheese, chives, or sour cream.

Preparation Time: 10 minutes

Cooking Time: 30 minutes

Servings: 4

Notes: This is a spicy dish because of the Jalapeño. If you prefer a less spicy version, you can leave it out. Remember, the key to making great chili is to let it simmer for a good amount of time - the longer, the better the flavors develop.
Examples aren’t necessary, but they do help narrow down the answers you get to be more like what you want them to be.

 

Roles/Persona’s

Giving the AI a Role/Persona helps it “get in character” for the response and make the answer more focused. Ask yourself who you would want to answer the task you are giving it.  If you use the examples above and preface the request with one of the two following statements, you will get some different answers:

You are a nutritionist, generate a week long meal plan…

You are the world winner of the barbecue smoker contest, generate a week long meal plan…

It’s easy to see how the prompts will generate a different result. Basically, the generic result might be fine, but asking the AI to take on a persona, gives it a clearer goal of what you want. A job description written as if the AI were a professional recruiter, a Set of recovery exercises from the perspective of a physical therapist… Not necessary, but worth the extra words…

Format

Similar to the Examples, this helps refine your output. At its simplest, it’s you telling the AI how you want the answer presented to you. Do you need details, do you need fewer sentences, do you want a summary, bullet points, or a table, do you want a long response or a short one, etc. This is also where it’s been determined that asking for a “Chain of thought” or “Step by step” method helps increase the accuracy of the answer, making the returned result more reliable. For Math, in particular, asking the AI to “think through the answer and answer step by step” has proven successful. This is the time where you close your eyes and imagine how you want the results given to you and then ask the AI to give you the results in that format.

Voice

This is where you can have a little fun or take away too much fun. What voice or tone would you like the response to be? Casual? Formal? Sarcastic? If this is for a specific audience, you would ask yourself how you would want the written output to be received or interpreted. Do you want to be taken ‘Seriously’ or is this a time for ‘Humor’?

Conclusion

I only add the conclusion above to separate it from the Voice section. At times I believe I buck against the standard sentence structure just because I was an English teacher once. Regardless, the advice above is a starting point. These are suggestions on how to start prompting and, like diagramming sentences, the more you write the more rules you’ll break. And the beauty and inspiration and the best results come when you are able to start breaking the rules a bit. But you shouldn’t break the rules until you know them. Use these to help refine your prompts and the more you play around with how you task the AI with them, the more you’ll identify the subtleties that can exist. Good luck and good prompting.

Necessary:

Action

Context

Optional, but will help refine the output:

  • Examples

  • Role/Persona

  • Format

  • Voice

Continue reading