Short answer
Show GPT-3 the exact format two or three times, in identical worked examples separated by clear delimiters, and end each example with the same end marker. Then leave the template open for one new item, so the only sensible continuation is another filled-in copy that stops at the marker.
Follow-up question Why do examples work better than instructions alone?
GPT-3 does not take orders. It continues text. If you ask it to "summarize these notes as a list of decisions and action items," it may do exactly that, or it may write a chatty paragraph, add a title you didn't want, or carry on into a second set of imaginary notes. Each of those is a plausible continuation of your prompt. A reliable format comes from making your format the only plausible continuation.
Laria Reynolds and Kyle McDonell put this well in a February paper on prompt programming. A model like GPT-3 does not predict how one particular person would finish your prompt. It reflects all the ways anyone might finish it. So a good prompt should not just allow the result you want. It should rule out the results you don't.
Three tools: template, delimiters, end marker
A fixed template. Decide the exact headings, order and punctuation of the output before you write the prompt. If you can't write the empty template on paper, the model can't guess it either.
Delimiters. These are markers that separate one part of the prompt from another, such as a line of three hash marks (###) or a label like NOTES:. They tell the model where the raw input ends and the structured output begins, and where one example ends and the next starts.
An end marker. This is a word or symbol, such as END, placed at the close of every example output. After seeing it two or three times, the model tends to write it too when it finishes. That gives you a clean place to cut the text, or to tell your software to stop generating. Researchers rely on a similar stopping point: in one recent study of GPT-3 prompts, the authors simply let the model write until it produced a line break.
A worked example: meeting notes to a fixed summary
Here is a few-shot prompt that turns scrappy notes into the same three-part summary every time.
Turn each set of meeting notes into a summary with exactly three sections: Decisions, Action items, Open questions. Use "- " bullets. Write "None" if a section is empty.
###
NOTES:
talked budget, ok to spend 2k on new laptops. sam to get quotes by fri. still unsure if we need a 2nd monitor each
SUMMARY:
Decisions:
- Approve up to $2,000 for new laptops.
Action items:
- Sam: collect laptop quotes by Friday.
Open questions:
- Does each person need a second monitor?
END
###
NOTES:
newsletter late again. agreed: move send day to tues. priya writes, lee proofreads
SUMMARY:
Decisions:
- Move the newsletter send day to Tuesday.
Action items:
- Priya: write the newsletter.
- Lee: proofread the newsletter.
Open questions:
- None
END
###
NOTES:
client wants logo bigger?? we said maybe. ana to mock up 2 versions. launch date stays june 1
SUMMARY:Look at what the prompt does. The task line names the three sections. The ### lines and the NOTES: and SUMMARY: labels mark every boundary. Both examples use identical headings, bullets and spacing, and both end with END. One example includes "None," so the model has seen how to handle an empty section. The prompt stops right after SUMMARY:, so the next words can only be the start of a summary in this layout.
A few habits make this sturdier:
- Keep examples consistent down to the punctuation. If one says "Action items:" and another says "Actions -", you have shown two formats.
- Vary the content, not the form. Use examples with different lengths and topics, so the model copies the structure rather than the subject matter.
- Watch the order. A study by Tony Zhao and colleagues found that GPT-3 leans toward answers that appear near the end of a prompt, and that the format, the choice of examples and even their order can swing accuracy widely. Put your most typical example last.
- Check every output. Before you trust the result, confirm that all three headings appear in order and that the text ends with
END. If it doesn't, retry or flag it.
Try it: Take three real sets of notes from your own work. Use two of them, tidied by hand, as examples in the prompt above, and run the third through it five times. Count how many outputs match the template exactly. Then remove the END markers and run it five more times to see what changes.
Why do examples work better than instructions alone?
An instruction describes a format; an example is the format. "Use three sections with bullets" can be read many ways: bold headings or plain, dashes or asterisks, a blank line or none. One worked example answers all of those questions at once.
There is also a deeper reason. GPT-3 has read an enormous amount of text in which a pattern repeats: forms, lists, transcripts, records. When it sees two filled-in copies of a template, continuing with a third copy is exactly the kind of prediction it was trained to make. Reynolds and McDonell argue that examples often work less by teaching a new skill than by pointing the model to a behavior it already has. They also note that examples are especially useful when a task needs a custom format, which is precisely the case here.
Instructions still matter, and examples have their own risks. In the same paper, a carefully worded prompt with no examples beat a ten-example prompt on a French-to-English translation test, and a single example actually hurt results because the model treated its content as part of the story. The practical lesson is to combine the two: a short instruction that names the task, plus a few varied examples that show the exact shape, separated so clearly that the model can't mistake them for one continuous document.
Sources
- Prompt Programming for Large Language Models: Beyond the Few-Shot Paradigm — Laria Reynolds and Kyle McDonell (arXiv), February 15, 2021
- Calibrate Before Use: Improving Few-Shot Performance of Language Models — Zhao, Wallace, Feng, Klein, Singh (UC Berkeley, University of Maryland, UC Irvine) (arXiv), February 19, 2021
- Language Models are Few-Shot Learners — OpenAI (arXiv), May 28, 2020