Strategy#039

Prompt Engineering Patterns: Beyond Chain of Thought

DBy DaVeenci
16 min read
2025-12-07

Quick AnswerWhat is the difference between Chain of Thought and Tree of Thoughts?

Chain of Thought (CoT) is a linear reasoning method ("Let's think step by step") where the model follows a single path A → B → C. It is efficient but brittle; if one step is wrong, the final answer fails.

Tree of Thoughts (ToT) is a non-linear method where the model generates multiple possible "branches" of reasoning for each step, evaluates them (self-voting), and discards the bad paths. It mimics human brainstorming and is 70-80% more effective for complex planning, coding, and creative writing.

The Evolution: From Magic Words to Cognitive Architectures

In 2023, \"Prompt Engineering\" was often derided as \"whispering to the machine.\" By 2025, it has evolved into Cognitive Architecture Design.

We are no longer searching for the perfect phrase. We are structuring the flow of computation. Advanced patterns like ToT and RCI are designed to break \"tunnel vision\" by forcing Inference-Time Compute—trading speed for accuracy.

PatternTopologyBest Use Case
Chain of Thought (CoT)Linear (A→B→C)Math, simple logic
Tree of Thoughts (ToT)Branching (A→B1/B2/B3→C)Strategy, coding, creative
Graph of Thoughts (GoT)Networked (A+B → C)Aggregating research

Pattern 1: Tree of Thoughts (ToT)

The Concept

Humans don't just think linearly. When planning a move in chess, we explore multiple options using \"If/Then\" scenarios. ToT forces the LLM to do the same.

The \"System Prompt\" Template:

"Imagine three different experts are answering this question.
All experts will write down 1 step of their thinking, then share it with the group.
Then, all experts will critique each other's step and decide which path is the most promising.
If a path is flawed, they must discard it and start a new branch.
Continue this process until a consensus is reached."

Why it works: It forces the model to generate diverse perspectives and perform a "majority vote" on its own logic before committing.

Pattern 2: Recursive Criticism & Improvement (RCI)

The Concept

LLMs are often better at spotting errors than avoiding them. RCI asks the model to act as its own editor (Reflexion Loop).

  • Draft: Model generates a response.
  • Critique: "Review the previous response for security vulnerabilities, logic gaps, or tone inconsistencies."
  • Refine: "Rewrite the response strictly following the critique."

Result: Improves coding accuracy on HumanEval by over 30%.

Pattern 3: Chain of Density (CoD)

Standard summaries are often \"lossy\". Chain of Density is a recursive technique to pack more entities into a fixed-length summary.

The Algorithm:

  1. Write a sparse summary.
  2. Identify "Missing Entities" (facts/names left out).
  3. Rewrite the summary without increasing the length, fusing the missing entities.
  4. Repeat 3-5 times.

Best For: Creating high-signal executive briefings or newsletters.

Pattern 4: Maieutic Prompting (Socratic)

Named after the Socratic method, this pattern helps the model handle Ambiguity. If a user asks a vague question, a standard LLM guesses. A Maieutic agent asks clarifying questions.

The Template:

"I will ask a question. If the answer depends on conditions, do not answer directly.
Instead: Identify ambiguity. Propose a tree of logical explanations ('If A, then X'). Assess contradictions."

Best For: Legal analysis, Logical dilemmas, and Medical diagnosis.

Automating the Patterns: DSPy & DSP

By 2025, writing complex prompt chains by hand is considered brittle. The industry has moved toward DSPy (Declarative Self-Improving Language Programs).

What is DSPy?

Instead of writing text prompts ("You are a helpful assistant..."), you write Python code that compiles into prompts.

  • You define a module: ChainOfThought("question → answer").
  • You give it examples (Few-Shot).
  • The Compiler optimizes the prompt for you. It tests 1,000 variations against a metric and selects the best one.

Benefit: If you switch models (GPT-4 to Llama-3), DSPy recompiles the prompts to fit the new model automatically.

Frequently Asked Questions

Does OpenAI's o1 (Strawberry) make this obsolete?

OpenAI's o1 model performs 'Chain of Thought' internally. However, for Open Source models (Llama 4) or for granular control over logic, you still need to implement these patterns explicitly.

How much does Tree of Thoughts cost?

It is expensive. Generating 9 intermediate thoughts increases token usage by 10x. Use it only for high-value tasks.

Can I use these patterns in ChatGPT Plus?

Yes. You can paste the 'System Prompts' provided above into a Custom Instruction to force the model into these reasoning modes.

What is 'Skeleton-of-Thought'?

A latency-optimization pattern. You ask the model to first write an outline, then use parallel API calls to fill in each section simultaneously.