Skip to content
Back to log

Writing prompts for reasoning models

Chainabit's Chao · · 7 min read

In short

How do you specify the task, constraints, and output format in a prompt? We explain using OpenAI’s guidance and Google Research’s chain-of-thought experiments.

Specify the task, constraints, and output

OpenAI recommends giving reasoning models a clear goal, firm constraints, and a well-defined output. The prompt should specify what the model needs to do, which constraints it must follow, and the desired output format. There’s no need to spell out every intermediate step.

The task and the output format serve different purposes. The task describes what you want the model to do. The output format specifies how the response should be presented. OpenAI treats the task, constraints, and output format as separate parts of the prompt.

For agentic or research-heavy workflows, OpenAI also recommends defining what counts as finished and how the model should verify its work. These give the prompt both a completion criterion and a verification method.

OpenAI uses reasoning.effort to control how much reasoning the model does. It describes this setting as a way to fine-tune that behavior and gives priority to prompt changes when addressing output quality. Its guidance on specifying the task, constraints, and output format applies to the prompt itself.

Using examples in a prompt

Google Research’s study on chain-of-thought prompting examines a method that adds task-specific examples to the prompt. Each chain-of-thought example in the study contains an input, intermediate reasoning steps that lead to a result, and an output. The researchers describe those steps as a coherent sequence leading to the final answer.

In the standard few-shot prompting format used for comparison, examples consist of input-output pairs. They’re written as questions and answers, with the answer given directly. In the chain-of-thought format, each example also includes the intermediate steps leading to its answer. The model is then asked to produce an output for a new input.

In the researchers’ arithmetic example, Roger starts with five tennis balls. He buys two more cans with three balls each. The example first calculates that the cans contain six balls in total. It then adds the original five balls to get eleven.

In the same demonstration, the model is given a different question to answer. A cafeteria starts with twenty-three apples, uses twenty for lunch, and buys six more. The model’s chain-of-thought response shows the subtraction first, then the addition, and gives nine as the result.

In the standard prompting demonstration, the answer to Roger’s question contains no intermediate calculations. The model’s response to the cafeteria question also gives a direct answer. Together, the two demonstrations show how including intermediate steps in an example changes the format of the prompt.

The study’s arithmetic tasks include free-response problems and a multiple-choice task. The researchers used the same set of examples for the free-response math problems. For the multiple-choice task, they used examples and solutions from the training set.

One multiple-choice example asks how many digits are needed to write the numbers in a given range. The sample answer groups the numbers by digit count and works out how many digits each group contributes. It then gives the option that matches the calculated total.

How intermediate steps vary across tasks

Alongside arithmetic, the Google Research study examines chain-of-thought examples for commonsense reasoning and symbolic reasoning tasks. The examples follow the same format, with intermediate steps and an output following the input. What those steps contain depends on the task.

One commonsense reasoning example asks where someone looking for a crowded place could go. The sample answer explains that the place should be somewhere many people gather. It then considers the options against that criterion and gives the selected answer.

Another example asks whether a pear will sink in water. The answer compares the pear’s density with that of water. It then explains that the pear will float and answers no. The comparison comes before the final answer.

One symbolic reasoning task involves joining the last letters of the words in a name. In the study’s example, the last letter of each of two words is identified separately. The letters are joined, and the resulting string is given as the answer. The output follows the steps of finding and joining the letters.

Turn this insight into action.

Use the mobile app to continue with guided workflows.

The other symbolic reasoning task asks whether a coin that starts with a particular side up still has that side up after a series of flips. In the example, one person flips the coin and the other leaves it as it is. The answer uses the number of flips and the starting orientation to determine which side is up at the end.

For both symbolic reasoning tasks, the researchers examined test inputs that required the same number of steps as the examples, as well as inputs that required more. The last-letter examples used two-word names, while the evaluation also included longer names. The researchers similarly varied the number of possible flips in the coin-flip task.

How examples are written and ordered

The Google Research team examined versions of the same few-shot examples in which different people independently wrote the intermediate steps. The study also tested a shorter version written by the same author. The researchers observed that results varied across versions.

In the shorter version, multiplication gives the total number of computers added over several days. That number is then added to the starting quantity. The longer version states the starting quantity and the number of computers added each day in separate sentences, then shows the same two calculations.

Alongside the examples they wrote themselves, the researchers tested examples drawn from a training set that included intermediate reasoning steps. They evaluated separate groups of examples from that set on arithmetic tasks. The study also included experiments that varied the order and number of examples in the prompt.

The researchers found that changing the order of examples had a relatively small effect in most cases they examined. The coin-flip task was an exception, with results varying considerably across example orders. The study also notes that how a prompt is worded can affect the results.

Other formats tested in the study

To understand the role of intermediate steps, the Google Research team compared several variants of the chain-of-thought format. In one variant, the example gives only the mathematical equation before the answer, in place of intermediate steps written in natural language. This format improved performance on some sets of one- or two-step problems and helped little on another math problem set the researchers examined.

In another experiment, the model was asked to produce a string of dots with as many characters as the equation needed to solve the problem. This version performed similarly to the study’s standard prompting baseline. The researchers used the experiment to distinguish the effect of the amount of intermediate computation from that of reasoning expressed in natural language.

The team also tested a format that placed the chain of thought after the answer. This format likewise performed similarly to the standard prompting baseline. The experiment examined the role of generating a sequence of intermediate steps before giving the final answer.

The visible response and the reasoning summary

According to OpenAI, reasoning models use internal reasoning tokens before producing a response. The model uses these tokens to break down the prompt and consider different approaches to generating a response. OpenAI links this process to tasks such as planning and solving multi-step problems.

OpenAI says it does not expose the raw reasoning tokens the model generates. For models that support reasoning summaries, you can request one using the summary parameter. The summary appears in the summary array of the reasoning item in the output and is included only when explicitly requested. Supported summary settings can vary by model.

Limitations

According to the Google Research researchers, a generated chain of thought offers a way to understand how the model may have arrived at a particular answer. Fully explaining the model computations behind an answer remains an open research question.

A model can produce a flawed chain of reasoning. The researchers note that an incorrect reasoning path can lead to either a correct or an incorrect answer. Among the errors examined in the study were misunderstandings, missing steps, repetitive outputs, and errors in mapping symbols.

The researchers also discuss adding intermediate steps to few-shot examples by hand. Preparing these explanations for fine-tuning can be costly. And whether a neural network is actually reasoning remains an open question even when it produces text that resembles human thought.

Ready to start?

Download the app and continue from your phone.

End of Entry