Making Models Reason
Chain of thought.
Ask someone to multiply two big numbers in their head, and they'll likely be wrong. Give them paper, and they'll get it right. Language models are the same. Forcing an instant answer leads to mistakes. Letting them work it out step by step, in writing, makes them far more accurate.

- Mental maths goes wrong
- Paper makes it right
- Let the model write its working
Think step by step
Here's a question that has several steps. Three books, a voucher, delivery, and a membership rule. We add a short instruction. Think step by step, then give the total. Run it. The model writes down each step, including the free delivery rule, and arrives at the correct total. Those few words can raise accuracy a great deal on multi-step problems. Modern reasoning models do this by themselves, for longer.
from google import genai
client = genai.Client()
question = ("A customer bought 3 books at $12 each, used a $5 voucher, "
"and pays $6 for express delivery. Bright Plus members get free "
"express. The customer is a member. What is the total?")
answer = client.models.generate_content(
model="gemini-flash-latest",
contents=question + " Think step by step, then finish with: TOTAL: $amount")
print(answer.text.strip()[-220:])late the delivery fee. Express delivery is $6, but Bright Plus members get free express delivery. Since the customer is a member, the delivery cost is $0. Step 4: Calculate the final total. $31 + $0 = $31. TOTAL: $31
Checking its own work
You can also ask a model to review a draft against the rules. Here's a reply that wrongly says ninety days. We give it the policy and the draft, and ask it to find errors. Run it. It catches the mistake, and writes a corrected version. This critic pattern is one of the simplest ways to raise quality. A second pass often catches what the first one missed.
from google import genai
client = genai.Client()
draft = "Hi, sorry about the torn book. Send it back within 90 days for a refund."
policy = "Books can be returned within 30 days if unread. Damaged books are replaced free."
prompt = (f"Policy: {policy}\n\nDraft reply: {draft}\n\n"
"List any errors against the policy. Then write a corrected reply in "
"one sentence, starting with FIXED:")
print(client.models.generate_content(model="gemini-flash-latest",
contents=prompt).text.strip()[-260:])re replaced for free. 2. **Incorrect timeframe:** The draft mentions 90 days, but the policy only specifies a 30-day window (for returns). **Corrected reply:** FIXED: Hi, sorry about the torn book, so please send it back to us and we will replace it for free.
Chaining small steps
Don't ask one prompt to do everything. Break the work into small steps. Here, the first call extracts the facts. The second reads the tone. The third writes the reply, using the first two. Run it. Each step is simple, and easy to test. If the tone is wrong, you know exactly which part to fix. Reliable systems are built from small, testable steps.
from google import genai
client = genai.Client()
ask = lambda p: client.models.generate_content(
model="gemini-flash-latest", contents=p).text.strip()
message = "Third time asking! Order #48213 is still missing and I'm furious."
facts = ask(f"In one line, list the issue and order number: {message}")
tone = ask(f"In one word, how does this customer feel? {message}")
reply = ask(f"Write a two sentence reply. Facts: {facts}. Customer feels: {tone}.")
print("Facts:", facts)
print("Tone: ", tone)
print("Reply:", reply)Facts: Issue: Missing order | Order Number: #48213 Tone: Furious Reply: I am truly sorry for the frustration and anger caused by your missing order, #48213. I am personally investigating this with our shipping team right now and will follow up with you within the hour to make this right.
Summary
Think in steps, review your own work, and chain small prompts. These three patterns will fix most quality problems. Next, conversations. How does an assistant remember what you said a moment ago?
Key takeaways- Step by step improves accuracy
- A critic pass catches errors
- Chain small, testable steps