🧠 Advanced
Zero-Shot
🟢 Introduction
🟢 Emotion Prompting
🟢 Role Prompting
🟢 Re-reading (RE2)
🟢 Rephrase and Respond (RaR)
🟦 SimToM
◆ System 2 Attention (S2A)
Few-Shot
🟢 Introduction
🟢 Self-Ask
🟢 Self Generated In-Context Learning (SG-ICL)
🟢 Chain-of-Dictionary (CoD)
🟢 Cue-CoT
🟦 Chain of Knowledge (CoK)
◆ K-Nearest Neighbor (KNN)
◆◆ Vote-K
◆◆ Prompt Mining
Thought Generation
🟢 Introduction
🟢 Chain of Draft (CoD)
🟦 Contrastive Chain-of-Thought
🟦 Automatic Chain of Thought (Auto-CoT)
🟦 Tabular Chain-of-Thought (Tab-CoT)
🟦 Memory-of-Thought (MoT)
🟦 Active Prompting
🟦 Analogical Prompting
🟦 Complexity-Based Prompting
🟦 Step-Back Prompting
🟦 Thread of Thought (ThoT)
Ensembling
🟢 Introduction
🟢 Universal Self-Consistency
🟦 Mixture of Reasoning Experts (MoRE)
🟦 Max Mutual Information (MMI) Method
🟦 Prompt Paraphrasing
🟦 DiVeRSe (Diverse Verifier on Reasoning Step)
🟦 Universal Self-Adaptive Prompting (USP)
🟦 Consistency-based Self-adaptive Prompting (COSP)
🟦 Multi-Chain Reasoning (MCR)
Self-Criticism
🟢 Introduction
🟢 Self-Calibration
🟢 Chain of Density (CoD)
🟢 Chain-of-Verification (CoVe)
🟦 Self-Refine
🟦 Cumulative Reasoning
🟦 Reversing Chain-of-Thought (RCoT)
◆ Self-Verification
Decomposition
🟢 Introduction
🟢 Chain-of-Logic
🟦 Decomposed Prompting
🟦 Plan-and-Solve Prompting
🟦 Program of Thoughts
🟦 Tree of Thoughts
🟦 Chain of Code (CoC)
🟦 Duty-Distinct Chain-of-Thought (DDCoT)
◆ Faithful Chain-of-Thought
◆ Recursion of Thought
◆ Skeleton-of-Thought
🔓 Prompt Hacking
🟢 Defensive Measures
🟢 Introduction
🟢 Filtering
🟢 Instruction Defense
🟢 Post-Prompting
🟢 Random Sequence Enclosure
🟢 Sandwich Defense
🟢 XML Tagging
🟢 Separate LLM Evaluation
🟢 Other Approaches
🟢 Offensive Measures
🟢 Introduction
🟢 Simple Instruction Attack
🟢 Context Ignoring Attack
🟢 Compound Instruction Attack
🟢 Special Case Attack
🟢 Few-Shot Attack
🟢 Refusal Suppression
🟢 Context Switching Attack
🟢 Obfuscation/Token Smuggling
🟢 Task Deflection Attack
🟢 Payload Splitting
🟢 Defined Dictionary Attack
🟢 Indirect Injection
🟢 Recursive Injection
🟢 Code Injection
🟢 Virtualization
🟢 Pretending
🟢 Alignment Hacking
🟢 Authorized User
🟢 DAN (Do Anything Now)
🟢 Bad Chain
🔨 Tooling
Prompt Engineering IDEs
🟢 Introduction
GPT-3 Playground
Dust
Soaked
Everyprompt
Prompt IDE
PromptTools
PromptSource
PromptChainer
Prompts.ai
Snorkel 🚧
Human Loop
Spellbook 🚧
Kolla Prompt 🚧
Lang Chain
OpenPrompt
OpenAI DALLE IDE
Dream Studio
Patience
Promptmetheus
PromptSandbox.io
The Forge AI
AnySolve
Conclusion
🧠 AdvancedDecomposition◆ Recursion of Thought

◆ Recursion of Thought Prompting

Reading Time: 3 minutes
Last updated on September 27, 2024

Bhuwan Bhatt

Recursion of Thought Illustration
Takeaways
  • Recursion of Thought (RoT) overcomes context length limitations by using a divide-and-conquer strategy, breaking down complex problems into smaller sub-problems.
  • RoT solves large-scale tasks by processing parts of a problem in separate contexts and then aggregating the results to form the final answer.
  • Training required: Unlike Chain-of-Thought prompting, RoT requires supervised training before use, making it more resource-intensive.
  • Key applications include tasks like multi-digit arithmetic and sequence problems that exceed the context window limits of current Large Language Models.
  • Limitations include the need for prior training and lack of length generalization, meaning models trained with RoT do not automatically adapt to larger problems.

What is Recursion of Thought Prompting?

One of the major limitations of present-day Large Language Models (LLMs) is that they are limited by their context length. The table below shows the context limit of today's most advanced language models:

Model NameContext Window
gpt-4o128,000 tokens
gpt-3.5-turbo16,385 tokens
Gemini 1.032,000 tokens

As a result, for complex problems, the context length for Chain-of-Thought (CoT) prompting1Jason Wei. (2022). Chain-of-Thought Prompting Elicits Reasoning in Large Language Models. can grow exponentially and exceed the maximum allowed length.

Recursion of Thought (RoT) Prompting2Soochan Lee, G. K. (2023). Recursion of Thought: A Divide-and-Conquer Approach to Multi-Context Reasoning with Language Models. is an inference framework that uses the divide and conquer strategy to divide a problem into multiple sub-problems, solve them in separate contexts, and aggregate the answer from each into a final answer.

How to Use Recursion of Thought Prompting?

Unlike other methods in this section, you cannot simply prompt the LLM to use recursive divide and conquer. For the Recursion of Thought to work, you must first train the model using a training dataset. You can train an LLM or any language model, as RoT is a model-agnostic framework.

decomposer prompt and sub-task handler

Training Data sample for Recursion of Thought2Soochan Lee, G. K. (2023). Recursion of Thought: A Divide-and-Conquer Approach to Multi-Context Reasoning with Language Models.

During inference, RoT utilizes special tokens - GO, THINK, STOP - for recursive context control. As expected, GO and STOP mark the start and end of a problem sequence. When the model needs to decompose the problem into a simpler version, the subproblem, and solve it, it produces a THINK token. It then substitutes the solution to the subproblem back into the problem sequence. The process continues till we get the final solution.

What Are Recursion of Thought Results?

  • The authors train GPT-3 using the RoT framework for 48-digit addition/subtraction and 16-digit multiplication/division. CoT cannot solve those problems due to the context limit of 2048 tokens in GPT-3. Consequently, there is no apples-to-apples comparison. However, GPT-3 trained with RoT achieves near-perfect accuracy in both tasks.

  • Results are similar for other problems such as Longest Common Subsequence (LCS), G.2.2 Longest Palindromic Subsequence (LPS), 0-1 knapsack, and Matrix Chain Multiplication (MCM). While CoT cannot solve them beyond a certain complexity, RoT achieves a perfect score.

Limitations of Recursion of Thought Prompting

There are a few limitations to RoT that make it difficult for people to adopt the framework:

  • RoT requires supervised training before you can use it to run inference. This can be a costly and time-consuming procedure.
  • RoT is built with a goal to support context length greater than 100K. For common problems, this can be an overkill.
  • Unlike humans, RoT is incapable of length generalization. Training on 8-digit multiplication with RoT cannot make a model generalize to 16-digit multiplication.

Conclusion

For complex problems requiring a large context length, CoT length grows rapidly with increased complexity. Models like GPT-3 cannot accommodate such a huge context length. The RoT framework allows language models with limited context length to solve complex frameworks. However, RoT requires training the model using a labeled dataset before using it for inference. As such, RoT can be a good alternative to expensive and large language models like GPT-4.

Find more on Decomposition Prompting methods.

Footnotes

  1. Jason Wei. (2022). Chain-of-Thought Prompting Elicits Reasoning in Large Language Models.

  2. Soochan Lee, G. K. (2023). Recursion of Thought: A Divide-and-Conquer Approach to Multi-Context Reasoning with Language Models. 2

Bhuwan Bhatt

Bhuwan Bhatt, a Machine Learning Engineer with over 5 years of industry experience, is passionate about solving complex challenges at the intersection of machine learning and Python programming. Bhuwan has contributed his expertise to leading companies, driving innovation in AI/ML projects. Beyond his professional endeavors, Bhuwan is deeply committed to sharing his knowledge and experiences with others in the field. He firmly believes in continuous improvement, striving to grow by 1% each day in both his technical skills and personal development.

Edit this page

© 2025 Learn Prompting. All rights reserved.