GenAI Course · Module 8 · Session 27

Reasoning Techniques

⏱ 11 min read🎯 Intermediate🖼 2 diagrams🧪 3 live demos🐍 Python code

LLMs often get multi-step problems wrong when they answer in one jump. Simply asking them to show their working, like we did in school maths, makes them much more accurate. In this session, let us learn the main reasoning prompts and when to use each.

In this session

  • Chain-of-thought (CoT): zero-shot and few-shot
  • Self-consistency: ask several times and take a vote
  • Tree-of-thought and decomposition (least-to-most) prompting
  • How built-in reasoning models change the picture

01Chain-of-thought prompting

Here is a small word problem:

Question: A tea stall sells chai at ₹12 and samosa at ₹15. Ravi buys 3 chai and 2 samosas and pays with a ₹100 note. How much change does he get?

Two ways to get chain-of-thought (CoT):

📒

Like a maths teacher saying “show your working”. Students who write each step make fewer silly mistakes, and the teacher can see exactly where a mistake happened.

CoT is not free. It uses more output tokens (cost and time), and the written steps are not always a faithful explanation of how the model reached the answer. Use it for multi-step problems, not for simple lookups.

02Self-consistency: ask several times, take a vote

With some randomness (temperature around 0.7), the model may follow different reasoning paths. Self-consistency samples several CoT answers and picks the most common final answer. Wrong paths tend to disagree with each other, while correct paths agree.

One path made a mistake, but the vote still gives the right answer.
Demo · Sample and vote
Simulated model that is right 75% of the time on each try. Watch how voting is right more often than a single try.

Self-consistency improves accuracy on maths and logic, but costs N times more calls. Use it where a wrong answer is expensive and the answer can be compared exactly (a number, a label).

03Tree-of-thought and decomposition

Tree-of-thought (overview)

Instead of one chain, the model explores several possible next steps, scores each one, keeps the promising branches and drops the bad ones, like a chess player thinking a few moves ahead. It helps planning and puzzle-like problems, but needs many calls, so it is usually built with code (or an agent framework), not a single prompt.

Problem Idea A · 0.8 Idea B · 0.3 ✕ Idea C · 0.6 A1 · 0.9 ✓ A2 · 0.4 C1 · 0.5 Generate options → score them → expand the best → backtrack if needed
Tree-of-thought searches over reasoning steps instead of following just one.

Decomposition (least-to-most) prompting

Break a big question into smaller sub-questions, solve them in order, and use each answer in the next step. This is simple and works very well in practice:

04What about reasoning models?

Newer “reasoning” or “thinking” models (Session 24) are trained to do chain-of-thought internally before answering. With them:

TechniqueCallsBest for
Zero-shot CoT1Quick boost for multi-step questions
Few-shot CoT1When you want a specific style of working
Self-consistency5–20Maths, logic, labels where errors are costly
Tree-of-thoughtManyPlanning, puzzles, search problems
DecompositionA fewBig business questions, multi-part analysis

05Summary

06Quick quiz

1. Adding “Let’s think step by step.” to a question is called…

2. Self-consistency works by…

3. CoT helps most on…

4. Which technique explores and scores multiple branches?

5. With a built-in reasoning model, the best prompt is usually…

07References

Created by Ajeetkumar