Markov Chain of Thought for Efficient Mathematical Reasoning

Wen Yang, Kai Fan, Minpeng Liao

Abstract

Chain of Thought (CoT) of multi-step benefits from the logical structure of the reasoning steps and task-specific actions, significantly enhancing the mathematical reasoning capabilities of large language models. As the prevalence of long CoT, the number of reasoning steps exceeds manageable token limits and leads to higher computational demands. Inspired by the fundamental logic of human cognition, "derive, then reduce", we conceptualize the standard multi-step CoT as a novel Markov Chain of Thought (MCoT). In this study, we consider the mathematical reasoning task, defining each reasoning step as text accompanied by a Python code snippet. To facilitate a longer reasoning path, self-correction is enabled through interactions with the code interpreter. Our MCoT aims to compress previous reasoning steps into a simplified question, enabling efficient next-step inference without relying on a lengthy KV cache. In our experiments, we curate the $\texttt{MCoTInstruct}$ dataset, and the empirical results indicate that MCoT not only significantly enhances efficiency but also maintains comparable accuracy. While much remains to be explored, this work paves the way for exploring the long CoT reasoning abilities of LLMs.

Introduction

Standard Chain of Thought (CoT) prompting has revolutionized how Large Language Models (LLMs) handle complex tasks. However, it faces a major scalability challenge: as the reasoning path lengthens, the Key-Value (KV) cache grows, leading to linear or quadratic increases in computational cost and memory usage. Furthermore, long reasoning chains are prone to "hallucination drift," where early errors accumulate. Existing Multi-Step Reasoning (MSR) methods using code interpreters help but still suffer from long-context inefficiencies. This research introduces Markov Chain of Thought (MCoT) to address these issues by enabling deep reasoning without the overhead of exhaustive context.

Methodology: The Markovian Approach

MCoT is inspired by the human cognitive loop of "derive, then reduce." Unlike traditional CoT, which appends new thoughts to an ever-growing prompt, MCoT treats reasoning as a sequence of independent state transitions following the Markov property: the future depends only on the current state.

Comparison of reasoning paradigms: Multi-Step Reasoning, Question Decomposition, and Markov Chain of Thought.

The process involves three main stages:

  1. Derivation: The model generates a reasoning step with natural language and a Python code snippet.
  2. Reduction: The model generates a simplified version of the original question based on the previous step's results.
  3. State Transition: The old context is discarded, clearing the KV cache, and the model starts fresh with the simplified question.

To support this, the authors developed MCoTInstruct, a dataset of 82,000 Markov chains derived from GSM8K and MATH. It also includes a self-correction mechanism where code execution errors are fed back into the next reduction step.

Experimental Results

The empirical evaluation demonstrates that MCoT achieves significant efficiency gains while maintaining high accuracy across various benchmarks, including GSM8K, MATH, OCWCourses, and GaoKao2023-Math-En.

Efficiency and Scalability

MCoT provides a 1.90x speedup in inference compared to traditional multi-step reasoning. By clearing the KV cache after each reduction, the prompt length remains stable (typically under 512 tokens), whereas traditional MSR prompts can exceed 2,000 tokens by the seventh step.

Reasoning cost comparison: MCoT maintains a constant cost per step, while traditional Multi-Step Reasoning costs grow linearly.

Accuracy and Generalization

On the challenging MATH benchmark, MCoT-DeepSeek (7B) achieved a solve rate of 55.8%, outperforming larger models like Llama-3 70B. Notably, MCoT showed a clear advantage in "Level 5" problems, suggesting that the "derive and reduce" strategy is particularly effective for high-complexity tasks.

Discussion and Future Work

While MCoT offers substantial efficiency, it faces risks of information loss during the reduction phase. If a simplified question omits critical details, the model cannot "look back" to recover them. Future research aims to integrate Monte Carlo Tree Search (MCTS) with MCoT to allow for exploration of multiple reduction paths and backtracking, combining Markovian efficiency with global search robustness.

Summary updated

Abstract

Chain of Thought (CoT) of multi-step benefits from the logical structure of the reasoning steps and task-specific actions, significantly enhancing the mathematical reasoning capabilities of large language models. As the prevalence of long CoT, the number of reasoning steps exceeds manageable token limits and leads to higher computational demands. Inspired by the fundamental logic of human cognition, "derive, then reduce", we conceptualize the standard multi-step CoT as a novel Markov Chain of Thought (MCoT). In this study, we consider the mathematical reasoning task, defining each reasoning step as text accompanied by a Python code snippet. To facilitate a longer reasoning path, self-correction is enabled through interactions with the code interpreter. Our MCoT aims to compress previous reasoning steps into a simplified question, enabling efficient next-step inference without relying on a lengthy KV cache. In our experiments, we curate the $\texttt{MCoTInstruct}$ dataset, and the empirical results indicate that MCoT not only significantly enhances efficiency but also maintains comparable accuracy. While much remains to be explored, this work paves the way for exploring the long CoT reasoning abilities of LLMs. The code is available at https://github.com/james-yw/Markov-Chain-of-Thought
BibTeX
@inproceedings{yang2025markov,
  author = {Wen Yang and Kai Fan and Minpeng Liao},
  title = {{Markov Chain of Thought for Efficient Mathematical Reasoning}},
  booktitle = {Conference of the North American Chapter of the Association for Computational Linguistics},
  year = {2025},
  doi = {10.18653/v1/2025.naacl-long.365},
}
Figure