AI – How to write an effective Prompt for AI

By | 04/12/2024

In this post, we will see how to write a good Prompt for a generative model like ChatGPT.
But, why should we be careful to write a good Prompt when using AI?
A well-structured prompt serves as a clear roadmap, guiding the AI to understand our intentions, context, and specific requirements. Without a precise prompt, we might receive generic or off-target answers that don’t fully meet our needs. By investing time in designing effective prompts, we unlock the full potential of AI generative models, ensuring that the content generated is not only coherent and comprehensive but also tailored to our specific objectives.
In order to write an effective prompt, we should incorporate five key elements: Role, Task, Specifics, Context and Example.
Let’s see them in details:

ROLE: Defining the Role sets the perspective or expertise we want the AI to adopt. By specifying a role, we guide the AI to respond in a manner consistent with that persona.

TASK: The Task is the primary objective we want the AI to accomplish. It clarifies what we expect from the AI, whether it’s writing an article, solving a problem, or generating ideas.

SPECIFICS: Including Specifics provides detailed instructions that narrow down the scope of the task. This can include style guidelines, format preferences, content requirements, or any constraints.

CONTEXT: Providing Context helps the AI understand the background or situation surrounding the task. This ensures the response is relevant and appropriately tailored.

EXAMPLES: Including Examples illustrates what we are looking for and guides the AI towards the desired output.

Furthermore, when we interact with AI, the way we present our prompts can influence the quality of the response we receive.
For this reason, I suggest to use Markdown to structure our prompts becuase it brings clarity and organization to our instruction.
But what is Markdown?
Markdown is a simple markup language that allows us to format text using plain text syntax. By incorporating headings, subheadings, bullet points, and emphasis through Markdown, we make each part of our prompt distinctly visible and easier to understand.
It separates different sections such as the role we want the AI to assume, the specific tasks you need completed, any contextual information, and examples into clear, organized segments. This structured approach reduces ambiguity and ensures that important details are not overlooked.
The basic Markdown Syntax are:

  • Headings: # Heading 1, ## Heading 2, ### Heading 3, etc.
  • Bold text: **bold text**
  • Italic text: *italic text*
  • Bullet lists: - Item 1, - Item 2

For all information about Markdown, this is the official web site: https://www.markdownguide.org/


Now, let’s see some prompt examples:

Travel blogger: In this example, we will ask the AI to create a travel blog post about London.
This could be the prompt:

# Role
## You are an experienced travel blogger and a local expert on London.

# Task
## Write an engaging blog post about must-see attractions in London for first-time visitors.

# Specifics
-   **Introduction**: Begin with an inviting introduction that captures the excitement of visiting London for the first time.
-   **Main Content**:
    -   Describe five must-see attractions in London, such as the Tower of London, Buckingham Palace, the British Museum, the London Eye, and Camden Market.
    -   Include interesting facts or stories about each attraction that make them unique.
    -   Provide practical tips for first-time visitors, such as the best times to visit these attractions and how to avoid crowds.
-   **Tone and Style**:
    -   Use a friendly and conversational tone that is approachable for tourists.
    -   Make the content engaging by adding personal anecdotes or experiences related to the attractions.
    -   Use descriptive language to help readers imagine the sights, sounds, and atmosphere of London.
-   **Format**: Structure the post with headings for each attraction and include an overview at the end summarizing why London is a great destination for first-time travelers.

# Context
## The post is intended for a travel blog aimed at young adults and families planning their first trip to London. The readers are looking for informative yet fun and inspiring content that will help them plan their itinerary and make the most of their time in the city.

# Examples
## Example 1: Tower of London
Describe the historical significance of the Tower of London, mention the Crown Jewels, and provide a tip on the best times to visit to avoid long lines.

## Example 2: Camden Market
Talk about the vibrant atmosphere of Camden Market, describe the unique street food stalls, and recommend a few must-try dishes.


Below is the output generated by the AI:



Culinary writer: In this other example, we will ask the AI ​​to describe how to prepare a perfect Chinese duck dish.
This could be the prompt:

# Role
## You are a professional chef specializing in Chinese cuisine and a culinary writer.

# Task
## Write a detailed recipe for preparing an authentic Peking Duck, suitable for experienced home cooks.

# Specifics
-   **Introduction**: Begin with a brief history of Peking Duck, explaining its significance in Chinese culinary tradition. 
-   **Ingredients**:
    -   Provide a complete list of ingredients with precise measurements.
    -   Include any specialty ingredients required, such as maltose syrup and five-spice powder, with possible substitutions if necessary.
-   **Instructions**:
    -   Offer step-by-step instructions on how to prepare the duck, including:
        -   Cleaning and preparing the duck.
        -   Air-drying techniques for achieving crispy skin.
        -   Marinating processes.
        -   Roasting methods, including traditional techniques if possible.
-   **Serving Suggestions**:    
    -   Offer tips on presentation for an authentic dining experience.
-   **Tone and Style**:
    -   Use clear and detailed language suitable for experienced home cooks.
    -   Incorporate professional cooking tips and explain any specialized techniques.
-   **Format**:
    -   Structure the recipe with clear headings and numbered steps for easy following.
    -   Include a notes section for additional tips or variations.

# Context
## The recipe will be featured in a gourmet cooking magazine aimed at home chefs looking to recreate authentic Chinese dishes.

In this example, I didn’t include the Examples section because I didn’t have any examples to show at the AI.


Bellow is the output generated by the AI:



Writing an effective prompt is very important for getting the most out of AI generative models like ChatGPT.
By including the Role, Task, Specification, Context, and Example elements and structuring our prompts using Markdown, we can guide the AI ​​to produce high-quality, relevant, and useful responses.
So I suggest to take the time to plan and structure our prompts in order to have better outcomes.




Category: AI Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *