
- Published on
Mastering Prompting: A Guide to Writing Effective AI Prompts
Does it happen to you that you try and try again to make yourself understood by an AI model?
Well, just like in any aspect of your life (relationships, work, etc.), effective communication with AI models is a great skill too! Here is how >>>
Principle 1: Write Clear and Specific Instructions
The more precise your instructions, the better the AI's response will be. Avoid vague prompts and instead focus on clarity and structure. Remember: clear ≠ short.
1. Use Delimiters
Delimiters help separate different parts of your input to avoid misinterpretation, especially if your input is a complex text or there are quotation marks inside. You can use:
- Triple backticks (```),
- Angle brackets (< >),
- Triple quotation marks (””” “””), and more.
Example:
Summarize the text delimited by angle brackets in one sentence:
< AI models are powerful tools that can assist with tasks such as writing, data analysis, and problem-solving, but their effectiveness is entirely dependent on the prompts given. A well-structured prompt provides clear instructions, context, and constraints, ensuring the AI generates relevant and useful responses. Conversely, vague or ambiguous prompts can lead to misleading or incomplete outputs. For example, asking an AI to "write about history" is too broad, while specifying "summarize the key events of the French Revolution in 200 words" results in a more precise response. Thoughtful prompt design is essential for maximizing AI’s potential. >
Expected output:
The effectiveness of AI models depends on well-structured prompts that provide clear instructions, context, and constraints to ensure relevant and useful responses.
2. Ask for Structured Output
Specify how you want the response to be formatted, such as JSON or HTML.
Example:
Generate a list of two imaginary travel destinations along with their locations and unique attractions. Provide them in JSON format with the following keys: destination_id, name, location, attraction.
Expected output:
[
{
"destination_id": 1,
"name": "Celestara Cove",
"location": "The Luminous Isles",
"attraction": "A secluded beach where the sand sparkles like stardust and the waves glow under the moonlight."
},
{
"destination_id": 2,
"name": "Eldermyst Hollow",
"location": "The Whispering Woods",
"attraction": "An ancient forest where trees emit a soft hum, and glowing fireflies form mesmerizing patterns in the night sky."
}
]
3. "Few-shot" prompting
Few-shot prompting helps guide the model’s response style by providing examples within the prompt. This technique is useful for ensuring the model follows a specific format or tone.
Example:
Your task is to generate responses in the voice of an adventurous and inspiring outdoor gear brand.
Customer: What makes your hiking boots different?
Brand: Every step is an adventure. Our boots aren’t just footwear; they’re your trusted companions on rugged trails, built to endure and empower your wildest journeys.
Customer: Can I use them in snowy conditions?
Expected output:
- Brand: Conquer the cold with confidence! Designed for all terrains, our boots grip icy paths and keep your feet warm, so you never have to cut your journey short.
In this case, the model understands the response style and continues it appropriately. This approach is useful for storytelling, generating consistent responses, or maintaining brand voice in AI-generated content.
Principle 2: Give the Model Time to Think
This is a funny one. When I learned this, I literally thought: "Seriously?" Believe or not, models need time to think, just like anyone.
If a model is making reasoning errors by rushing to an incorrect conclusion, reframe the query to request a chain of reasoning before the model provides its final answer.
This happens with more frequency if you are using models before the o1 version. The new version does this by itself and OpenAI has done a great job on this.
1. Specify Step-by-Step Processing
Example:
Perform the following actions:
- Rewrite the given paragraph to make it clearer and more engaging.
- Summarize the improved version in one sentence.
- Identify the overall tone of the paragraph (e.g., informative, persuasive, casual).
- Return a JSON object with 'improved_paragraph', 'summary', and 'tone'.
Paragraph:
"The new fitness tracker has a lot of features. It can track your steps, heart rate, and even sleep. It's also waterproof and connects to your phone."
Expected output:
{
"improved_paragraph": "The latest fitness tracker is packed with features, from step and heart rate tracking to sleep monitoring. It's waterproof and syncs effortlessly with your phone for seamless health insights.",
"summary": "A feature-rich fitness tracker that monitors health and syncs with your phone.",
"tone": "informative"
}
2. Encourage Logical Deduction
Ask the model to work out the answer itself before evaluating someone else's response.
Example:
Determine if the student's solution is correct.
Question: "Land costs 250 per square foot, and maintenance costs 10 per square foot. What is the total cost in the first year for x square feet?"
Student's solution: "Total cost = 100x + 250x + 100,000 + 100x = 450x + 100,000"
First, solve the problem yourself before evaluating the student's answer.
This method ensures that the AI doesn’t assume correctness but actively solves the problem before making a judgment.
Conclusion
Effective prompting is a skill that enhances how you interact with AI models. By writing clear and structured instructions and giving the model time to process information, you can significantly improve response quality. Start practicing these principles today to unlock the full potential of AI in your workflows!