Sometimes you may feel like you can’t get an LLM chatbot to do quite what you want. Sometimes, this can be resolved by improving your prompt. Let’s take a look at prompt engineering, the art of constructing an effective prompt!
Prompts and prompt engineering
A prompt is simply the textual input you give generative AI models (like LLMs and image generation models), instructing them to perform your desired task. A simple example – whatever you type into ChatGPT is a prompt!
Prompt engineering is the art of designing prompts to be more relevant, effective, and imposing some manner of constraints. It’s generally done all with natural language, and you can pick and choose what methods you’d like to use, so don’t be intimidated!
Some prompt engineering techniques
Here are some commonly-used prompt engineering techniques
One/Few-shot prompting
In this technique, “shots” refers to examples you’re providing in your prompt. A regular prompt you would use, like “Make a sentence with the word ‘weta’ in it”, is an example of a zero-shot prompt, since you’re not providing any examples. (PS: Google it if you dare)
An example of a one-shot prompt would be:
“A weta is an insect endemic to New Zealand. An example of a sentence using the word ‘weta’ is:
Mark was terrified of the weta crawling on his bedroom floor
Create a sentence using the word ‘weta’ in it”
As for few-shot prompting, just add a few more examples.
Role prompting
In this technique, you assign the LLM a particular role or persona. This encourages the model to embody a similar expertise level, tone, and perspective as the role you assigned. An example:
“You are a technical support specialist with expertise in handling network issues. You are also great at explaining solutions to non-technical teammates.
I’m facing this issue, please help me resolve it: … “
Chain of thought
In this technique, you encourage the model to work through its solution step-by-step. This encourages the model to generate its ‘thinking process’, which can be useful as added context for complex questions. An example:
“Find the solutions to this equation, and explain your reasoning step-by-step:
x^2 + 2x + 1 = 0”