A Language Model (LM), like GPT-3, is a complex system, and the quality of the results you get from them depends on how you write your prompts. Prompt writing, or “prompt engineering” to some, is the process of designing prompts that will produce the best possible results.
Designing language model prompts can be difficult, but there is a method that can help make the process easier.
In my experiments with GPT-3, I’ve found that the best prompt designs contain three important components: perspective, context, and action. Each of these parts plays an important role in getting the best output.
This prompt writing strategy makes the LM more of an exploratory tool than one that simply reproduces. It’s a way of writing “zero-shot” prompts, which can be seen as the opposite of the “k-shot” prompts where specific examples of acceptable outputs are provided in the prompt.
Perspective refers to the point of view from which your prompt is written. For example, if you’re writing a prompt about a character in a book, you could write it from the character’s point of view (first-person perspective), or an omniscient narrator’s point of view (third-person perspective). The choice of perspective can greatly impact the quality of the results you get from your LM.
Context refers to the situation in which your prompt is used. For example, if you’re writing a dialogue between two characters, it’s important to consider who they are and their relationship. That way, you can ensure that the conversation sounds natural and believable.
The action represents what we want our LM to do. In other words, it’s the goal of our prompt. For example, if we want our LM to generate a character description, we need to include some actionable elements in our prompt (e.g., “Describe the character’s appearance”).
Let’s take a closer look.
What is Perspective in a Prompt?
Perspective is the angle or point of view from which something is seen. In the context of a prompt, perspective represents the angle or point of view from which the prompt evaluates your request. When creating a prompt, it is important to consider the perspective from which the language model will view the prompt. The perspective can be thought of as the “lens” through which the LM will interpret the prompt. By considering the perspective, we can ensure that the LM understands the prompt in the way we intend.
In story writing, if you were designing a prompt for a language model to generate a story about a character’s day, the perspective could be from the character’s first-person point of view. This would mean that the prompt would need to include information about what the character sees, hears, and thinks throughout the day.
Another example could be if you designed a prompt for a language model to generate an advertisement for a product. The perspective could be from a “Marketing Expert” or “Advertising Specialist” so the LM considers relevant information, like what the product does and how it benefits consumers.
examples of changes in perspective
You are a first grader. Write one sentence about the sky:
The sky is blue and it has clouds in it.
You are a physics professor. Write one sentence about the sky:
The sky appears blue because of Rayleigh scattering.
You are a meteorologist. Write one sentence about the sky:
The sky looks like it might rain.
What is Context in a Prompt?
Viewing Context as separate from Perspective allows us to see it more clearly as providing a set of cues or constraints the LM must follow. When we construe Context too narrowly, our response options may be unduly limited; when we construe it too broadly, our responses may be off-target or miss the point entirely.
When designing prompts for a language model, Context represents the situation in which the prompt is used. This is different from Perspective, which represents the point of view from which the prompt is given.
For example, if you were designing a prompt for a chatbot, the Context would be the conversation that led up to the bot’s response. At the same time, the Perspective would be the bot’s disposition or personality used when interacting with its users.
Now let’s look at how Context affects the output of a language model. The most important thing to remember about Context is that it provides context for the LM’s responses. Without context, the LM would not know how to interpret or respond to a given prompt. For example, if you said “I’m hungry” to an LM without providing context, it wouldn’t know whether you’re trying to start a conversation about food or just making an observation. However, if you provide context by saying something like “I’m hungry, and I was wondering if you know any good restaurants near me.” It becomes clear that you’re looking for specific information and The LM can respond accordingly.
Context is important because it helps determine what information is relevant and what isn’t. In other words, it allows us to filter out noise to focus on getting useful results from our language models.
examples of changes in context
You are a first grader. It's night time. Write one sentence about the sky:
The sky is very dark.
You are a physics professor. It's night time. Write one sentence about the sky:
The night sky is full of stars.
You are a meteorologist. It's night time. Write one sentence about the sky:
The moon is out and there are a few stars visible.
What is Action in a Prompt?
The action is the part of the prompt that specifies what the model should do with the information it has been given. Action is different from perspective and context in that it represents the specific task or goal you want the language model to perform.
Verb choice is important. If you are translating, you will want to specify an appropriate action, such as “translate the sentence…” If you are writing a prompt for question-answering, your action might be “answer the question… “
If you are writing a blog post, the verb “write” may be sufficient for getting some text that’s on topic. However, changing that to “explain” will improve the output by including additional reasoning.
examples of changes in action
You are a first grader. It's night time. Explain:
It’s nighttime. The sun has gone down and it’s dark outside.
You are a physics professor. It's night time. Explain:
The night sky is full of stars. Each star is a huge ball of gas, held together by its own gravity. The gravity of a star keeps all the gas in the star from flying off into space.
You are a meteorologist. It's night time. Explain:
The moon is out and it’s a clear night. The stars are shining brightly.
The Order of Perspective-Context-Action Prompt Design
Perspective-Context-Action Prompt Design starts with the broadest instruction, Perspective, and ends with the most narrow, Action.
The order of the Perspective-Context-Action components is important because it allows the LM to focus on a smaller set of possibilities, leading to improved results.
This order is useful from a human perspective, as it’s easier to think broadly than specifically.
examples of changes in ordering
Write one sentence about the sky. It's night time. You are a first grader:
The sky is dark and full of stars.
Write one sentence about the sky. It's night time. You are a physics professor:
The night sky is full of stars.
Write one sentence about the sky. It's night time. You are a meteorologist:
The sky is full of stars.
When to use Perspective-Context-Action Prompt Design
When you want to explore and develop ideas from scratch, Perspective-Context-Action Prompt Design is the best method. This is because it allows you to interact with the language model in a way that helps you generate new ideas, rather than simply replicating existing ones.
An analogy could be an author, zero-shot, and a printing press, k-shot. The author uses zero-shot prompts to explore and develop ideas from zero-to-one. Meanwhile, the printing press uses k-shot prompts to replicate output with a known value from one-to-many times.
If you are looking to generate new ideas from an LM, or want your LM to produce outputs tailored to a specific audience, then you should try using the perspective-context-action method for prompt writing.