In the previous article in this series, Understanding Prompt Engineering and Its Importance we discussed the importance of prompt engineering. Now, let’s take a look at some of the techniques that can help you to obtain useful, consistent results. Mastering the art of prompt engineering is vital for making the best use of the tools available today, and will build a strong foundation for the increasingly powerful systems that will be available in the near future. By building experience in the areas of prompt phrasing, step-by-step guidance, incorporating examples, and experimentation, users can significantly enhance the quality of their interactions with these new AI systems.
Four techniques
Prompt Phrasing
The manner in which a prompt is structured directly influences the quality of the response. The previous article in this series reviewd this concept in some detail, including a few examples to help structure clear prompting. For example, to reduce ambiguity, and ensure that the AI model understands the intent, instead of asking “Tell me about keyboards” consider a prmpt with more detail, such as “Please provide a brief history of keyboards used in music production” The first prompt is likely to cause the AI to elucidate on human interface devices (computer keyboards) rather than a musical instrument.
It is also important to provide specific instructions in prompts, as this can help guide the AI model towards a more helpful, accurate, and ultimately, useable output. Expanding on our example above, rather than Please provide a brief history of keyboards used in music production”, a more specific prompt could be “Please provide a brief history of keyboards used in music production, with a few notable keyboardists and an emphasis on psychadelic rock”
Step-by-step guidance
Just as is the case for humans in daily life, it is important to break complex tasks into smaller. more manageable parts for AI models. Instead of asking the model to “Write a complete guide on photography”, ask first for “An outline of important topics to cover in a photography guide,” and then proceed to ask and expand on each topic individually. This will allow for better control overr the output.
And, just as before in “Prompt Phrasing,” it’s important to provide proper context for each step as well to help the AI model understand the overall goal of the task. When working on the “Gear and Equipment” section of the photography guide, when requesting information about “Lenses and Focal Lengths,” provide an overall objective of that section, e.g.: The section “Lenses and Focal Lenghts” will cover at a macro view the different types of lenses and focal lengths, without going into too much detail about a specific type. Please provide an introduction and closing paragraph for this section, and provide a list of common lenses and focal lengths in tabular form.
Incorporating Examples
This technique is arguably one of the most effective and important when constructing solid prompts. The quality of the returned data can be significantly enhanced if examples of the desired output format are provided. For example, if prompting for a haiku, including a sample haiku that demonstrates the 5-7-5 syllable structure would assist the language model with comprehending the request.
Examples also help clarify specific requirements, such as tone, style, or content. If you wanted a scientfic report written in a formal, journal style, providing one written in the desired style along with the request can produce a similar style of report.
Experimentation and Iteration
The most effective way to improve one’s skill with prompt engineering is simply to experiment with different prompt variations. This will help identify the most effective way to communicate a request to an AI model.
As an example, the same general prompt could be sent to the model in three differrent ways:Summarize this article in 3-4 sentencesProvide the main points and conclusions of this articleCondense this article into a concise summary.
Once each reponse is reviewed, the responses can be evaluated for accuracy, clarity, and useability. Prompts that don’t yield the desired output can be changed, accounting for phrasing, instruction, or even examples to improve the model’s understanding of the request.
Ultimately, prompt engineering plays a vital role in optimizing AI model performance and user satisfaction. The use of clear language, specific instruction, breaking down complex tasks, providing context and examples, and experimetnation, a Prompt Engineer can shape and ensure that theur prompts effectively communicate their intentions and desired outcome to the AI. This helps to unlock more of the full potential of AI models, which enables more efficient and accurate utilization fo their capabilities.
Some Example prompts based on the techniques in this article:
Prompt Phrasing
Example:
Task: Request information on the health benefits of green tea.
Poor Prompt: “What’s good about green tea?” Improved Prompt: “Please describe the health benefits of green tea, including its impact on heart health and antioxidants.”
Example:
Task: Request a list of popular tourist attractions in Paris.
Poor Prompt: “Tell me about cool places in Paris.” Improved Prompt: “Provide a list of top 5 popular tourist attractions in Paris, France, that are frequently visited by travelers.”
Step-by-step guidance
Task: Write a tutorial on setting up a website with a custom domain.
Step 1: “Explain how to choose and purchase a domain name from a domain registrar.” Step 2: “Describe the process of selecting a web hosting provider and setting up an account.” Step 3: “Outline the steps to connect the purchased domain to the web hosting account.” Step 4: “Provide guidance on installing a content management system, such as WordPress, on the web hosting account.” Step 5: “Offer tips on customizing the website, including theme selection and adding content.”
Incorporating Examples
Prompt: Write a limerick about a cat, similar to this example:
Example: “There once was a cat from Peru / Who dreamed of eating a shoe / It gave it a taste / But in such a haste / It swallowed a lace and turned blue.”
Prompt: Create a slogan for a fictional eco-friendly toothpaste brand, like this example:
Example: “Clean teeth, green planet: Brush with NatureSmile!”
Prompt: Compose a tweet announcing a new product launch, similar to this example:
Example: “Introducing our latest innovation, the PowerCharge 3000! 🔋 Say goodbye to low battery life and hello to endless adventures! 🌍 Available now! 🚀 #PowerCharge3000 #StayConnected”
Experimentation
Prompt Variation 1: “Tell me about Albert Einstein.”
Prompt Variation 2: “Give me a short introduction to Albert Einstein, focusing on his major contributions to science.”
Prompt Variation 3: “In 2-3 sentences, describe who Albert Einstein was and his most famous achievements.”