What is prompt engineering? How to write a good prompt?
- 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
Zero shot prompting
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
Example
Prompt: "Translate "Good Morning" to french
AI response: Bonjour
This type of prompting is useful when you're doing some generalize task and which doesn't need specific instructions
Few shot prompting
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
Example
Structured prompt: Translate the following English phrases to French:
Good morning: Bonjour
How are you?: Comment ça va?
See you later: À plus tard
Good night: [AI completes]
AI response: Bonne nuit.
Few shot prompting is good approach to consider when you expect structured and task specific responses
Chain of Thoughts
This a advanced prompting method when it allows AI model to generate logically reasoning before concluding final answer, it enhances problem solving capabilities
Example
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?"
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.
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:
Clarity & Specificity
Make sure the prompts are clear and unambigous. Specific prompts will help the AI model to generate more accurate and relevant responses
Example
Instead of prompting "Tell me about Python"
Use "Explain the key features of the Python programming language."
Contextual Information
Providing context within the prompt helps the AI understand the background and generate more informed responses
Comments