top of page

What is prompt engineering? How to write a good prompt?

  • Writer: Aakash Walavalkar
    Aakash Walavalkar
  • Feb 14
  • 3 min read

Introduction

In the paced environment of artificial intelligence, talking specifically about natural language processing the way we interact with AI models has become very interesting & significant. While interacting with an AI model the basic & core of interaction is the “prompt”.


A “prompt” can be defined as an input instruction to the AI model which will give more context to the model and get desired response from it. The permutations and combinations of these prompts all together are known as prompt engineering.


Introduction to Prompt

A prompt is basically an input provided to AI model which acts as a instruction to generate responses. It can be a question, statement, facts or an directive that gives clarity to AI model of the expected output. If clarity and specific instructions are provided to the prompts it will significantly improve the relevance and quality of the response generated by AI model


Example

General Prompt: "Explain climate change"

Specific Prompt: "Explain primary causes of climate change and their impact on coastal cities"


Does prompt impacts AI model Response?

If you are thinking about this, the answer is Yes! Absolutely. A well structured and precise input will generate meaningful & context specific responses, where as a poorly structured prompt can lead to vague, incomplete and target off responses.


Example

Unstructured prompt: "Tell me about Java"

Potential AI Response: Information about the Java programming language or the Indonesian island of Java.


Structured prompt: "Tell me about Java programming language"

AI Response: Detailed information about the Java programming language.


What is Prompt Engineering?

It is a practise of structuring & refining the prompts to better the AI model performance. It has various factors like how different tonality, expression of speech, context awareness can influence AI model performance while generating responses.


Prompt engineerings is an essential step while building applications like chatbot, virtual assistant and content generation tools where quality of the AI model response directly affects the user experience.


Types of prompting

  1. Zero shot prompting

    1. In zero-shot prompting, AI model is given task without any instruction or example about the specific task. The AI model completely relies on the pre-training data to generate the responses

    2. Example

      1. Prompt: "Translate "Good Morning" to french

      2. AI response: Bonjour

    3. This type of prompting is useful when you're doing some generalize task and which doesn't need specific instructions

  2. Few shot prompting

    1. In this method AI model is provided with few examples of expected response. These example helps AI model to understand the structure and generate responses

    2. Example

      1. Structured prompt: Translate the following English phrases to French:

        1. Good morning: Bonjour

        2. How are you?: Comment ça va?

        3. See you later: À plus tard

        4. Good night: [AI completes]

      2. AI response: Bonne nuit.

    3. Few shot prompting is good approach to consider when you expect structured and task specific responses

  3. Chain of Thoughts

    1. This a advanced prompting method when it allows AI model to generate logically reasoning before concluding final answer, it enhances problem solving capabilities

    2. Example

      1. Structured prompt: "The cafeteria had 23 apples. If they used 20 to make lunch and bought 6 more, how many apples do they have now?"

      2. AI response: Let's think step by step.

        • Start with 23 apples.

        • Used 20 for lunch: 23 - 20 = 3.

        • Bought 6 more: 3 + 6 = 9.

        • Therefore, they have 9 apples now.

    3. This approach is beneficial when it comes to complex problem solving capabilities and mathematical calculations


Best practices in prompt engineering

To generate effective responses and use the AI model to it's full capacities through prompt engineering you need to follow these practices:


  1. Clarity & Specificity

    1. Make sure the prompts are clear and unambigous. Specific prompts will help the AI model to generate more accurate and relevant responses

    2. Example

      1. Instead of prompting "Tell me about Python"

      2. Use "Explain the key features of the Python programming language."


  2. Contextual Information

    1. Providing context within the prompt helps the AI understand the background and generate more informed responses

Comments


Empowering data science enthusiasts with vibrant discussions, expert Q&A, and specialized services for an accelerated journey towards success.

Thanks for subscribing!

bottom of page