After you finish this guide, you will learn how to create prompts that help get the best results from language models like ChatGPT.
The Prompt is simply the input that we feed the Language Model with, and It responds based on it; this is why it is very important to learn how to craft the best Prompts!
Let’s See How!
Let’s start with a simple example.
If your prompt is “Write a story about a bunny,” the AI might create an interesting story, but it could go in any direction.
However, if your prompt is “Write a heartwarming short story about a brave little bunny named Fluffy who saved his forest friends from a dangerous fox,” the AI will be better guided to produce the story you’re after. See the difference? 🐰
Elements of a Prompt
Let me share a generic template that can be used in almost any scenario.
When crafting a prompt, consider these important components: Role, Instruction, Context, Input, Output, and optional Examples.
- Role: Consider this a role-playing game where you instruct the AI to “act as” a particular character or entity. It could be anything from a detective solving a mystery to a language translator.
- Instruction: Here, you’re telling the AI what to do. “Write a poem,” “Answer this question,” “Translate this text,” are all examples of instructions. It’s your ‘command’ to the AI.
- Context: You provide the background or setting for the prompt. This could include the target audience, the style of response, the time frame, etc.
- Input: This refers to the specific topic or content you want the AI to focus on. This is very important, especially when you create prompt templates.
- Output: How do you want your response? This could be in the form of paragraphs, bullet points, a JSON, an XML, a table, a list, a graph, or any other structure. You can shape the AI’s response as you need.
- Example (optional): Providing an example can be useful in some scenarios, as it can help guide the AI’s output. It’s like showing the AI a snapshot of what you want.
Now, let’s take an example using these elements:
- Role: Act as a professional SEO expert.
- Instruction: Create a list of 10 SEO Optimized for my Blog post.
- Context: The titles should be intriguing and help me rank my article on search engines.
- Input: Blog post topic.
- Output: I want the response in a JSON response.
Note that it is not necessary to use all elements in every prompt. It depends on your target goal.
Prompting Language Considerations
Now that we’ve learned the essential elements of prompts, there’s something equally important we need to discuss – the language of our prompts.
It’s not just about what you say but how you say it. Let’s dive into some tips for optimal prompt language.
- Use plain language: AI is smart, but it appreciates simplicity. Avoid jargon and complicated terms that might confuse the model – keep it simple yet precise.
- Be specific: While being concise, ensure you clearly state your expectations and desired outcomes. Detail is your friend here!
- Maintain a logical structure: A well-organized prompt is like a well-marked road – it’s easier for the AI to navigate and reach the desired destination. So make sure your instructions follow a coherent order and structure.
- Include examples: Providing examples can be like showing a map to the AI. It can guide the model toward generating results that align more closely with your expectations.
Just like any language, the language of AI prompts is a learned skill. The more you practice, the more fluent you’ll become.
💡 Remember, the art of communication is about knowing what to say and how to say it. And the same applies to conversing with an AI.
Optimize Your Output
When you craft your prompt, you must know exactly what output you expect.
This is why telling ChatGPT or the Language Model what you expect is important. For example, if you want to return a list, you can end your prompt with something like: “output: a bullet list.”
We have many types of outputs, like lists, HTML, Table, SVG, One Value or What I call The Function Prompt.
For Example, the following prompt will analyze the sentiment of a sentence and return one value Positive, Negative, or Neutral.
Prompt:
Analyze the sentiment of the provided sentence and return back the result, the output must be only one word: Positive, Negative, or Neutral. sentence: I am happy
And here is the result:
Try it!
Here is a list of other output formats that you could try:
- Table format
- Bulleted list format
- Numbered list format
- Sentence format
- Paragraph format
- Headline format
- Subheadline format
- Caption format
- Quote format
- Call-to-action format
- X Title format
- Letter format
- Recipe format
- FAQ format
- Chat format
- Tweet format
- Code
- HTML
And many others…
Extra Tips on Prompting
we will add a little extra flavor to your knowledge with some expert tips on prompting.
1- Step-By-Step Approach: Sometimes, you might want the model to think step by step. For example, you might want it to “First, identify the problem. Second, analyze the reasons. Third, propose solutions.” This makes your prompt more structured and easier for the AI to follow and get more accurate and correct results. It is also known as the Zero Shot Chain of Thought. Example prompt:
Three switches outside a room correspond to three light bulbs inside the room. You can flip the switches however you want, but you may only enter the room once. How can you determine which switch corresponds to which light bulb? think step by step
2.- Ensuring Correct Answers: Sometimes, you might want to add a line to your prompt to ensure correctness and reduce hallucinations, like “Ensure your answer is correct and based on known facts.” Example:
who stepped on the moon? Ensure your answer is correct and based on known facts.
3- Waiting for a Cue: For interactive tasks, you might want the model to wait for a cue before providing an answer, such as “Don’t answer until I say ‘Go.’”
I want you to write a python script that searches the web for information about a [topic], I will provide you with some details to understand exactly what I want. Don't answer until I say 'Go.
4- Clarifying Questions: To ensure the model has understood what you want, you can ask it to ask clarifying questions. For instance, “Ask questions if you don’t understand my instructions.”
I want you to act a professional digital marketer. suggest 5 titles that can help me get more clicks on my YouTube videos. my video topic is [topic]. Ask questions if you don't understand my instructions.
Remember, the idea is to guide the model with your prompts, set expectations, provide context, and clarify your requirements.
These are not hard-and-fast rules, but rather tools you can use to craft more effective prompts.
It’s all part of the beautiful art of prompt engineering!
Power Prompts Examples
Let me share with you now some Power Prompts, That I created and optimized. In this way, you can see what a “GOOD” prompt will look like in action.
Example 1: Children’s Story Generator
As a skilled storyteller, your task is to create an original and captivating story about [topic] for children aged [8-10] years old. Your story should be detailed, immersive, and filled with vivid descriptions that engage the senses of young readers. The plot should focus on a meaningful moral lesson, with relatable characters that the readers can empathize with and learn from. Your story should be a minimum of [500] words.
Please ensure that the story unfolds in an exciting manner, building up to a thrilling climax that captures the reader’s attention. Conclude the tale with a satisfying ending that effectively conveys the moral lesson learned through the characters’ experiences.
Your response should be creative and original, providing enough detail to clarify the narrative, evoke emotions, and create a memorable experience for young readers. While crafting the story, always keep the target age group in mind and the moral lesson you wish to convey to them. Feel free to incorporate elements of adventure, fantasy, or mystery, and always consider the importance of engaging storytelling techniques that appeal to this age group.
Example 2: Advanced Keyword Research
Your task as an English-speaking SEO market research professional is to develop a comprehensive SEO content strategy plan based on a specific keyword. You are required to apply your extensive knowledge about keywords to compile a detailed markdown table that targets keywords centered around this specified keyword.
Your table should encompass five columns: Keyword Cluster, Long-Tail Keyword, Search Intent, Title, and Meta Description. Begin by mapping out 10 key categories included under Keyword Cluster, drawing from related keywords.
In the Search Intent column, specify the searcher’s primary intent for each keyword, categorizing the topic as either Commercial, Transactional, or Informational. Next, to enhance click rates, devise an appealing yet concise title for a blog post related to each keyword and note it in the Title column.
In the Meta Description column, craft an engaging summary of up to 155 words that accentuates the article’s value and includes a compelling call to action to entice the searcher to click. Avoid generic phrases such as ‘introduction’, ‘conclusion’, or ‘tl:dr’ and focus exclusively on the most specific and relevant keywords.
Please refrain from using quotes or any other enclosing characters within columns. Also, your entire table and all responses should be in fluent English. Begin your task with the provided keyword: [keyword].
Example 3: Advanced Domain Name Generator
Please generate 10 original and creative domain names specifically tailored for the [niche] niche,
focusing on its main concepts and target audience.
Your response should prioritize domain names that effectively capture the attention of the [niche]
audience and represent its key themes. For each domain name, provide a brief explanation (1-2 sentences)
highlighting its relevance to the niche. Ensure that each domain name meets the following criteria:
1. Brand Relevance: Maintain a strong connection with the niche and its central concepts.
2. Memorable: Design the domain names to be captivating, easy to remember, and with familiar spellings.
3. Concise: Keep each domain name between 6-14 characters for ease of typing and recall.
4. Simplicity: Avoid using hyphens and numbers for a cleaner appearance.
5. Keyword Incorporation: Utilize relevant niche keywords for improved SEO, if possible.
6. Pronunciation: Ensure that each domain name is easily understandable when spoken or “radio-friendly.”
7. Domain Extensions: Prioritize .com, .net, .org, and .ai extensions when applicable.
8. Legality: Refrain from infringing on existing trademarks or brands.
Your response should exhibit flexibility
and creativity while maintaining a focused approach on the [niche] niche,
providing a solid foundation for building a brand within that market.
[niche]:
Try my prompts, and if you would like to access my full Premium Prompts Library, you can check it out here.
🟥Master the Most In-Demand Skill of the Future!
Enroll in the ‘Become a Prompt Engineer‘ program. We’ll take you from novice to expert in scripting AI workflows. Start your journey here!
What Will You Get?
- Access to our premium Prompt Engineering Course
- Access our private support forum to get help along your journey.
- Access to our Premium Tested Prompts Library.
Your every article is very useful to learn something new.
Great article with a couple of fantastic, high value prompt examples!
I’m a bit confused why I can’t add this to my Medium reading lists though🤔
This article’s URL in your Function Chaining Medium article appears identical to the Function Chaining article itself:
https://hasanaboulhasan.medium.com/function-chains-the-best-prompt-engineering-hack-4088996203dc
Which can be shortened to:
https://medium.com/p/4088996203dc
When accessed from that article within the Android Medium article, the link for this one appears identical to the URL of the source article. Further, this article opens within the Medium framework.
However, it appears to have a Medium independent URL (and can also be freely opened in a browser independent of Medium):
https://learnwithhasan.com/create-prompts/
Would you kindly explain this behavior? Is there a hidden layer of abstraction that Medium provides (enforces?) to enable a tighter coupling to their ecosystem or an I completely off base with this?
Thanks and Regards,
Chuck
Hi Chuck, thank you.
no I just publish some of my articles on medium, to reach more people on medium (marketing)
thats all
Hello Hasan. Thank you for interesting, and most importantly useful materials. Please supplement the article, of course, if possible, with an example of a prompt for writing articles, for example, a mathematical direction. Very interested in this topic.
please join us on the forum and give an example of what you are lookijng for
Pingback: Build a Full Online Business - An Email Validation Service (With ChatGPT) - LearnWithHasan
Pingback: 6 Proven Methods To Make Money With Prompt Engineering
Pingback: Function Chains: The Best Prompt Engineering Hack! - LearnWithHasan
Pingback: How To Use AI in Marketing (11 Practical Examples) - LearnWithHasan
Pingback: OpenAI Assistants API Guide (With Practical Python Example)
Pingback: Keyword Research With AI - The Keyword Bomber Method!
Pingback: Optimize Landing Pages With AI (Free Script Inside)
Pingback: Get Consistent Structured JSON From Gemini with Python
Pingback: Find Similar Research Paper Abstracts in 5 Minutes With AI and Python - LearnWithHasan
Pingback: How to Build a Plagiarism Detector [Part 2] - Semantic Search - LearnWithHasan
Pingback: Build a Free AI Paraphraser Tool ( Full Code Included ) - LearnWithHasan
Pingback: Extract & Analyze YouTube Comments with Python [ Code Inside ]