Have you ever felt unhappy with the results that ChatGPT or one of image generators provided you with? If you’re using artificial intelligence for content creation, marketing, or even software developing, mastering prompt engineering will help you get the best results. Read on to learn the best practices for writing effective prompts.
What is Prompt Engineering?
When you ask the model a question, you are giving it a kind of instruction, which is called a prompt. Effective AI prompts help you get better responses, while unclear and poor-structured inputs may not bring what you want. The art and science of crafting effective prompts that generate desired outcomes is known as prompt engineering.
Essentially, you can write better prompts by using specific words or phrases and a good structure, providing examples, and setting a context to guide the AI towards the right answer.
Artificial intelligence is still far from perfect, as the generated output is usually as good as the data the model has been trained on. However, prompt optimization can still improve the quality a lot.
16 Effective Ways to Write Better AI Prompts
The following optimization techniques will guide you in crafting prompts for traditional and generative AI tools.
Tip #1: Be Specific
Detailed and longer prompts usually generate more helpful responses because they guide AI tools in the right direction. Depending on the situation, you can add more details by setting language, region, timing, the number of words needed, format, and other parameters. Remember to use natural language and avoid ambiguous wording.
Below, you can see how different prompting encourages AI to create different responses.
| Simple Prompt | Specific Prompt |
| Generate an image of a cat. | Generate an image of a white Siamese cat sitting on a windowsill with sunlight streaming through the window, in a photorealistic style. |
Tip #2: Set Context
Setting clear context is also important to optimize your prompts. It is especially important to indicate the intended audience so the model can automatically adjust the tone of voice and writing style. Many systems have pre-built prompt templates for different use cases, developed by professionals.
See another example below.
| General Prompt | Specific Prompt |
Tip #3: Rephrase
Refining prompts by changing a couple of words or phrases can also help you improve the outcome. Many AI tools like ChatGPT use language models and machine learning to analyze your prompt, so even a slight shift in wording can make a difference in the outcome.
Tip #4: Set Format
Make sure to indicate the desired format and structure in your prompts. It can be using a bullet or numbered list, colors, word count, bold/italics, file extension, etc.
| Create an image of a forest. | Create an image of a dense rainforest at sunrise, with mist in the air and vibrant green foliage, sized 1024×1024 pixels. |
Tip #5: Add Examples
To get better results from your prompts, add positive and negative examples. This will help the model better understand your focus and constraints.
Tip #6: Ask Open-end Questions
The power of AI lies in its creativity. Open-ended prompts often encourage the model to explore the topic from multiple angles. This is especially important if you want AI to deliver multiple ideas.
Tip #7: Set the Tone
It is also possible to adjust the tone of voice and writing style. Leverage the power of prompt engineering and set the desired tone for AI to use. A tone can be:
- Conversational vs. Professional
- Informal vs. Informal
- Serius vs. Humorous
- Dry vs. Friendly
Pro Tip: If you want the model to keep your writing style, make sure to submit your own writing samples to train it.
Tip #8: Refine
Effective prompt engineering is often an iterative process. You can start with a basic prompt, see what the model provides, and improve your interactions step by step. Instead of trying to give all constraints in one prompt, you can build on it in several iterations until you get the desired output.
For example, you can improve responses to your prompts using the following instructions:
- “Rewrite this paragraph to make it more concise while keeping the formal tone.”
- “Rewrite this paragraph to be more persuasive by emphasizing benefits over features.”
Tip #9: Switch Models
You can get different results from your prompts by using different AI models. Let’s take a look at some major ones and their use cases.
- General purpose: Open AI’s GPT series (e.g., GPT-4), Google’s Bard, Anthropic’s Claude, and Meta’s LLaMA.
- Image generation: DALL·E, Stable Diffusion, and MidJourney.
- Speech-to-text/voice: Whisper and Google’s Speech-to-Text API.
- Code generation: Codex (used in GitHub Copilot) and Google’s AlphaCode.
There is also a number of advanced AI models, such as Hugging Face Transformers with a focus on NLP, and more.
Tip #10: Ask for Feedback
Ask the model to deliver feedback to improve your output. If you are unhappy or unsure about the response, ask the tool to review it and suggest improvements. For example, you might ask:
- “How can this response be improved?”
- “What’s missing in this explanation?”
- “Can you make this slogan more engaging by using alliteration?”
Tip #11: Role Play
One of more advanced techniques to enhance interactions with AI is role playing. Ask the tool to assume a specific role and match the specified expertise level and perspective. This will help you get more focused and authoritative answers.
- “Act as a Python coding tutor and explain how to create a simple calculator program.”
Tip #12: Ask for Reasoning
When working on complex problems, ask the model to explain its reasoning. For example, walking you step-by-step through the process so you can find potential flaws in the tool’s logic.
Tip #13: Adjust Parameters
Some platforms allow users to adjust settings to improve their interaction. Here are some major parameters:
- Temperature controls randomness. Set it low for more predictable or higher for more creative outcomes.
- Higher Top-p will diversify the vocabulary in the response.
- Max Tokens limit response length. Increase the number to get a longer answer.
- Frequency Penalty reduces repetition of common words.
- Presence Penalty encourages a wider vocabulary.
- Stop Sequences define “stop” words that end the response.
- Number of Completions allows you to create multiple outputs at once.
- Seed allow you to recreate the same response for consistency.
- Model Selection enables a particular model.
• Good Prompt (with hyperparameter guidance): “Write a creative and imaginative story about space exploration. Use a temperature setting of 0.8 to encourage more diverse ideas while maintaining coherence.”
Tip #14: Check Grammar
Write your prompts using proper grammar, spelling, and punctuation. Avoid using uncommon abbreviations or jargon words. This will help get more relevant results from your AI prompts.
Tip #15: Ask for Different Perspectives
If you are working on a complex topic, it might be important to consider several perspectives in your analysis. Tell the AI to compare common opinions and their pros and cons. For example, you can consider a certain problem from the point of view of different players:
• “Explain the benefits of remote work from three perspectives: an employee, an employer, and an environmentalist.”
Tip #16: Use Prompt Generators
To enhance optimization process, you can use special prompt AI systems that follow prompt engineering best practices:
- PromptPerfect allows you to compare and optimize prompts for different models. The interface is intuitive and easy to navigate, with no coding experience required.
- For more advanced prompts, you could explore PromptBase, a marketplace for prompts for various models.
How to Improve Your AI Prompts: Do’s & Don’ts
The following checklist of do’s and don’ts will enhance your AI interactions.
Limitations
The full potential of AI is till not reached, so it is crucial to fact-check the output before you apply it in real life. Here are the three most important things to look at:
- Accuracy. Artificial intelligence might provide wrong facts, such as dates, prices, etc. Before taking any important decisions, make sure to check the information the tool has given you.
- Hallucinations. Even worse, the model might completely make things up. It can be a book that has never been written or a person who never existed. Again, fact-check.
- Biases. Depending on the data used in their training, AI solutions might reflect racial or gender bias in their responses. Write prompts with potential edges in mind.
How to Write Effective Prompts for AI
Optimizing your prompts is key to getting the best possible results. Write specific, clear, and iterative prompts to encourage the model to give the best response it can. Remember, trial and error is part of the process—don’t be afraid to experiment. So, get out there, test these tips, and see what works best for your needs. And hey, if you’ve got any other tips and tricks, drop them in the comments—I’d love to hear them!
Frequently Asked Questions (FAQ)
1. What is prompt engineering, and why is it important?
Prompt engineering is the art and science of crafting effective prompts (inputs). It helps the AI models generate the best possible responses and ensures its higher quality.
2. How can I make my prompts more effective?
To improve your prompts, be specific, provide context, set desired format and style, include examples, and refine your queries iteratively. Detailed prompts help you get better outputs from AI.
3. What are common mistakes to avoid when writing prompts?
Common mistakes include using vague or ambiguous language, failing to provide sufficient context, not specifying the format, and expecting perfect responses without refinement. Also, avoid overly complex or unclear instructions that may confuse the model.
4. How do parameters like temperature affect responses?
There are various AI parameters that you can adjust directly in your prompt or in the system’s settings:
- Temperature controls randomness; lower values make responses more predictable, while higher values increase creativity.
- Top-p (nucleus sampling) filters the vocabulary for diverse but relevant responses.
- Max tokens set the response length limit.
- Frequency and presence penalties help control repetition and encourage varied vocabulary.
5. Can AI always generate 100% accurate responses?
No, the model’s responses are only as good as the training data they were built on. They can sometimes produce incorrect facts, hallucinate (make things up), or reflect biases. Never blindly rely on such systems without fact-checking their outcome.
6. What are some advanced prompt engineering techniques?
Advanced techniques to unlock AI potential include role-playing (asking the model to assume a specific persona), chain-of-thought prompting (breaking down reasoning step-by-step), and instructing the model to generate multiple responses for comparison.
7. Are there any tools to help with prompt optimization?
Yes, tools like PromptPerfect allow you to compare and optimize prompts for different models, while PromptBase offers a marketplace for pre-built prompts designed for various applications.
8. How can I train the model to match my writing style?
You can provide samples of your writing and instruct the tool to analyze the tone, style, and structure. This helps it mimic your unique writing voice more accurately.
9. What should I do if responses don’t meet my expectations?
Try refining your prompt, adding more details, rephrasing the question, or adjusting parameters.
