From the book

What is a prompt?

· By Robert Scales · 4 min read

Short answer

A prompt is whatever you type to an AI model such as ChatGPT: a question, an instruction, a piece of text to work on, or all three. The model builds its reply from your prompt, so a clear, specific prompt with the right context gets a far more useful answer than a vague one.

Every conversation with ChatGPT starts with a prompt. It might be one word ("haiku?"), a full page of instructions, or a document you paste in with a request on top. Whatever form it takes, the prompt is the only thing the model has to go on. It does not know who you are, why you are asking or what you plan to do with the answer unless the prompt tells it.

This is the starting point of A Beginner's Guide to ChatGPT, the book Robert Scales published this week, and the first article in a short series built on its method. The book's central idea is simple: most disappointing answers come from thin prompts, and most good answers come from prompts that give the model a role, some context, a clear task and an expected format.

What a prompt is made of

Think of a prompt as a brief you would hand to a capable new colleague on their first day. They are quick and well read, but they know nothing about your situation. A useful brief usually covers four things:

PartWhat it answersExample
RoleWho should the model act as?"You are a patient high-school chemistry teacher."
ContextWhat is the situation?"My student is 15 and failed the last quiz on moles."
TaskWhat exactly should it do?"Explain the mole with one everyday comparison."
FormatWhat should the answer look like?"Under 150 words, then three practice questions."

You will not need all four every time. A quick fact or a synonym needs none of them. But when an answer comes back generic, one of these parts is almost always missing.

OpenAI's own guidance for developers points the same way. Its help center recommends putting the instruction first, keeping it separate from any text you want processed, and being specific about the context, outcome, length, format and style you want. It also suggests showing an example of the format, since models follow a pattern they can see more reliably than one you only describe.

A before-and-after example

The book makes the case with a camping trip: a bare request for evening activities gets a stock list, while a detailed scenario gets suggestions that fit the people and the day. Here is the same idea with a different everyday task.

Prompt
Give me dinner ideas.

That will return a reasonable, forgettable list. Now add the four parts:

Prompt
You are a home cook who plans cheap weeknight meals. I have two kids under ten, 30 minutes after work, and in the fridge right now: chicken thighs, rice, carrots, eggs and a half bag of spinach. Suggest three dinners I can make this week with mostly these ingredients. For each, give the cooking time, a short ingredient list marking anything I'd need to buy, and one tip to get kids to eat it.

The second prompt does not use special words or tricks. It simply removes the guesswork. The model now knows the cook, the time limit, the ingredients, the audience and the shape of the reply.

How the model reads your prompt

ChatGPT runs on large language models, GPT-3.5 for free users and GPT-4 for Plus subscribers. These models were trained on huge amounts of text to predict what comes next. When you send a prompt, the model reads it, along with the earlier messages in the same chat, and then writes the most fitting continuation one piece at a time.

Two consequences follow. First, everything earlier in the conversation is part of the prompt. If you told it twenty messages ago that you live in Quebec, that may still shape the answer, and if you switch topics completely, starting a new chat can give cleaner results. Second, the model fills any gap with the most typical answer. Leave out the audience and you get an answer for an average reader. Leave out the length and you get whatever length is common.

Try it: Pick a task you did this week, such as an email, a plan or a summary. Write a one-line prompt for it, then rewrite it with a role, context, task and format. Run both in separate chats and note what the longer prompt gave you that the short one did not.

Why does the same question get different answers?

If you ask ChatGPT the same thing twice, or ask it to try again, you will usually get a different reply. That is by design. When the model picks each next word, it does not always take the single most likely one; it samples from several good candidates. OpenAI's developer guide explains that a setting called temperature controls how often the model picks less likely words. A higher temperature gives more varied, often more creative text, while a temperature of zero suits factual tasks. That is one reason the same prompt rarely produces identical text twice.

Small changes in wording matter too. OpenAI noted when it launched ChatGPT that the model is sensitive to tweaks in phrasing: one version of a question can produce "I don't know" and a slight rewording a correct answer. The conversation history also changes the input, so the same question in a new chat and in a long chat are not really the same prompt. And GPT-3.5 and GPT-4 will answer differently because they are different models.

For a beginner, the useful conclusion is practical. Variation is helpful for ideas: ask several times and keep the best. It is a warning sign for facts: if two answers to a factual question disagree, at least one is wrong, and you should check a reliable source before using either.

Sources

  1. A Beginner's Guide to ChatGPT — Holistic Hybrid, April 18, 2023
  2. Best practices for prompt engineering with OpenAI API — OpenAI Help Center
  3. ChatGPT: Optimizing Language Models for Dialogue — OpenAI, November 30, 2022

Get the free Guide to Artificial Intelligence

Sign up for the weekly newsletter and receive the free guide: what changed in AI this week, one lesson, one prompt to try. Unsubscribe in one click.

How we handle your address

Back to top

Display

Your choices are saved in this browser only. No data is sent.

Text size
100%
Colours
Reading
More settings
Accessibility statement