4.4.7 · HinglishAlignment, Prompting & RAG

Chain-of-thought prompting

1,808 words8 min readRead in English

4.4.7 · AI-ML › Alignment, Prompting & RAG


KIYA hai Chain-of-Thought (CoT)?

Reasoning steps natural language mein generate hote hain, aur answer generation ke tail se read off kiya jaata hai.

Do main flavours


KYUN kaam karta hai? (First-principles reasoning)

Ek transformer har generated token pe fixed amount of computation karta hai (ek forward pass). Kisi hard problem ke liye, output ka ek single token ek bahut chota compute budget hai — model ko poori multi-step reasoning ek hi forward pass mein compress karna padta hai, jo woh reliably nahi kar sakta.

Formally, model ko approximate karte socho. Reasoning paths pe marginalise karke:

Figure — Chain-of-thought prompting

KAISE likhein CoT prompt

Few-shot CoT template

Q: Roger has 5 tennis balls. He buys 2 cans of 3 balls each.
   How many balls does he have now?
A: Roger starts with 5 balls. 2 cans × 3 balls = 6 balls.
   5 + 6 = 11. The answer is 11.

Q: <your new question>
A:

Ye step kyun? Exemplar format demonstrate karta hai: pehle reason karo, phir "The answer is X". Model us structure ko pattern-match karke reproduce karta hai.

Zero-shot CoT template

Q: <your question>
A: Let's think step by step.

Ye step kyun? Trigger phrase model ko ek aisi distribution mein shift karta hai jahan agle tokens reasoning hain, na ki ek bare answer.


Self-Consistency (power-up)


Worked examples


Common mistakes


Recall Feynman: 12-saal ke bacche ko samjhao

Socho ek hard maths puzzle hai. Agar main tumhe answer fauran chillane pe majboor karun, toh tum shayad galat guess karoge. Lekin agar main tumhe pehle scrap paper pe kaam likhne dun — "okay, 23 apples, 20 minus, woh 3 hai, 6 add karo, woh 9 hai" — toh tum kaafi zyada baar sahi nikaloge. Chain-of-thought bas AI ko scrap paper dena aur kehna hai "answer se pehle apna kaam dikhao." Aur agar tum teen doston se alag-alag kaam karne ko kaho aur woh mostly "9" bolein, toh tum 9 pe trust karte ho — yahi self-consistency hai.


Flashcards

Chain-of-thought prompting kya hai?
Ek LLM ko guide karna ki woh final answer se pehle intermediate reasoning steps produce kare, yaani instead of .
Zero-shot CoT trigger phrase?
"Let's think step by step."
Few-shot aur zero-shot CoT mein kya fark hai?
Few-shot prompt mein worked exemplars deta hai; zero-shot sirf ek trigger phrase use karta hai, koi exemplars nahi.
Reasoning tokens performance kyun improve karte hain (compute view)?
Har generated token ek forward pass hai jo context mein wapas feed hota hai, toh CoT zyada effective computation kharidta hai aur intermediate results externalise karta hai.
Probabilistic decomposition jo CoT exploit karta hai?
— ek hard prediction ko kaafi saari easy, in-distribution predictions se replace karta hai.
Self-consistency decoding kya hai?
N diverse chains sample karo aur unke final answers pe majority vote lo.
Majority voting kyun kaam karta hai?
Correct answers kaafi saare valid paths se reach hote hain; errors scattered hote hain, toh voting sabse zyada supported answer pe concentrate hoti hai.
CoT mainly kab help karta hai (Steel-man mistake)?
Large scale par emergently; chote models ko benefit nahi milta aur woh worse bhi ho sakte hain.
CoT mein faithfulness problem kya hai?
Written chain ek post-hoc rationalisation ho sakti hai, answer ka asli cause nahi; chain ki correctness ≠ answer ki correctness.
Self-consistency formula?
.

Connections

  • Prompt Engineering — CoT ek core prompting pattern hai.
  • Few-shot In-context Learning — few-shot CoT, ICL ka ek specialisation hai.
  • Self-Consistency Decoding — CoT ka sampling+vote upgrade.
  • Tree of Thoughts / ReAct — linear chains ko search / tool-use tak extend karte hain.
  • Emergent Abilities of LLMs — explain karta hai kyun CoT ko scale chahiye.
  • Retrieval-Augmented Generation — external facts ko CoT reasoning ke saath combine karo.
  • Temperature and Sampling — diverse chains generate karne ke liye zaroori hai.

Concept Map

limited on hard tasks

generates

then read off

flavour

flavour

uses

uses exemplars

motivates

buys compute for

formalised by

calibrates

Standard prompting q to a

Chain-of-Thought

Intermediate reasoning steps

Final answer a

Few-shot CoT

Zero-shot CoT

Think step by step phrase

Fixed compute per token

Tokens as compute budget

Marginalise over paths r

Pretraining on step-by-step text