Lesson 41 — Beginner
Reasoning & Decomposition
Har task ko "think step by step" bol kar solve nahi karna hota. Is lesson mein hum decide karenge kab reasoning prompt chahiye aur kab seedha jawaab, complex kaam ko kaise sub-problems mein todein (decomposition), aur naye reasoning models ke saath prompting kaise badalti hai.
Kab reasoning prompt chahiye
WHAT
Reasoning-oriented prompting matlab model ko explicit steps lene ko bolna — plan banao, calculate karo, check karo. Multi-step logic, maths, planning aur constraint-heavy tasks mein output quality badhti hai.
WHEN
Jab kaam mein dependencies hain: "pehle items nikalo, phir tax jodo, phir discount lagao". Ya jab constraint clash ho sakta hai — wahan step-by-step sochne se galati kam hoti hai.
WHERE
Math word problems, multi-file code changes, debugging chains, budget planning, aur rule-heavy classification — yahan reasoning se farak dikhta hai.
Reasoning ka fayda tab hai jab jawaab seedha nahi hai — beech mein calculation, ya do constraints ka trade-off hai. Wahan model ko sochne ki jagah do, warna wo shortcut lega.
Kab reasoning bekaar hai
# EXTRACTION — simple instruction kaafi, reasoning se sirf latency badhti hai
Bill: Subtotal Rs.1,200, SGST Rs.108, CGST Rs.108, Total Rs.1,416
Task: sirf total nikalo (ek number), koi explanation nahi.
# REWRITE — style change, koi calculation nahi
Task: is line ko formal tone mein dobara likho.
# CLASSIFICATION — label chahiye, soch nahi
Task: sentiment ka label lo: POSITIVE / NEGATIVE. Ek word.
- Extraction: field padh ke nikalna — ek instruction enough.
- Rewrite/translate: content wahi hai, style badalna hai — reasoning ki zarurat nahi.
- Simple classification: label list de do, straight output lo.
- In tasks mein "think step by step" likhne se model extra gyaan ugalta hai — output lamba, parse karna mushkil, aur faayda zero.
Decomposition — kaam ko todo
# Ek mushkil task ko sub-steps mein toda — har step ka output agle ka input
steps = [
"1. Invoice ke line items nikalo: item, qty, price.",
"2. Har item ka amount nikaalo: qty * price.",
"3. Subtotal jodo, phir GST percentage laga ke tax nikaalo.",
"4. Total = subtotal + tax. Sirf final total batao.",
]
# Code generation mein bhi wahi pattern:
# 1) function signature banao 2) body likho 3) edge cases check karo 4) tests likho
Decomposition ke do tareeke hain: ek hi prompt mein numbered steps likhna (chhote kaam ke liye), ya alag-alag calls — pehle step ka output capture karke agle prompt mein daalna (bade pipeline ke liye, jahan intermediate output pe validation chahiye).
- Har step ka output clear hona chahiye — warna error aage propagate hota rehta hai.
- Step 2-4 line ke kaam ho toh ek hi prompt kaafi; 5+ independent stages hon toh calls alag karo.
- Sub-steps mein apna "check this" step rakho — model khud verify kar le intermediate result.
Reasoning models ke saath prompting
# Instruction-based purane model ko aksar yahi chahiye tha:
"Let us think step by step..." / "Har step alag-alag line mein likho"
# Reasoning models ko goal + constraints do — wo internally sochte hain:
Goal: Rs.50,000 ko 3 saal mein 3 schemes mein baantna hai.
Constraints: risk low hona chahiye; har scheme ka amount integer rupees mein.
Output: ek table — scheme | amount | reason.
- Reasoning models apne aap internal steps banate hain — unhe "think step by step" ya har step likhne ko kehna aksar bekaar ya counter-productive hota hai.
- Unke saath goal, constraints aur output shape do — yehi kaafi hai.
- Chain-of-thought instruction har model pe same effect nahi deti — kaunsa model use kar rahe ho wo check karo, aur waisa prompt karo.
- Simple extraction/classification task mein bada reasoning model lagana = zyada latency aur cost, faayda nahi. Task ki complexity ke hisaab se model chuno.
Exercise
Question: Invoice se sirf total amount nikalna hai — reasoning steps chahiye ya simple extraction instruction kaafi?
Question: Complex task ko chhote sub-steps mein todne ko kya kehte hain? (ek word)
Question: "Think step by step" ki wajah se modern reasoning models apne aap kya karte hain? (internal / manual)
Common mistakes
- Har chhote kaam pe "think step by step": Extract/classify/rewrite jaise tasks mein reasoning se sirf latency aur token bill badhta hai, output aur messy hota hai. Simple instruction seedhi maango.
- Reasoning models ko wahi purane CoT instructions dena: Naye reasoning models khud internally sochte hain — unhe bas goal, constraints aur output shape do. Forced step-by-step likhwana unki working ko bigaad sakta hai.
- Poora mushkil kaam ek hi shot mein maang lena: 3-stage planning wale task mein model shortcut lega. Decomposition karo — numbered steps ya alag calls — tabhi consistent result milega.
Mehmaan ko ek saath pura menu mat poocho — starter, main, dessert alag-alag finalise karo. Model ko bhi wahi: har sub-problem alag, tabhi order complete hoga:
Step 1: starter finalize -> paneer tikka (2 plates)
Step 2: main finalize -> dal makhani + 4 roti
Step 3: budget check -> Rs.900 mein hai? (haan)
Step 4: final order print -> waiter ko do
Ek hi shot mein "pur lunch plan kar" bologe toh waiter guess karega — yaad rakho, model bhi wahi karta hai.- Q: Reasoning prompt kab use karna chahiye? — Multi-step logic, maths, planning aur constraint-heavy tasks mein; simple extraction mein nahi.
- Q: Decomposition se kya milta hai? — Ek mushkil instruction ki jagah clear sub-problems, jahan har step ka output validate ho sakta hai.
- Q: "Think step by step" kyun outdated mana jaata hai? — Wo instruction-based models ke liye tha; reasoning models internally sochte hain, unhe goal + constraints do.
- Q: Ticket ka sentiment label chahiye — reasoning model lagana chahiye? — Nahi; simple classification ke liye basic instruction/label list kaafi hai.
Reasoning aur decomposition ka decision rule clear. Agla lesson — System Prompt Design — mein seekhenge app ka stable behavior kaise likhte hain.