Anatomy of a Good Prompt

AI Prompt Design
Pickaxe Project
Published in
5 min readFeb 23, 2023

Writing a good prompt is easy, but not immediately intuitive. Here are five tips to internalize for writing better GPT-3 prompts. (Created via Pickaxe)

What is Prompt Engineering?

Prompt engineering is the art of writing instructions for a generative AI model (like GPT-3, ChatGPT, Google Flan, etc.) that produce the results you intended. The same instruction written two different ways can get very different results. Writing a good prompt comes down to structure, examples, and being specific.

1. Separate Instruction & Context

There is a difference between the instruction “do x” and the context “do it using Y”. Don’t combine the two. When writing a prompt, you should separate instruction (what you’re telling it do) and context (the details & circumstances). Try writing the instruction as a sentence and the context as data.

A First-time user might write a prompt like:

✅ A prompt engineer would write:

Separating the instruction and the context makes the prompt much cleaner. Additionally, it’s easier to change later. If you want to add more context such as neighborhood or renovation history, it’s very easy to add them with muddying your prompt.

2. Specify details you want

If you want something specific, tell the machine. Otherwise it won’t know. This may seem obvious, but somehow it’s not.

Let’s say you want a tweet about the superbowl. Think about what type of Tweet you want. Call out the recognizable traits of what ‘a tweet’ means in your head. Because the machine’s idea of a tweet may be much broader than yours.

First-time user:

✅ Prompt Engineer:

3. Use examples to guide style

Not getting an output you like? Feed the machine samples of what you like. You can guide the output by feeding it examples. The machine is smart. It will pick up on patterns.

First-time user:

✅ Prompt Engineer:

Don’t forget, you can further improve the above prompt by using techniques around structure/context and specificity. Keep improving your prompt until you get results you like.

4. Use examples to guide formatting

If you want your output particularly formatted, use examples to teach the machine.

First-time user:

✅ Prompt engineer:

5. Use ALL CAPS to designate labels

Sometimes you want to label parts of your prompt. For example, you might want to label DESIRED FORMAT, or EXAMPLES, or CATEGORIES. It’s helpful to mark these in a special way so the machine understands you’re labeling something. Using all caps work, so do other unique markers liek ##double hashtags## or //code commenting//.

First-time user:

✅ Prompt Engineer

6. (BONUS) The last few words matter!

Remember, LLMs function as auto-complete engines. While it’s important to separate instruction and context, the last few words really influence what comes next. Never forget this!

If you’ve written a good prompt but still aren’t getting what you want, consider stacking the deck. Pack some extra explicit instruction at the very end.

Pretty good:

✅ A little more caustic:

Giving the model a little reminder at the end

Those final three words in the capitalized direction make a big difference.

And, remember LLMs function like auto-complete! They’re trying to guess the next word. You can lead it into certain answers.

Even your own mental auto-complete model knows where a letter that starts “Unfortunately,” is headed…

Experiment! The model holds mysteries…

Above all, test your prompts! Test them over and over until you’re getting results you like.

Try stuff out. We are dealing with LLMs, Large Language Models. You are communicating with these machines through natural language, not code. Just like humans, there is a variety of methods for communicating clearly. Some people are very structured and dry, others are very expressive and figurative. You might find you like using examples. There are no absolute rules like programming.

A great way to experiment is with prompt frames — places where you create a prompt, punch holes in it, and run the same prompt with slightly different inputs. Pickaxe prompt builder lets you create prompt frames and play with them endless.

Building a “prompt frame” in Pickaxe
Easily testing different inputs in your prompt on Pickaxe

The only advice left is to start writing and testing your prompts. Go forth, young prompt engineer!

--

--