Building a Thinking Model from a Non Thinking Model with Chain of Thought

Large language models can be great at fluent writing yet shaky at reasoning. Many jump to an answer without showing the steps. Chain of Thought prompting nudges the model to reason step by step, so a non thinking model starts to behave like a thinking one.
What is Chain of Thought
Chain of Thought is a prompt style that asks the model to break a problem into intermediate steps before giving the final answer. That gentle structure reduces careless mistakes.
Example without CoT
Q: If you have 3 apples and get 2 more, how many do you have?
A: 5
Example with CoT
Q: If you have 3 apples and get 2 more, how many do you have?
A: I start with 3 apples. I add 2 apples. Now I have 5 apples in total. The answer is 5.
Why some models need this
Some models are tuned for short, confident replies. They may skip reasoning, make intuitive guesses, or become inconsistent on multi step problems. CoT acts like scaffolding that guides each step.
A minimal helper for examples
Below is a tiny wrapper you can adapt to your setup. Replace the body with your actual chat call.
async function chatCompletion(prompt) {
// return await client.responses.create({ input: prompt });
return "Mocked response for illustration";
}
Basic Chain of Thought prompt
Add a simple instruction like “Think step by step.”
async function chainOfThought(question) {
const prompt = `${question}
Please think step by step before answering.`;
const reply = await chatCompletion(prompt);
console.log(reply);
}
// Example
chainOfThought(
"A car travels 60 km in 1 hour. How far will it travel in 4 hours?"
);
/*
Expected shape:
First, in 1 hour the car travels 60 km.
In 4 hours that is 60 × 4 = 240 km.
So the answer is 240 km.
*/
Structured reasoning template
Give the model a clear structure to follow.
async function structuredCoT(question) {
const template = `
Question: ${question}
Step 1: Restate the problem.
Step 2: Identify key facts.
Step 3: Solve step by step.
Step 4: Provide the final answer.`;
const reply = await chatCompletion(template);
console.log(reply);
}
// Example
structuredCoT(
"If a box holds 8 books, how many boxes are needed for 100 books? Return an integer and explain."
);
/*
Expected shape:
Step 1: We need the number of boxes...
Step 2: Each box holds 8 books...
Step 3: 100 ÷ 8 = 12.5 so we need 13 boxes...
Step 4: Final answer: 13.
*/
Few shot plus Chain of Thought
Show one or two worked solutions before the real question. This sets a pattern the model can imitate.
async function fewShotCoT(question) {
const prompt = `
You will solve problems by explaining your steps briefly, then giving a final answer on a new line starting with "Answer:".
Example 1
Q: I have 5 pencils and buy 3 more. How many in total?
A: I start with 5 pencils. I add 3 pencils. That makes 8 pencils in total.
Answer: 8
Example 2
Q: A bag has 4 apples, and I add 6 more. How many apples now?
A: I start with 4 apples. I add 6 apples. That makes 10 apples in total.
Answer: 10
Now your turn
Q: ${question}
A:`;
const reply = await chatCompletion(prompt);
console.log(reply);
}
// Example
fewShotCoT("There are 7 oranges, and I buy 5 more. How many in total?");
/*
Expected shape:
I start with 7 oranges. I add 5 oranges. That makes 12 oranges in total.
Answer: 12
*/
Guardrails for clarity and brevity
CoT can increase length and latency. Keep it tidy with explicit formatting rules.
async function conciseCoT(question) {
const prompt = `
Solve the following task using at most three short steps, then give a final line starting with "Answer:".
Keep explanations compact.
Task: ${question}`;
const reply = await chatCompletion(prompt);
console.log(reply);
}
// Example
conciseCoT("A train moves 90 km per hour for 2.5 hours. How far does it travel?");
/*
Expected shape:
Step 1: Rate is 90 km per hour.
Step 2: Time is 2.5 hours.
Step 3: Distance = 90 × 2.5 = 225 km.
Answer: 225 km
*/
Programmatic checker pattern
Ask the model to propose steps, then verify or recompute the final answer. This can catch slips on arithmetic or logic.
async function proposeVerify(question) {
const prompt = `
You will solve the problem in two phases.
Phase A Reasoning
Explain your steps briefly.
Phase B Check
Recompute the final value directly and confirm it matches.
Problem: ${question}
Output format:
Reasoning: <two to four short sentences>
Check: <one sentence>
Answer: <final value only>`;
const reply = await chatCompletion(prompt);
console.log(reply);
}
// Example
proposeVerify("A recipe needs 3 cups of flour for one batch. How many cups for 7 batches?");
/*
Expected shape:
Reasoning: One batch uses 3 cups. Seven batches require 7 × 3.
Check: 7 × 3 = 21.
Answer: 21
*/
Side by side prompt for learning effect
Use a single prompt that contrasts naive answering with stepwise reasoning.
async function compareNaiveVsCoT(question) {
const prompt = `
We will answer the same question in two ways.
Naive answer
Just give a direct answer without explanation.
Reasoned answer
Think step by step in two or three short lines, then provide a final line starting with "Answer:".
Question: ${question}
Begin.`;
const reply = await chatCompletion(prompt);
console.log(reply);
}
// Example
compareNaiveVsCoT(
"You have 48 candies and share them equally among 6 friends. How many candies per friend?"
);
/*
Expected shape:
Naive answer: 8
Reasoned answer:
48 candies shared among 6 friends means division.
48 ÷ 6 = 8.
Answer: 8
*/
Practical tips
Start with a simple “think step by step” instruction
If results are messy, add a structure with labeled steps
If the model still struggles, include one or two worked examples
Keep explanations concise by setting limits on step count or sentence length
Use a final explicit line for the answer so it is easy to parse in code
Summary
Chain of Thought turns a quick guessing model into a steadier reasoner by guiding each step. You do not change the architecture. You just prompt better. Begin with a plain instruction, add structure when needed, and combine with a few examples for tricky tasks.






