How to write AI prompts? A step-by-step guide

Learn the best practices for writing AI prompts to enhance user interactions and improve AI performance. Master the art with our expert tips!

May 27, 2024 - 16:52
May 28, 2024 - 10:32
How to write AI prompts? A step-by-step guide
AI prompts

Crafting effective prompts is crucial when interacting with AI models, as they are essential for generating accurate responses. This guide will delve into the significance of prompt engineering and equip you with the tools and techniques to create high-quality prompts that yield desired outcomes.

What is an AI prompt?

Fundamentally, an AI prompt is a set of instructions given to an AI model to produce a response. Prompt engineering entails meticulously crafting and perfecting these instructions to achieve the intended result. This process involves testing various wording, contexts, and conditioning methods to enhance the accuracy and appropriateness of the responses generated.

Different types of AI prompts

Different types of AI prompts exist, each serving distinct purposes and necessitating specific approaches.

Below are several common prompt types, accompanied by examples pertaining to prompt engineering:

Prompt type Description Prompt example
Completion prompts This entails presenting an unfinished sentence and requesting the AI model to create a logical continuation. "Finish this sentence, please: The rainiest month in Florida is…"
Question prompts This involves posing a particular question to prompt the AI model to produce a relevant response. "What are the fundamental principles and methods employed in prompt engineering to enhance the performance of AI models?"
Instruction prompts This involves giving clear instructions for the AI model to follow, detailing the desired result.

"Provide a list of safety guidelines for maintaining fire extinguishers in office environments."

Comparison prompts This involves instructing the AI model to compare various elements and derive insights based on the specified criteria. "Contrast the dynamics of rock recordings from the 1970s to rock recordings from the 2000s."
Creative prompts This involves prompting the AI model to produce creative ideas, stories, or artistic creations. "Write a fictional story about a boy who experiences bullying at school, overcomes his social challenges, and develops self-confidence. Along the way, his friends and parents help to bolster his self-esteem."
Translation prompts This entails giving the AI model text in one language and directing it to translate it into another language. "Provide an English translation of the Ecuadorian president’s speech from April 11, 2017."
Summarization prompts This involves requesting the AI model to summarize a given text or information into a brief, concise format.

I need a summation of the article entitled “Radical Approaches to Eliminating Child Malnutrition in Late 19th Century Britain,” from the June 2021 edition of Sociology and History.

Dialogue prompts This involves directing the AI model to produce responses from various perspectives or characters. "Pit Kant’s conception of morality against Hume’s in the form of a debate."

Preparing to write AI prompts

To maximize the effectiveness of AI prompts, you can take the following preparatory steps:

  • Define the target audience and purpose: Understand the intended users of the AI-generated content and its purpose. This knowledge will guide the design of effective prompts. If you plan to specify a particular writing style for the AI model, such as ChatGPT, ensure you have the legal right to use that style to avoid copyright and other legal issues.
  • Research the topic: Develop a thorough understanding of the subject matter to create prompts that elicit accurate and relevant responses. This step also helps in identifying and correcting any potentially incorrect information provided by the AI model.
  • Understand the AI model's capabilities: Familiarize yourself with the strengths and limitations of the AI model to leverage its capabilities effectively. This understanding will also help manage expectations regarding the quality and type of output the model can provide.

How to write a good AI prompt?

When crafting AI prompts, it's essential to adhere to the following principles:

  • Use clear and concise language: Use language that is clear and concise to ensure that the AI model understands the task or request accurately and avoids any confusion. Avoid spelling mistakes and use correct punctuation.
  • Provide context and background information: Include the necessary context and background information in your prompts to help the AI model understand the subject matter and generate more contextually relevant responses.
  • Consider the AI model's internet access: Keep in mind that some AI models may not have live access to the internet. If you're discussing a very new topic, provide novel information in your prompt to enable the model to provide an updated and relevant response.
  • Give specific instructions and guidelines: Include specific instructions and guidelines in your prompts to direct the AI model toward generating outputs that align with your desired requirements or objectives.

Here's a practical example to illustrate these guidelines.


The first example, "Without prompt engineering," lacks specific instructions, such as the function name and desired output format, making the task ambiguous for the AI model.
On the other hand, the "With prompt engineering" example provides clear instructions by specifying the function name "count_word_occurrences," the input format (a string of text), and the desired output format (a dictionary with word counts). These details help the AI model understand the task better and generate more accurate code.

To enhance the clarity of your prompts, include examples of inputs and desired outputs. This helps the AI model understand the expected response format and content better. Here's a practical example.


The enhanced prompt clarifies the task by providing specific examples of the expected input and output, illustrating the desired result more clearly.

Anticipate and address potential challenges:

Foresee any challenges or limitations the AI model might face and address them preemptively in your prompts. For example, avoid placing two questions in the same line, as the model may only be able to answer one.

Customizing prompts for specific AI models

To maximize the potential of AI models, it's crucial to tailor prompts that align with their unique capabilities and optimize performance. Here are a few key considerations when working with different AI models:

  • Understand AI model capabilities: Different AI models have varying capabilities, such as text generation, image generation, or both. Some models can retrieve information from the internet, while others rely on pre-scanned databases. Understanding these capabilities is essential for crafting effective prompts.
  • Modify prompts for specific tasks: Since AI models excel in different tasks, it's necessary to modify prompts to suit specific task requirements. For example, for a language translation task, a well-formulated prompt would include the input language, the desired output language, and a specific sentence to be translated.
  • Adapt prompts for fine-tuning or transfer learning: For fine-tuning or transfer learning processes, adapt prompts to meet the specific requirements of these techniques. This adaptation helps the AI model learn and apply knowledge from related tasks or domains, improving the quality of its responses.

Testing and iteration

After successfully prompting an AI model to create insightful content, you can take additional steps to further enhance the effectiveness of your AI prompts:

  • Test with sample prompts: Before inputting large amounts of text, test a set of sample prompts and evaluate the generated outputs. This allows you to gather feedback and make necessary refinements before applying them to a broader sample.
  • Iterate and refine prompts: Incorporate user feedback and iterate on your prompts to continuously improve their quality and performance. When incorporating feedback, rephrase it to maximize the AI model's performance, as explained earlier.

Best practices for writing AI prompts

Here are several measures you can take to ensure the quality and ethical considerations of your AI prompts.

  1. Avoiding ambiguity and unintended bias: Use language that is clear, precise, and unbiased to generate appropriate responses. Request the model to eliminate unintended biases, but review the results as they may not catch all biases.
  2. Considering ethical concerns: Be aware of how AI-generated content can impact your audience and ensure prompts align with your or your company’s ethical standards.
  3. Incorporating diversity and inclusivity: Create prompts that embrace diverse perspectives and promote inclusivity to avoid biased or one-sided responses. Modify potentially biased responses to remove these biases.
  4. Ensuring prompts are open-ended and adaptable: Develop prompts that inspire creativity and allow the AI model to generate various responses, rather than restricting it to a limited set of possibilities.
  5. Balancing guidance and freedom for creativity: Provide enough guidance in prompt creation to ensure results are acceptable, while also allowing for creativity. Achieving the right balance may require some experimentation.

Resources and tools

Online platforms and APIs

 Various online platforms and APIs offer prompt generation features. These platforms typically have user-friendly interfaces for inputting requirements and receiving generated prompts.

Some platforms also incorporate advanced AI models, allowing you to explore different prompt styles and variations. These tools can streamline the prompt generation process, saving you time and effort.

Here are some commonly used platforms and APIs for generating AI prompts:

  • The OpenAI playground provides text generation using powerful language models.
  • ChatGPT offers a user-friendly interface for direct interaction with the model.
  • Hugging Face Transformers provides pre-trained language models through their Python library.
  • IBM Watson’s natural language understanding service and Google Cloud’s natural language API enable text analysis for generating AI prompts.
  • Microsoft Azure provides services like the text analytics API and language understanding (LUIS) for understanding text and generating meaningful prompts.

Reference materials and case studies

Using reference materials and case studies is crucial for crafting effective AI engineering prompts. These resources offer valuable insights and real-world examples that shape the content and context of the prompts.

Reference materials, including academic papers, technical documentation, and industry reports, provide in-depth knowledge of AI concepts, algorithms, and methodologies. They form the basis for creating prompt questions that encourage engineers to apply their knowledge and problem-solving abilities.

Case studies demonstrate practical AI implementations across different fields, helping prompt creators design scenarios that mirror real-world challenges.

What's Your Reaction?