# How do you write instructions for the new instruction-following GPT-3 models?

Date: 2022-02-09 · Author: Robert Scales · https://guidetoartificialintelligence.com/en/learn/write-instructions-new-instruction-following-gpt-3/

**Answer:** Write to an instruction-following model the way you would brief a capable assistant: start with the task as a direct request, then say who the result is for, how long it should be and what shape it should take, and put any text to work on after the instruction. With the InstructGPT models now the API default, one clear instruction often replaces a page of examples.

For most of GPT-3's life on the API, getting good results meant building a pattern. You wrote the start of a document, added a few solved examples, and left a gap for the model to fill. That worked because the original GPT-3 was trained only to continue text. Since January 27, the default models on OpenAI's API are the InstructGPT models, which were trained with human feedback to carry out written requests. The habits that served the old models are no longer the only way, and often not the best one.

The shift asks for a different skill. Instead of disguising your task as a document, you state it. The skill now is writing instructions that leave the model as little as possible to guess.

## Five parts of a clear instruction

A strong instruction usually answers five questions. Not every prompt needs all five, but when a result disappoints, one of them is usually missing.

| Part | Question it answers | Example wording |
|---|---|---|
| Task | What should the model do? | "Write a product description..." |
| Audience | Who will read the result? | "...for parents shopping for a first bike..." |
| Length | How much text? | "...in two short sentences..." |
| Format or tone | What should it look and sound like? | "...friendly, no exclamation marks..." |
| Input | What material should it use? | "Product details:" followed by the facts |

Two habits make these parts work together. First, put the instruction before the material, so the model knows what it is looking for as it reads. Second, mark clearly where the material starts, with a label such as "Text:" or a line of symbols, so the model does not mistake your notes for part of the request.

Be concrete wherever you can. "Short" means different things to different readers; "under 50 words" does not. "Simple" is vague; "for a ten-year-old" is not. Say what you want rather than only what you want to avoid: "use plain words" gives the model a target, while "don't be technical" only rules something out.

## Before and after: from pattern to instruction

Here is the old way to get a product description out of GPT-3. The prompt sets up a pattern with two examples and an open slot.

```prompt
Product: Stainless steel water bottle, 750 ml, keeps drinks cold 24 hours
Description: Cold water all day, from the morning commute to the evening run. This 750 ml steel bottle keeps drinks chilled for a full 24 hours.

Product: Wool hiking socks, cushioned sole, sizes S to XL
Description: Soft wool and a cushioned sole make long trails easier on your feet. Available in sizes S to XL.

Product: Kids' balance bike, 12-inch wheels, adjustable seat, ages 2 to 5
Description:
```

This still works, but it takes effort to write, it uses up space, and the model may copy quirks of your examples, such as their length or their opening words. With an instruction-following model, you can ask for the same thing directly:

```prompt
Write a two-sentence product description for parents shopping for a first bike. Keep the tone warm and practical, mention the age range, and don't invent features that aren't listed.

Product details: Kids' balance bike, 12-inch wheels, adjustable seat, ages 2 to 5
```

The second prompt is shorter, and it states things the first one could only hint at: the reader, the tone and a rule against making things up. Rules like that last one are hard to express through examples alone.

OpenAI's own comparisons point the same way. In its announcement, the company reports that the people rating outputs scored InstructGPT's answers well above those of GPT-3, whether or not GPT-3 was given a few-shot prompt. The company describes the training as making abilities GPT-3 already had easier to reach, without depending so much on clever prompt engineering.

> **Try it:** Take a few-shot prompt you already use and rewrite it as one instruction using the five parts above. Run both versions on five new inputs and note which gives answers closer to what you wanted, and where each one goes wrong.

## When are examples still worth adding?

Examples are still worth adding when the output must match a format or style that words describe poorly. A fixed layout for an invoice summary, a set of internal category codes, or the rhythm of your newsletter's headlines are all easier to show than to explain. The GPT-3 paper made this point when it introduced zero-shot, one-shot and few-shot prompting: some tasks are ambiguous without a demonstration, even for a person.

A good approach combines both methods. Lead with the instruction, then add one or two examples that show the exact shape you want. The instruction tells the model what the task is; the examples settle the details. Keep examples varied, so the model learns the pattern rather than copying a single case, and make them look like the real inputs you expect.

Examples also help when you notice the model drifting. If answers come back too long, too formal or in the wrong structure even after you tighten the instruction, one example is often the quickest correction.

Instruction-following is not unique to OpenAI. In a September 2021 paper, Google researchers showed that a large model fine-tuned on dozens of tasks written as instructions, which they named FLAN, got much better at tasks it had never seen when given only an instruction. Models trained this way are built to start from the request. Examples become a tool you reach for when the request alone is not enough, rather than the only way to be understood.

## Sources

- Aligning Language Models to Follow Instructions: https://openai.com/index/instruction-following/
- Language Models are Few-Shot Learners: https://arxiv.org/abs/2005.14165
- Finetuned Language Models Are Zero-Shot Learners: https://arxiv.org/abs/2109.01652
