AI basics › How LLMs work
What is a reasoning model? AI that thinks before it answers
A reasoning model is an LLM trained to think at length before answering. How the idea spread, how it differs from chain-of-thought prompting, and when it fits.
If you’ve used an AI chatbot lately, you may have seen a “thinking” notice stay on the screen for a while before the answer appears, or the word thinking or reasoning next to a model’s name. Sometimes you can even open a panel and read what looks like the model talking to itself. Models like this are called reasoning models, and since late 2024 the name has turned up more and more often in model announcements and API documentation.
A reasoning model is an LLM trained to work through a long stretch of thinking before it gives its answer. An ordinary LLM starts writing the answer as soon as it reads the question. A reasoning model writes out its working first, checking along the way and sometimes backing up, and only then answers. In other words, it spends more computation at the moment of answering, and that’s how it gets through harder problems.
How the term spread
The usual starting point is OpenAI’s o1. In Learning to Reason with LLMs, published on September 12, 2024, OpenAI wrote that its large-scale reinforcement learning algorithm “teaches the model how to think productively using its chain of thought” through a data-efficient training process. Reinforcement learning lets a model try many times and nudges it toward the attempts that earn a reward. Through it, the post says, o1 learned to recognize and correct its mistakes and to try a different approach when one wasn’t working.
In January 2025, DeepSeek released the weights of DeepSeek-R1 along with a paper. The paper’s first model, DeepSeek-R1-Zero, skipped supervised fine-tuning and learned through reinforcement learning alone, with rewards that mainly checked whether the answer was correct and whether the thinking was wrapped in think tags. Even so, its responses grew steadily longer over training, and in the paper’s words, the model “naturally learns to solve reasoning tasks with more thinking time” this way. Then the Qwen3 Technical Report of May 2025 introduced models that hold a thinking mode and a non-thinking mode in one, and that’s the model I’ll use next.
Turning thinking on and off in a small model
Qwen3-0.6B is the smallest Qwen3 model, with about 0.6 billion parameters and about 1.5 GB of weights, so it runs on a laptop’s CPU (model card). According to the technical report, the small Qwen3 models were trained by distillation, learning to follow the outputs of larger ones. If you set the chat template’s enable_thinking to True, the model first writes its thinking inside think tags. With False, it answers right away.
The first block defines ask(), which asks a question and splits the output into the thinking and the answer. For thinking mode, the model card recommends sampling with Temperature=0.6, TopP=0.95, and TopK=20, and warns against greedy decoding, which “can lead to performance degradation and endless repetitions” in that mode. Even so, I used greedy decoding, always taking the most likely next token, so that anyone who runs it gets the same output. To guard against repetition, I capped each reply at 2,048 new tokens.
import re
import textwrap
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
name = "Qwen/Qwen3-0.6B"
tok = AutoTokenizer.from_pretrained(name)
model = AutoModelForCausalLM.from_pretrained(name, dtype=torch.float32)
end_think = tok.convert_tokens_to_ids("</think>")
def ask(question, thinking):
inputs = tok.apply_chat_template([{"role": "user", "content": question}], enable_thinking=thinking,
add_generation_prompt=True, return_tensors="pt", return_dict=True)
# Greedy decoding, so every run gives the same output
out = model.generate(**inputs, max_new_tokens=2048, do_sample=False)
ids = out[0, inputs["input_ids"].shape[1]:].tolist()
if end_think in ids: # the thinking part ends at </think>
cut = ids.index(end_think) + 1
else: # thinking was off, or it never finished
cut = len(ids) if thinking else 0
think = tok.decode(ids[:cut], skip_special_tokens=True)
answer = tok.decode(ids[cut:], skip_special_tokens=True)
return cut, think, answer
The second block asks three word problems with thinking off and then on, and prints the thinking length in tokens, the last number in the answer, and whether it’s right. Each question ends with a request to reply with only the number.
rule = " Reply with only the final number."
problems = [
("pen", "A notebook and a pen cost 110 cents together. The notebook costs "
"100 cents more than the pen. How many cents does the pen cost?", 5),
("apples", "Mia has 3 boxes with 12 apples in each. She gives away 15 apples "
"and then buys 8 more. How many apples does she have now?", 29),
("printers", "5 printers print 5 pages in 5 minutes. How many minutes do "
"100 printers need to print 100 pages?", 5),
]
for label, question, expected in problems:
for thinking in (False, True):
n_think, think, answer = ask(question + rule, thinking)
numbers = re.findall(r"\d+", answer)
final = int(numbers[-1]) if numbers else None # last number in the answer
print(f"{label:8} thinking {'on ' if thinking else 'off'} {n_think:4} tokens"
f" answer {final!s:>4} {'right' if final == expected else 'wrong'}")
if label == "pen" and thinking:
pen_thinking = think
pen thinking off 0 tokens answer 50 wrong
pen thinking on 541 tokens answer 5 right
apples thinking off 0 tokens answer 29 right
apples thinking on 763 tokens answer 29 right
printers thinking off 0 tokens answer 100 wrong
printers thinking on 2048 tokens answer None wrong
On the pen problem, the thinking-off mode ignored that request and set up an equation, reaching x = 5 and then answering 50. With thinking on, it thought for 541 tokens and answered 5. The apple problem came out right both ways, so 763 tokens of thinking bought nothing extra. On the printer problem, whose answer is 5 minutes, the thinking-off mode said 100. The thinking-on mode wrote “the answer is 5” ten times, yet kept saying “Wait” and going back over it until it hit the 2,048-token cap without answering. I didn’t test the recommended settings or a longer cap. The third block shows the pen problem’s thinking, trimmed to its first two and last six lines.
# The pen problem's thinking, cut down to its first and last lines
lines = [line for line in pen_thinking.splitlines() if line.strip()]
for line in lines[:2] + ["..."] + lines[-6:]:
print(textwrap.fill(line, 76))
<think>
Okay, let's see. There's a notebook and a pen that together cost 110 cents.
Also, the notebook is 100 cents more than the pen. I need to find out how
much the pen costs. Hmm, let me think.
...
Wait, but let me make sure I didn't make any mistakes in my equations. The
problem says the notebook costs 100 cents more than the pen. So if the pen
is P, then notebook is P + 100. Adding them gives 2P + 100 = 110. Solving
gives P = 5. Yep, that seems right.
Alternatively, maybe I can think of it as the pen is x cents, notebook is x
+ 100. Total is 2x + 100 = 110. Subtract 100: 2x = 10, so x = 5. Same
result.
I think that's correct. So the pen costs 5 cents. The answer is 5.
**Final Answer**
The pen costs \boxed{5} cents.
</think>
After solving the equation, the model says “Wait, but let me make sure” and solves the problem a second way before settling on 5. I also asked five more problems, and each mode got three right. Across all eight, every miss with thinking on came from hitting the cap. And without the request for only a number, the thinking-off mode got the pen problem right too, so it’s best not to read a handful of problems as a measurement.
How it differs from chain-of-thought prompting
Getting a model to write out its working isn’t a new idea. In 2022, Jason Wei and colleagues at Google put eight worked examples with intermediate steps into the prompt and called the method chain-of-thought prompting. They described a chain of thought as “a series of intermediate reasoning steps” that lead to the answer. A few months later, Takeshi Kojima and colleagues showed that even without examples, adding “Let’s think step by step” before the answer raised accuracy a great deal (Kojima et al., 2022).
The difference lies in where the habit comes from. Chain-of-thought prompting asks for steps in the prompt every time, while a reasoning model has the habit trained in and thinks at length without being asked. That’s why OpenAI’s reasoning best practices say that telling these models to “think step by step” is unnecessary, since they already reason internally.
Longer thinking tends to help
The computation a model spends when it actually produces an answer is called test-time compute. In the o1 post’s charts, o1’s accuracy on AIME, an American high school math competition, rose the longer reinforcement learning went on and the longer the model was allowed to think. Note that the horizontal axes use a log scale, so each step to the right multiplies the compute several times over.
Of course, that’s a tendency on hard benchmarks, and it comes with a cost. On my Mac’s CPU, the thinking-off answers in the example came back within about ten seconds, while the thinking-on answers took close to a minute, and more than two minutes when they hit the cap.
What you get to see of the thinking
I could read every word of the thinking above because it was an open model, but commercial services usually don’t hand over the raw thinking. Here’s what the official docs of three companies said when I checked them on October 28, 2026.
- OpenAI’s reasoning guide says reasoning tokens aren’t visible through the API, yet they take up context window space and are billed as output tokens. You request a summary with
summaryand set how hard the model thinks withreasoning.effort. - Anthropic’s thinking docs say a thinking block holds only a summary, no setting returns the raw chain of thought, and you’re charged for the full thinking tokens. An effort setting controls how much Claude thinks.
- Google’s Gemini thinking docs say only the final output comes back by default and thought summaries can be turned on, while pricing is based on the full thought tokens. Depth is set with
thinking_level.
In the o1 post, OpenAI said it made this choice after weighing user experience, competitive advantage, and the option of monitoring the chain of thought. So the thinking you read in these services is usually a summary, and the bill includes the thinking you never saw.
The written thinking may not tell the whole story
Reading the thinking can feel like watching the model reach its answer. Yet Anthropic’s April 2025 study, Reasoning models don’t always say what they think, found that this isn’t necessarily so. The researchers slipped a hint about the answer into a question and, where the hint changed the answer, checked whether the model admitted using it. Claude 3.7 Sonnet mentioned the hint 25% of the time and DeepSeek-R1 39% of the time, and the explanations that hid it were on average longer.
In setups where a loophole also earned reward, the model used the loophole on more than 99% of the examples. Yet in five of the six environments, it wrote about the loophole in its thinking less than 2% of the time. The paper concludes that watching the chain of thought is a promising way to notice unintended behavior, but not reliable enough to rule it out. So the thinking makes a useful clue, and it’s safer not to treat it as a full record of how the answer came about.
Where it fits and where it doesn’t
Reasoning models tend to fit work that takes several steps and whose result is easy to check, such as math, coding, and planning a task with many stages. Anthropic’s thinking docs likewise say thinking improves performance on complex tasks such as math, coding, analysis, and long-running agentic work.
They fit less well for simple questions or where a fast response matters, because thinking takes time and every thinking token is billed. The DeepSeek-R1 paper also notes that overthinking on simple questions remains a problem, and as the printer problem showed, longer thinking doesn’t even guarantee an answer.
Where to start
If you’d like to try it, install the libraries with pip install torch transformers and run the three blocks above in order. Then try other questions, or swap in the card’s recommended sampling and a longer cap, and watch how the thinking and the answer change. If you use a commercial API, the three docs pages above show how to set the effort level and turn on summaries. I ran this example on October 28, 2026, on a Mac’s CPU with Python 3.13.12, PyTorch 2.14.1, and Transformers 5.20.2.
AI tools helped with the research for this post.