AI From Zero - Lesson 5-b: Advanced Prompt Engineering Techniques.
Crafting better prompts for better outputs with Generative AI
"The expert in anything was once a beginner. The path to mastery is paved with practice." - Unknown
In the previous post, we got started with prompting - the language of Generative AI chatbots. This addendum dives into more advanced ways to "talk" to AI, helping you get even more precise and powerful results. These techniques build on the basics of writing clear and specific prompts.
Role-Playing: Getting AI to Act a Part
One powerful technique is to assign the AI a specific role or persona. This changes the tone, style, and even the type of information the AI provides, making its output much more suitable for your needs.
How it works: Start your prompt by telling the AI who it should pretend to be.
Example: "Act as a seasoned travel agent. Plan a 3-day itinerary for a family with two young children visiting Kilifi on the Kenyan coast, focusing on historical sites and child-friendly activities."
Without the role, the AI might give a generic itinerary. With the role, it adopts the language and priorities of a travel agent.
Chain-of-Thought Prompting: Guiding AI's Reasoning
Sometimes, you don't just want the answer; you want to see how the AI got there. Chain-of-thought prompting encourages the AI to break down complex problems into smaller, logical steps before arriving at a final answer. This can significantly improve accuracy for complex tasks and helps you understand the AI's reasoning.
How it works: Include phrases like "Think step-by-step," "Explain your reasoning," or "Walk me through it."
Example: "Solve this math problem step-by-step: (15 + 7) * 2 - 10. Explain each calculation you make."
This forces the AI to show its work, making it less likely to make a simple arithmetic error and allowing you to verify its process.
Few-Shot Prompting: Learning from Examples
If you want the AI to follow a very specific style or format, or you're dealing with a nuanced task, providing a few examples within your prompt can be incredibly effective. This is called few-shot prompting. The "few shots" are the examples you give.
How it works: Provide 2-3 examples of the input and desired output directly in your prompt, then give the AI a new input for it to complete in the same style.
Example:
"Here are some examples of product descriptions:
Product: 'Smart Kettle'
Description: 'Boil water with your voice! This Wi-Fi enabled kettle connects to your smart home for convenient, precise temperature control.'
Product: 'Noise-Cancelling Headphones'
Description: 'Immerse yourself in pure sound. These headphones block out distractions, delivering crystal-clear audio and ultimate comfort.'
Now, write a description for: Product: 'Portable Solar Charger'"
The AI will then try to generate a description for the solar charger in a similar style and length to your examples.
Defining Constraints: Setting Boundaries for AI
Sometimes you need the AI to stick to very specific rules. Constraints are limits or requirements you put on the AI's response. This helps prevent unwanted content, ensure specific formatting, or keep the output concise.
How it works: Use phrases like "Must be," "Do not include," "Limit to," "Format as."
Example: "Write a 2-sentence marketing slogan for a new coffee shop. Do not use the words 'brew' or 'bean'. Emphasize freshness."
This forces the AI to be creative within the given boundaries, ensuring the output meets precise criteria.
By combining these advanced techniques with your basic prompt writing skills, you'll be able to unlock much more powerful and tailored results from AI tools. Practice is key to mastering them!
Practice Exercise
Try these specific prompts with your favorite AI chatbot:
Role-Playing: Ask an AI: "Act as a grumpy old pirate chef. Give me a recipe for a simple sea stew." See how its language and ingredient suggestions change.
Chain-of-Thought: Ask an AI: "Solve this math problem step-by-step: (15 + 7) * 2 - 10. Explain each step." Verify each step of its calculation.
Constraints: Ask an AI: "Write a 2-sentence marketing slogan for a new ethical clothing brand. Do not use the words 'fashion' or 'style'." Observe if it adheres to the negative constraint.
Fun Fact
Some advanced AI models can follow multi-step instructions so well that they can actually "reason" through problems by showing their intermediate thought processes, just like a human! This ability is a major breakthrough in making AI more reliable and explainable for complex tasks.
Learning Reinforcement Questions
What is the main goal of "role-playing" in prompt engineering?
To make the AI laugh.
To get the AI to adopt a specific persona or style.
To help the AI solve math problems.
To make the AI forget information.
Explain "chain-of-thought prompting" in your own words.
Why are "constraints" useful when writing prompts?
True or False: Few-shot prompting means you give the AI only a few words to start its response.
Which advanced prompting technique would you use if you wanted the AI to explain its reasoning process?
Once you've given it a shot, you can find the <guidelines to answering these questions here> to check your understanding.
Next up
In our next lesson, Lesson 6: Smart vs. Just Fast: Understanding AI's Capabilities, we will differentiate between AI speed versus correctness and emphasize on important considerations such as hallucinations and quality of AI outputs. Stay curious!
Licensing, Attribution and Commercial use
© 2025 Nacha – AI Activation Hub, a division of Asset Thinking Ltd. All rights reserved.
For commercial licensing, partnerships, adaptations, integrations, usage within an organization or consulting inquiries, please contact the author via email: zack@nacha.life
A great lesson that was.
Wake up to the crisp aroma of coffee crafted at the peak of its flavor. Where each cup is made moments before it finds your hands—because you deserve nothing less than *fresh*.
Awesomeness