Enhancing Chain of Thought Prompting in Large Language Models via Reasoning Patterns

Yufeng Zhang, Xuepeng Wang, Lingxiang Wu, Jinqiao Wang

Abstract

Chain-of-Thought (CoT) prompting has significantly advanced the reasoning capabilities of Large Language Models (LLMs). However, existing demonstration selection methods often rely on semantic similarity, which can introduce "semantic noise" and lead to suboptimal reasoning paths. We present Pattern-CoT, a framework that prioritizes the logical structure of problems by clustering demonstrations based on "Reasoning Patterns"—sequences of operation tokens. Our results across eight benchmarks demonstrate that Pattern-CoT consistently outperforms semantic-based methods, showing remarkable robustness even when demonstrations contain errors.

Introduction: The Pitfalls of Semantic Similarity

Chain-of-Thought (CoT) prompting—providing a few step-by-step examples before asking a question—is the gold standard for helping LLMs solve complex tasks. However, choosing which examples to show the model is a significant challenge. Current unsupervised methods typically select demonstrations based on semantic similarity. For instance, if a query involves "buying apples," the system retrieves other "apple" problems.

Comparison between semantic-based prompting (leading to error) and pattern-based prompting (leading to correct answer).

As shown in Figure 1, this approach is often flawed. Two problems can share the same topic but require entirely different logic (e.g., simple addition vs. complex percentage calculation). This "semantic noise" can mislead the model into following an incorrect reasoning path. Furthermore, these methods lack interpretability, making it difficult to understand why specific examples succeed or fail.

Methodology: The Pattern-CoT Framework

To address these issues, we propose Pattern-CoT, a framework that selects demonstrations based on "Reasoning Patterns." The process operates in four distinct stages:

  1. Seed Collection: Initial rationales (step-by-step solutions) are generated for a pool of questions using Zero-Shot CoT ("Let's think step by step").
  2. Pattern Discovery: Task-relevant "operation tokens" are identified. For arithmetic, these include operators like +, -, *, /, or keywords like twice. For logic tasks, tokens might include temporal shifts like yesterday.
  3. Pattern Extraction: For every seed rationale, the sequence of these tokens is extracted to form a "reasoning pattern" (e.g., [+, *, -]).
  4. Diverse Selection via Clustering: Patterns are encoded into vectors and grouped using $k$-means clustering. By selecting one representative from each cluster, we ensure the LLM sees a diverse range of logical strategies.
The Pattern-CoT framework overview, from seed collection to final answer generation.

Crucially, Pattern-CoT employs an adaptive formula for $k$ (the number of demonstrations), which scales based on the number of unique operations identified and the total sample size, moving away from rigid, fixed-size demonstration sets.

Key Results and Insights

Pattern-CoT consistently outperformed baseline methods like Zero-Shot CoT and Auto-CoT across multiple models, including LLaMA-2, GPT-3.5, and Qwen-7B.

  • Performance Gains: On the GSM8K benchmark, Pattern-CoT achieved 28.05% accuracy with LLaMA-2-7B, compared to 21.00% for Zero-Shot and 26.99% for Auto-CoT. Symbolic reasoning tasks like "Coin-Flip" saw even larger jumps, from 44.60% to 59.40%.
  • Robustness to Errors: A surprising finding was that Pattern-CoT works even when demonstrations contain incorrect answers. In the AQuA dataset, selected demonstrations had a 100% error rate, yet the model's performance still improved. This suggests LLMs learn the method of problem-solving from the pattern, rather than just copying the arithmetic.
  • Avoiding Monotonous Reasoning: By clustering patterns, the method prevents the model from being biased toward a single type of solution (e.g., forcing addition onto a subtraction problem).

Conclusion

By prioritizing logical templates over surface-level text, Pattern-CoT mitigates the bias of "monotonous reasoning" and improves the robustness of LLM prompting. While challenges remain for tasks with extremely broad action spaces, this pattern-based approach offers a more interpretable and effective path forward for complex reasoning tasks.

Summary updated

BibTeX
@inproceedings{zhang2025enhancing,
  author = {Yufeng Zhang and Xuepeng Wang and Lingxiang Wu and Jinqiao Wang},
  title = {{Enhancing Chain of Thought Prompting in Large Language Models via Reasoning Patterns}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2025},
  doi = {10.1609/aaai.v39i24.34793},
}
Figure