Skip to main content
The user poses a multi-step problem; the agent records chain-of-thought steps before answering.

Chain-of-Thought Tools

The Chain-of-Thought (CoT) tools enable AI agents to generate step-by-step reasoning paths for problem-solving and create synthetic reasoning data for training purposes. These tools help break down complex problems into manageable steps and document the reasoning process.

Quick Start

1

Install

2

Enable chain-of-thought reasoning

Overview

Chain-of-Thought reasoning is a technique where AI models explicitly show their step-by-step thinking process when solving problems. This approach improves accuracy, provides transparency, and generates valuable training data for improving AI models.

Installation

The Chain-of-Thought tools require the following dependencies:

Core Functions

cot_save

Saves chain-of-thought solutions to a CSV file for further analysis or training data generation.

cot_upload_to_huggingface

Uploads your chain-of-thought dataset to Hugging Face Hub for sharing or model training.

Usage Examples

Basic Chain-of-Thought Generation

Structured Reasoning with Pydantic Models

Multi-Agent Reasoning System

Configuration

Environment Variables

Custom Configuration

Advanced Features

Batch Processing

Quality Metrics

Integration with Training Pipelines

GenerateCOT Class - Advanced Training Data Generation

The GenerateCOT class provides specialized functionality for generating Chain-of-Thought training data from question-answer pairs.

Basic Usage

The GenerateCOT class requires Q&A pairs to be provided upfront. It does not generate questions automatically.

Class Methods

Initialize GenerateCOT

Core Methods

  1. cot_run(question: str) -> str - Generate solution as string
  2. cot_run_dict(question: str) -> dict - Generate solution with structured output
  3. cot_generate(question: str, context: str = "") -> str - Generate with context
  4. cot_generate_dict(question: str, context: str = "") -> dict - Generate structured with context
  5. cot_check(question: str, answer: str) -> bool - Verify if answer is correct
  6. cot_find_error(question: str, current: str) -> str - Find errors in solution
  7. cot_improve(question: str, current: str) -> str - Improve existing solution

Export Methods

Complete Example: Math Training Data

Working with Different Question Types

Loading and Improving Existing Solutions

Important Differences from Documentation Examples

Integration with Agents

Best Practices

Always provide clear, unambiguous problem descriptions
Include all intermediate steps, even seemingly obvious ones
Use consistent structure across all reasoning examples
Include examples of common mistakes and their corrections
Cover a wide range of problem types and difficulty levels
Always include a verification step to check the answer
Track model parameters and conditions for each example
Prepare comprehensive Q&A pairs before using GenerateCOT
Use lower temperature (0.3-0.5) for factual content, higher (0.7-0.9) for creative solutions

Common Use Cases

Educational Content Generation

Debugging and Error Analysis

Troubleshooting

Common Issues

  1. CSV Encoding Errors
  2. Large Dataset Handling
  3. Hugging Face Upload Failures
For more examples and integration patterns, see the Generate Reasoning documentation.

Custom Tools

Build your own agent tools

Tools Overview

Browse PraisonAI tool documentation