How to Write Better Prompts for AI
A beginner-friendly introduction to how to write better prompts for ai
Photo by Generated by NVIDIA FLUX.1-schnell
Introduction
Getting good results from AI like ChatGPT depends heavily on how you ask your questions. In this guide, youâll learn practical techniques to write prompts that get you better, more useful responses from AI systems.
Prerequisites
Basic familiarity with using AI chatbots like ChatGPT is helpful but not required.
Why Prompts Matter
Think of prompting like giving directions. If you tell someone âgo that way,â they might end up anywhere. But if you say âwalk two blocks north, turn right at the coffee shop,â theyâll get exactly where you want them to go.
AI is similarâthe clearer and more specific your instructions, the better the results.
The Basic Principles
1. Be Specific
Bad Prompt: âTell me about dogsâ
Good Prompt: âExplain the differences between Golden Retrievers and Labrador Retrievers in terms of temperament, size, and care requirementsâ
The second prompt tells the AI exactly what aspects you care about.
2. Provide Context
Bad Prompt: âHow do I fix this?â
Good Prompt: âIâm a beginner learning Python. My code gives an âIndexError: list index out of rangeâ error. How do I fix this type of error?â
Context helps the AI understand your level and situation, leading to more appropriate answers.
3. Specify the Format You Want
Bad Prompt: âWhat should I know about starting a garden?â
Good Prompt: âGive me a step-by-step beginnerâs guide to starting a vegetable garden, with each step as a numbered list itemâ
This tells the AI how to structure the response.
Advanced Prompting Techniques
The Role Technique
Ask the AI to take on a specific role or expertise:
âYou are an experienced piano teacher. Explain to a complete beginner how to read sheet music.â
This focuses the AIâs knowledge on the relevant domain.
The Example Technique
Show the AI what you want by giving examples:
âGenerate three business name ideas similar to these examples: Netflix, Spotify, Pinterest. They should be: catchy, made-up words, and easy to remember.â
The Step-by-Step Technique
Ask the AI to think through problems step-by-step:
âLetâs solve this math problem step by step. First, identify what we know. Then, determine what we need to find. Finally, work through the solution.â
Breaking it down often leads to better reasoning.
đĄ Pro Tip: Combining techniques works wonders! Try âYou are a data scientist. Using the example datasets I provided, explain step-by-step how to identify outliers.â Multi-technique prompts often yield the best results.
Common Mistakes to Avoid
Mistake 1: Being Too Vague
Vague prompts get vague answers. If youâre not satisfied with a response, ask yourself: âCould I follow these instructions myself?â
Mistake 2: Assuming Too Much Context
The AI doesnât remember your previous conversations (in a new chat) or know your personal situation unless you tell it.
Mistake 3: Not Iterating
Your first prompt rarely gives perfect results. Treat it as a conversation:
- Start with a prompt
- See what you get
- Refine and ask follow-up questions
- Repeat until satisfied
Real-World Examples
Example 1: Getting Recipe Help
Initial: âHow do I make pasta?â
Better: âI have spaghetti, tomatoes, garlic, and olive oil. Give me a simple 30-minute recipe with step-by-step instructions.â
Even Better: âIâm cooking for someone with a gluten allergy. Suggest a pasta substitute and give me a recipe using tomatoes, garlic, and olive oil that takes under 30 minutes.â
Example 2: Learning a Concept
Initial: âExplain blockchainâ
Better: âExplain blockchain to someone who understands basic computer concepts but has never heard of cryptocurrencyâ
Even Better: âExplain blockchain using an analogy to something in everyday life, then describe one practical use case that isnât cryptocurrencyâ
Try It Yourself
-
Practice Specificity: Take a vague question you might ask AI and rewrite it three times, each time adding more specific details.
-
Test Different Formats: Ask the same question but request different formats (bullet points, table, step-by-step guide) and see how the responses differ.
-
Role Playing: Try asking the same question with and without the role technique. Compare the responses.
-
Iteration Exercise: Start with a simple prompt, then ask 3 follow-up questions to refine the answer. Notice how each iteration improves the result.
The Prompt Template
Hereâs a template you can use for complex prompts:
[Role/Context]: You are a [expertise]
[Task]: I need you to [specific action]
[Constraints]: Keep it [length/difficulty/style]
[Format]: Present this as [format type]
[Example]: Similar to [example if applicable]
Example using template: âYou are a fitness trainer. I need you to create a 3-day workout plan for a beginner who has 30 minutes per day and no equipment. Keep it simple with clear instructions. Present this as a table with columns for Day, Exercise, Sets/Reps, and Tips.â
Key Takeaways
- Specificity is your best friendâtell the AI exactly what you want
- Provide context about your situation, knowledge level, and constraints
- Specify the format you want (list, table, paragraph, etc.)
- Use techniques like role-playing and examples to guide the AI
- Donât be afraid to iterateârefine your prompts based on what you get back
- Treat it as a conversation, not a one-shot question
Next Steps
Ready to level up your prompt engineering skills?
In Part 2: Advanced Prompt Engineering Techniques, youâll learn:
- Few-shot learning for consistent outputs
- Chain-of-thought prompting for complex reasoning
- Prompt chaining for multi-step tasks
- Advanced prompt patterns professionals use
- How to test and improve prompt reliability
Further Reading
- Prompt Engineering Guide - Comprehensive free guide with latest papers and advanced techniques
- r/PromptEngineering - Community sharing tips, examples, and best practices
- Learn Prompting - Free comprehensive course on prompt engineering
Related Guides
Ready to explore more AI concepts?