# Prompt Engineering Best Practices Input - Context - Persona - You are roles... - that what it should do... - Input data - Instructions - Desired output - Goal(s) - Proofread and correct - Spelling and Grammar - Tone adjustment - Text conversion - Translation - ... - Summarize text - For a specific audience - With a word or sentence limit - With a specific focus - Expand text - Analysis / Text classification - Analyze the sentiment ... - Classify the following comment's sentiment as positive, neutral or negative - Determine the topics being discussed - Determine the category of issue being discussed, and assign a confidence percentage to each result - Identify named entities / Text extraction / Keyword extraction - Identify ... - Please extract ... - Extract important keywords ... - Text-to-image generation - Subject - Description - Style (e.g., modern, artistic, wideshot, close-up, impressionist, etc) - Code generation - ... - Examples (optional) - Constraints - Behavior - Avoid misinformation - ... providing reference to credible, and peer-reviewed sources whenever possible - Avoid bias/unfairness - Provide a balanced review... - Considering both the strengths and weaknesses, without favoring any particular genre... - Avoid copyright infringment - Create unique ... - Ensure that all content you generate is original and does not infringe upon any existing copyrights or use copyrighted material - Improve transparency - Detail your reasoning, the underlying principles, ... - Output guidelines - Format - e.g., JSON, Markdown, etc - Length / Verbosity - Structure - Tone - Style - Mood - ... - ... Verbosity control: - In one word - In one sentence - In a paragraph - Briefly explain - Provide a detailed analysis Tone control: - Formal - Casual - Humorous - Fun - Relatable - Independent - Intuitive - As if explaining to a child - Like I'm a 5 year old - For a teenager - Friendly - Like you're talking to a friend - Engaging Role examples: - A subject matter expert (e.g. a historian, scientist, lawyer, doctor) - A writing assistant (e.g. to help brainstorm ideas or edit your work) - A specific character or persona (e.g. a pirate, talk show host, or famous person) - An objective, neutral analyst to summarize information - A creative story teller or worldbuilder - I want you to act as a life coach. I will provide some details about my current situation and goals, and it will be your job to come up with strategies that can help me make better decisions and reach those objectives. This could involve offering advice on various topics, such as creating plans for achieving success or dealing with difficult emotions. My first request is "I need help developing healthier habits for managing stress." General: - Ensure the prompt clearly describes the task - Be as explicit as possible to avoid confusion - Keep prompts concise and to the point - Avoid details that could distract the model - Say what to do, rather than what not to do - Use delimiters to separate instructions from content - Tweak and test different strategies - Avoid repetition - Clean/Adapt the input prompt - e.g., don't repeat any sentence - e.g., less repetitive - Post-process the output to remove duplication/repetition - Limit the likelihood of hallucinations - If you don't know the answer, respond with "?" - Start with zero-shot, then few-shots Failures to avoid: - Considering that the data the model has is up to date - No, there is a cut-off date - Considering that models are unbiased - Considering the models as predictable - Thinking that the models know it all - Thinking that the models are careful about language and cultural nuances - Using vague prompts Reduce latency - Flow of completion - End user to ChatGPT API Latency - Time to process prompt tokens - Model choice impact - Time to generate tokens - Model choice impact - chatgpt API to end user latency - Reduce the number of tokens to generate - Stop sequences: e.g., Recommend X books - Max tokens (API param) - n Parameter (OpenAPI): number of chat completion choices to generate - Stream (OpenAPI): Return tokens as soon as they are available - Reduces the wait time for the first initial tokens - Improves UX For image generation: - Consistency is a challenge - Don't forget you can add - Motion - Emotion - Abstract concepts - Ask ChatGPT to provide help to improve image prompts - Give some bullet points describing how I could change that prompt to make it more emotive. I want the image to resonate with people, and to make them care about ... - Marketing campaign visuals - Help me design image assets for a new product I am launching. The product is a ... I want all the assets to have a consistent theme. They should be simple, stylish, and futuristic - Generate a header image for a social media site that I can use for this campaign - Show the product in use in a ... setting - Give me a background image for a flyer that will be printed out. Leave some space where I can add text at a later date