What is Prompt
Prompt engineering is the practice of using prompts to get the output you want. A prompt is a sequence of text like a sentence or a block of code. The practice of using prompts to elicit output originates with people. Just as you can prompt people with things like a topic for writing an essay, amazingly you can use prompts to elicit an AI model to generate target output based on a task that you have in mind.1
Like a person writing an essay, an AI model takes a prompt and continues writing based on the text in the prompt. The new text that the model outputs is called the completion. An example task might be to write a Python program to add two numbers. If you write out the task as a Python comment like so:
Write a function that adds two numbers and returns the result.
And give it that comment as a prompt to model, it will generate the code as the completion for you like this:
def add(a, b):
return a + b
Placebo or Antidote
How to Compose Prompt
Here are few tips you might want to include in your prompt design.
-
Role Play One of the most common ways to use ChatGPT is by adding prefix “Pretending you’re a …” or “Acting like a …” to the main prompt. For example, if you’re seeking public speaking advice, start your prompt with “Pretend you’re a public speaking coach with years of experience.” Playing a specific role/identity can help AI to enter the scene you want faster and answer questions more accurately.
-
Adding Background When seeking advice from a friend, you may start by providing some background stories so that the other person can fully understand the matter. Artificial intelligence is no exception; if you add some context to your questions by giving more contextual information, you are likely to receive more relevant, customized, and valuable answers. For instance, if you want to get a travel plan, you need to add some background information such as the number of people traveling together, whether they are couples or friends, their preferences, and so on.
-
Providing Details Generic input often results in generic responses from AI models, which may not showcase the true potential of AI. Instead of asking it to write an ordinary tweet about music, let it write an article about the influence of Chinese regional city currency culture on rap music and its relationship with pop music. You can also ask it to write an essay about swimming at the fifth-grade level.
-
Including Restrains Ask your question, but add specific restrictions or requirements. For instance, when making a recipe, add an allergy to coriander; add the identity restriction that the reading target is a college student; explain what the theory of relativity is to a 4-year-old child, or recommend a Sichuan restaurant with a per capita consumption of less than 200 yuan.
-
Defining Precise Goals Provide ChatGPT with accurate goals, i.e., what results you want to get after completing the task, such as translation, expansion, summary, abbreviation, giving creative ideas, etc. By providing ChatGPT with more precise goals, you can get the reply results you want.
-
Using Numbers If you want to generate something, such as the name of your product or the topic of an article posted on social media, don’t just ask to generate one result. You can ask to generate ten results, for example: According to the impact of AI artificial intelligence on our daily work, please Generate ten themed articles. This will give you more new ideas, and you may want to grab parts of each idea, which will greatly speed up your efficiency.
-
Regenerating If you don’t like ChatGPT’s response, just click “Regenerate” at the bottom of the conversation window. You can still view previous answers to the same question by clicking the arrow to the left of the OpenAI green logo.
-
Providing Feedback for Learning The most exciting thing about ChatGPT is its self-correction ability (In-context correction) and learning from feedback (In-context learning). After ChatGPT answers your questions, you can use its dialogue interface to give feedback. You can make it more interesting, scarier, longer, smarter, more convincing, technically leading, etc.
-
Defining Output Format ChatGPT can convert replies into tables, lists, flowcharts, code, etc. (although it doesn’t seem to be able to do diagrams, plots, generate images like DALL-E). If you don’t like long paragraphs of text, you can ask for responses in a format that is more helpful to your use case and preferences, such as a project list.
-
Challenging ChatGPT Try to break ChatGPT’s answers, as it often gives some inexplicable answers. You can challenge it in your professional field without any scruples, in many content biases, homogeneity, centralization, accuracy, dependence. If you want to use ChatGPT better in terms of work, you need to challenge it more and question its replies so that you can have more professional and effective answers. Fortunately, it will get angry yet.
-
Keiji Kanazawa, Ryan Volum, et al. Prompt Engineering: Learn how to use AI models with prompt engineering ↩︎