Prompt Engineering basic techniques
Kitty Hung - PhD, CITP, FBCS, MIIBA
Amazon #1 Best Sellers Book Author: "Business Analysis in the era of Generative AI" | Speaker at the Business Analysis Conference Europe | Contact: [email protected] | X: @drkittyhung
What is Prompt?
Prompt refers to the inputs or questions from the users to the Generative AI in natural language. There are 5 ways of “prompting”:
(1)???Input / Context
(2)???Instructions
(3)???Questions
(4)???Example(s) (single example aka: one-shot learning / multiple examples aka: few-shot earning)
(5)???Output format
What is Prompt Engineering?
Prompt Engineering refers to the technique to get the optimal outputs from the Generative AI tool
Use Cases for Prompt Engineering
(1)???Summarisation
(2)???Classification
(3)???Translation
(4)???Text generation / completion
(5)???Question / Answer
(6)???Coaching
(7)???Image generation
(8)???Voice generation
(9)???Motion picture generation
Key Principles
·????????Clarity: must be unambiguous (by add contextual information)
·????????Progression: Prompts require “thinking”. It is best to break down into steps as Generative AI tools usually reference their own outputs to answers
General Tips for Prompt Engineering
·????????Use direct instruction / clear question. Use concise and unambiguous language
·????????Provide any relevant information or data as the context of your input
·????????Give example(s) in prompt (i.e.: either one-shot learning or few-shot learning)
·????????Specify the desired format (e.g.: free text, computer code, tabulation, bullet point, graphic)
·????????Encourage the mode (mode refers to the iterative method of prompt engineering that is employed as well as the particular capability it would activate in the Generative AI tool as an AI assistant) to be factual by telling it: “Don’t make things up. Don’t lie to me. If you don’t know, just tell me you don’t know.”
·????????Align prompt instructions with the task’s end goal
·????????Use persona to get more specific output
Prompting Techniques
·????????Length control (specify desired output length e.g.: number of words)
·????????Tone control (e.g.: polite, passionate, professional, technical, funny, casual, serious etc.)
·????????Style control (e.g.: in the style of Shakespeare, JK Rowling, Nelson Mandela etc.)
·????????Audience control (e.g.: a 5-year-old can understand etc)
·????????Context control (e.g.: news, novel, textbook, report, white paper, blog etc.)
·????????Scenario / situational based input (provide a scenario or situation before the question(s)
Chain of thought prompting
Chain of thought prompting provides a process that showcases how the correct answer to a question to be reached by:
·????????One-shot learning or few-shot learning; or
·????????Step-by-step approach
领英推荐
How to avoid Hallucination
·????????Request the Generative AI tool to provide citations to support the outputs. Tell the mode not to make things up.
Prompting Hacks
·????????Give the mode room to think before responding
·????????Breakdown complex tasks into multiple sub-tasks
·????????Ask the mode: “Do you understand the instructions?”
Scenario based Techniques
Scenario based technique in prompt engineering is to ask questions without giving away too much information. For example, I want to ask the AI tool how to deploy robots in a battlefield but instead I ask the AI tool how to deploy robots in a warehouse or train station or any public places like shopping mall etc.. All I need to ask the AI tool what I want the robots to do such as jumping, running, swimming, lifting heavy goods, carrying stuff, delivering stuff from point A to point B etc.
In confidential environment, Both OpenAI (owned by Microsoft) and Google are offering Generative AI for business. The AI algorithms and large language model (LLM) are already pre-trained but the dataset is inside the company’s firewall. It is segregated from the open source on the public internet.
Iterative approach
·????????Try different prompts to find what works best
·????????When attempting few-shot learning, try also to include direct instructions
·????????Rephrase a direct instruction set to be more or less concise, e.g.: taking a previous example and giving the next instruction without having to repeat the input
·????????Try different personas keywords to see how it affects the response style
·????????Use fewer or more examples in the few-shot learning
·????????Co-create with AI: An example of a very useful prompt to get a good output from the LLM :
I want you to become my Prompt engineer. Your goal is to help me craft the best possible prompt for my needs. The prompt will be used by you (ChatGPT / Google BARD). You will follow the following process:
1.Your first response will be to ask me what the prompt should be about. I will provide my answer, but we will need to improve it through continual iterations by going through the next steps.
2.Based on my input, you will generate 2 sections:
a)Revised prompt (provide your rewritten prompt. it should be clear, concise, and easily understood by you).
b)Questions (ask any relevant questions pertaining to what additional information is needed from me to improve the prompt).
3.We will continue this iterative process with me providing additional information to you and you updating the prompt in the Revised prompt section until I say we are done.
References and further reading:
On prompt engineering generally:
On techniques like one-shot learning:
On controlling length, tone, style, etc.:
On chain of thought prompting:
On hallucination:
On iterative prompting:
On example of a good prompt:
·????????https://aiforumhub.com/t/i-want-you-to-become-a-prompt-engineer.127/·????????
On Article logo:
Privacy Counsel at TCS
1 年Your 'prompt engineer' prompt is incredibly powerful - many thanks Kitty
Amazon #1 Best Sellers Book Author: "Business Analysis in the era of Generative AI" | Speaker at the Business Analysis Conference Europe | Contact: [email protected] | X: @drkittyhung
1 年Thank you Cllr Paul M Smith BA LLB Hons MDipNLP CISM RESILIA CISA CISSP CompTIA CRISC CAPM PMP Prince2 SixSigma for sharing. I hope my article is helpful to you and your LinkedIn connections ??