Crafting effective AI prompts

Artificial Intelligence (AI) has seamlessly woven itself into the fabric of our daily lives, manifesting in various forms from voice assistants to sophisticated image generation tools. In my pursuit of heightened productivity, I have recently integrated Copilot into my workflow to elevate the quality of my writing (see Maybe with a little help). This journey began with a simple request: “Please rephrase the following paragraph in a more elegant manner: ‘PARAGRAPH HERE.’” 1 However, as I mentioned in my previous post about my discovery of the Prose Polisher prompt from Anthropic, the way you frame your prompts can significantly influence the outcome. Mastering the art of crafting these prompts is indeed crucial when interacting with AI. Consequently, I embarked on an exploration of the nuances and techniques involved in prompt engineering — the magical incantations that unlock the full potential of AI.

Crafting the right prompt can mean the difference between an AI delivering a valuable output that streamlines your workflow and receiving an inadequate response that leaves you more frustrated than relieved, forcing you to tackle the task independently.Sujatha R

What Are AI Prompts?

In the realm of artificial intelligence, a prompt is the cornerstone of interaction between humans and AI systems. It serves as the starting point for AI algorithms — the spark that ignites the engine of creativity within an AI’s neural network. It’s the query, statement, or input phrase that initiates a response or action from an AI system.

It’s like having a conversation with another person, only in this case the conversation is text-based, and your interlocutor is AI.MIT Sloan Technology Services Teaching & Learning Technologies

However, an AI prompt is much more than a mere command; it indeed sets the stage for the AI’s response. Your AI interactions and the output quality hinge largely on how you word your prompts. A well-crafted prompt can lead to outputs that are not only accurate and relevant but also creative and engaging, reflecting the user’s intent and the AI’s capabilities. The reverse is also true; hence, the importance 2 of prompt engineering.

Prompt engineering is the craft of designing and refining inputs (prompts) to elicit the desired output from AI language models. It requires a blend of creativity, understanding of the model’s capabilities, and strategic structuring of the question or statement to guide the AI towards providing accurate, relevant, and useful responses. Prompt engineering improves communication between humans and machines, ensuring the resulting interaction is efficient and effective.Sujatha R

The beauty of an AI prompt lies in its flexibility. It can be as simple as a single word or as complex as a multi-sentence instruction. It can also be tailored to elicit specific tones, styles, or formats, making it a powerful tool. In short, the prompt acts as a blueprint, outlining the user’s expectations and the desired outcome of the AI’s task.

Crafting an effective prompt can be likened to the art of asking the right questions.

Writing Effective Prompts

AI systems like ChatGPT combine natural language processing and machine learning to understand your prompts — even if you phrase them as if you’re talking to a human. However, the quality of your input directly influences the AI’s output. Specific, well-structured prompts yield more accurate and relevant responses. Effective prompts guide AI toward desired outcomes; they unlock the full potential of these powerful tools. Therefore, to instruct the AI on what you want, it’s best to apply AI prompt engineering best practices.

Asign a role

While it may seem unconventional, assigning a persona to an AI model can greatly enhance the relevance and precision of its responses. Lucas Pimentel, an AI developer, explains, Assigning a role to your AI counterpart will make them adopt the behavior of the role you assign. 3 By doing so, the AI generates responses that are more aligned with a specific perspective or expertise, ensuring that the information provided meets the unique requirements of your query. The AI will strive to emulate the assigned role, tailoring its answers accordingly. This seemingly simple step is often overlooked, yet it is crucial for obtaining the most relevant and accurate responses.

This method proves particularly advantageous in business settings where domain-specific knowledge is crucial. By guiding the AI to adopt a tone and terminology suited to the context, it ensures that the responses are both relevant and precise. Additionally, assigning a persona helps establish the right expectations, making interactions with the AI more relatable and engaging for the end user. This tailored approach not only enhances the accuracy of the information provided but also fosters a more meaningful and effective communication experience.

Be specific

Specificity is paramount when seeking the most accurate and relevant information from an AI through prompts. AI models generate outputs that heavily rely on the clarity and precision of the input queries they receive. By providing a clear, descriptive, and accurate task, you guide the AI to deliver information that aligns seamlessly with your intended use; thereby enhancing the overall quality and relevance of the responses. To achieve this, it is essential to include as many relevant details as possible without overwhelming the AI with extraneous information.

Specific, well-structured prompts yield more accurate and relevant responses.

The level of detail in your input directly influences the usefulness of the output you receive. While specificity is beneficial, it is however important to avoid overloading a prompt with excessive conditions or complex jargon, as this can obscure the clarity of the response. Striking the right balance ensures that the AI can process the information effectively, delivering precise and relevant results without confusion.

In essence, the key to an effective GPT prompt lies in striking a balance between clarity and specificity, guiding the AI’s response without overly constraining or biasing it.Mike Mantell

Provide context

In keeping with the above ideas, you can also make your prompts more sophisticated by providing some context, or even a voice. By adding context, you guide the AI toward a more relevant answer. Context is indeed the secret ingredient that transforms a good prompt into a great one, ensuring that AI responses are not just accurate, but also relevant and insightful.

Context matters – it ensures the AI understands your intent.

When we talk about context in prompt engineering, we’re referring to the background information and specific details that help the AI understand the task at hand. Think of it as setting the scene for a play. Without the right context, the actors (in this case, the AI) might deliver their lines, but the performance will lack coherence and depth. There are two main types of context to consider:

Input Context: This is the information you include directly in your prompt. For example, you should specify what the purpose of your prompt is (this may also include the target audience). You should also give the AI specifics about the preferred tone and/or style to make sure the output aligns with your intended audience or purpose.

External Context: This refers to any additional information the AI has access to during processing. For instance, if the AI has been trained on certain datasets or has access to particular databases, that’s part of its external context. This helps the AI draw on broader knowledge to provide a more informed response.

And again, while providing context is crucial, it’s also important to strike a balance. Too much information can overwhelm the AI, leading to confusion and less accurate responses. On the other hand, too little context can result in vague or irrelevant answers. The key is to provide just enough context to guide the AI without overloading it.

As AI continues to advance, the role of context will become even more important, making interactions smoother and more human-like.God of Prompt

Specify your desired output

Specifying the desired output is not just a best practice — it’s a necessity. What truly sets apart a well-crafted prompt from a mediocre one is indeed the clarity with which the desired output is specified. It eliminates guesswork and ensures the AI knows exactly what you want.

To master the art of specifying desired outputs, consider the following techniques:

Be Explicit: Clearly state what you want the AI to do. Use precise language and avoid ambiguity. For example, instead of saying “summarize this article,” specify “summarize this article in three bullet points, highlighting the main arguments and conclusions.”

Provide Examples: Show the AI what you expect by providing examples. This can be particularly useful for complex tasks. For instance, if you want the AI to generate a specific type of report, provide a sample report as a reference.

Use Constraints: Set boundaries for the AI to work within. This can include word limits, formats, or specific criteria. For example, “generate a 200-word product description that includes the product’s features, benefits, and a call to action.”

When constructing prompts for AI, it’s more effective to direct the system toward the desired action rather than detailing what it should avoid. This positive instruction approach reduces ambiguity and focuses the AI’s processing power on generating constructive outcomes.Sujatha R

Bonus tip

Going back to my previous article about the Prose Polisher prompt from Anthropic. You might remember that the latter was instructing the AI to follow these steps, providing seven specific ones. The idea was to help the user elevate the quality of their writing. This is a great learning opportunity indeed (instead of just copying/pasting the outcome). However, this approach is also useful when tackling complex problems or when the reasoning process itself is as important as the answer.

This technique, which encourages AI models to break down complex problems into intermediate steps, is called Chain-of-thought prompting. By guiding the AI to think step-by-step, this method enables it to tackle tasks that require logical thinking and multiple steps to solve, such as arithmetic or commonsense reasoning questions. In doing so, it improves the reasoning abilities of large language models (LLMs).

Chain-of-Thought prompting is a prompt engineering technique through which we force LLMs to output a sequence of intermediate steps that lead to the desired answer. It improves the reasoning abilities of LLMs. It is beneficial because it allows the model to focus on solving one step at a time, rather than having to consider the entire problem all at once. It can be especially helpful for complex problems that would be difficult or impossible to solve in a single step.Maithili Badhan

In short, by prompting the AI to articulate the steps it takes to reach a conclusion, you can better understand the logic employed and the reliability of the response. Not only does this elicit a more deliberate and explanatory response from an AI, but it also provides an interpretable window into the behavior of the model. 4

Prompt generators

Stuck on how to create a good prompt? Ask AI to help by creating one for you!Harvard University Information Technology

The task of creating effective prompts is complex and not everybody masters the skills of prompt engineering. Enter prompt generators — innovative tools designed to simplify and enhance the process of prompt engineering. They are specialized tools that use advanced natural language processing (NLP) and machine learning algorithms to create prompts for AI models. These tools are designed to understand user intentions and generate the most effective inputs for various AI tasks.

“An important focus of these tools is optimizing prompt quality to elicit the best response from the AI.”
“But how do you create your prompt to ask them to craft an optimized prompt? You use a prompt generator for prompt generators?”

Conclusion

Garbage in, garbage out. Genius in, genius out. Learn how to prompt ChatGPT effectively to unlock a new level of output and stop wasting your time.Jodie Cook

Crafting effective prompts may not involve any sorcery, but adhering to certain principles can significantly enhance the quality of AI-generated responses. A key guideline is to ensure your prompts are as detailed and comprehensive as possible, as this tends to yield more accurate and relevant outputs.

Moreover, it’s crucial to approach this burgeoning field with an experimental mindset. As you explore the nuances of prompt engineering, adopt an iterative approach: test various prompts, observe the outcomes, and refine your techniques. Pay close attention to how even minor adjustments can dramatically influence the AI’s responses. This hands-on experimentation is essential for understanding how different models react, and it is through this process that you will truly master the art of prompting.


1 At the time of this writing, I still do; I am not using the Prose polisher prompt and I have not yet come up with a better prompt. ^
2 At least today! As mentioned in the article — Effective Prompts for AI: The EssentialsAI platforms and the models they are based upon are rapidly evolving and becoming more sophisticated. For that reason, some experts doubt whether the importance of prompt engineering will be long lasting. ^
3 Jodie Cook (2023) How To Write Effective Prompts For ChatGPT: 7 Essential Steps For Best Results. Forbes. ^
4 Maithili Badhan (2024) Comprehensive Guide to Chain-of-Thought Prompting. Mercity. ^