AI prompt engineering is the process of crafting instructions and context to guide AI systems to generate desired outputs. Well-designed prompts are key to unleashing the potential of large language models like GPT-3. Here are some best practices and examples for writing effective AI prompts.
Use Clear and Unambiguous Language
Be as precise as possible when writing prompts. Avoid vague or abstract concepts that could be interpreted in different ways.
For example:
Write a poem about love
This prompt lacks specifics that the AI can use to write a meaningful poem.
A better prompt would be:
Write a 20 line poem about a teenager's first heartbreak using metaphors related to changing seasons
Provide Enough Context and Details
Give the AI enough background information and details to generate relevant and high-quality outputs.
For example, this prompt lacks context:
Give health advice for long distance runners
An improved prompt with more context:
You are a personal trainer with 10 years of experience working with marathon runners. Provide a 300 word section of a training guide with health advice focused on preventing injuries and maintaining energy levels during long runs. Target audience is beginner adults training for their first marathon.
Use Formatting to Structure Prompts
Apply formatting like markdown headers, bullet points, and code blocks to organize information for the AI.
For example:
# Topic: Dog Adoption
- Breed: Beagle
- Age: 2 years
- Gender: Male
- Write a 300 word section for a dog adoption website persuading potential owners to adopt this dog. Emphasize his energetic and friendly personality.
Guide Tone and Style
Explicitly state the desired tone (professional, casual, fun, etc) and style (conversational, technical, poetic, etc) for the output.
For example:
Rephrase the following research paper abstract to be more conversational and friendly in tone for a general audience blog post summary.
Show Examples
Provide examples of the type of output you want the AI to generate when possible. The AI will analyze the examples to understand the expected format, style, tone, level of detail, etc.
For example:
Q: Write a limerick about programming
Here is an example limerick:
There once was a coder named Kim
Who stayed up quite late programming
She coded all night
'Til morning's first light
But found a solution in the end
Now you write an original 5 line limerick about computer programming.
Use Multiple Inputs
Give the AI multiple related prompts to guide it, rather than trying to cram everything into a single prompt.
For example:
Prompt 1:
You are an English professor comparing two novels for a literary essay. The novels are:
- Novel 1: To Kill a Mockingbird
- Novel 2: The Kite Runner
**Do not generate text yet**
Prompt 2:
Write a thesis statement comparing the themes of innocence and experience found in both novels.
This allows you to provide more background context before having the AI generate text.
Websites with AI Prompt Examples
Here are some useful websites with more AI prompt examples and templates to reference:
- Awesome Prompts – Huge collection of categorized prompts for GPT-3 and DALL-E
- PromptBase – Community submitted prompts with ratings and reviews
- PromptHero – Curated prompts for writing, design, and creativity
- SberPrompt – Tool for generating prompts with custom parameters
These sites provide a great starting point to learn from existing prompts. You can analyze why prompts work well and adapt their structure to your specific needs.
Common Prompt Use Cases
Here are some common use cases for AI prompts and example prompts for each:
Creative Writing
Write a 600 word fantasy adventure story about a quest to find a rare ingredient needed to brew a magical potion. The main character is a witch who can transform into a cat. Use figurative language and describe the scenes and characters in vivid sensory detail.
Research Paper Outlines
# Topic: Benefits of Public Transportation
## Introduction
- Thesis statement: Public transportation offers economic, environmental, and social benefits compared to private vehicles.
## Body Paragraph 1
- Topic sentence: Public transportation reduces traffic congestion and emissions.
- Supporting details: fewer cars on roads, lower greenhouse gas emissions per capita
## Body Paragraph 2
- Topic sentence: Public transportation provides economic opportunity.
- Supporting details: connects people to jobs, reduces transportation costs, stimulates local business activity
**Do not generate text yet**
Email Templates
You are a marketing manager following up with a lead after an initial sales call. Write a friendly and persuasive 300 word email to schedule a product demo. Emphasize how your solution addresses their business needs and include 2-3 open ended questions to continue the conversation.
Social Media Captions
Write a fun, engaging 280 character Twitter caption for the attached image of dogs wearing silly Halloween costumes. Use emojis and hashtag suggestions. Image description: Two golden retriever dogs wearing hot dog and mustard Halloween costumes while sitting on a porch.
Experiment with these use case examples to see prompts tailored for different applications. Tweak them based on your specific needs.
Prompt Engineering Checklist
Use this checklist when writing your own prompts:
- [ ] Clear problem definition
- [ ] Unambiguous instructions
- [ ] Necessary background context
- [ ] Expected length/format defined
- [ ] Desired tone and style stated
- [ ] Structured with formatting
- [ ] Multiple focused prompts if needed
- [ ] Relevant examples provided
Carefully crafted prompts require time and iteration to perfect. But the investment pays off with more useful and aligned AI outputs. Use these prompt engineering best practices and examples to guide your journey.