Skip to main content
The user starts the workflow; agents generate, evaluate, and upload chain-of-thought training data.

What is Chain-of-Thought Generation?

Chain-of-Thought (CoT) Generation is a process where AI agents create detailed, step-by-step reasoning paths for solving problems. This involves generating questions, evaluating them, producing detailed solution steps, and making the data available for training and analysis.

How It Works

The user starts the workflow; the generator creates Q&A pairs, the CoT agent expands each into reasoning steps, and the uploader publishes the dataset.

Quick Start

1

Install Package

First, install the PraisonAI Agents package:
2

Set API Key

Set your OpenAI API key as an environment variable in your terminal:
3

Create a file

Create a new file app.py with the basic setup:
4

Run the application

Execute the Python script to start generating chain-of-thought data:

Features

Question Generation

Create challenging math and logic questions with answers.

Question Evaluation

Evaluate and validate generated questions for quality.

CoT Solutions

Generate detailed chain-of-thought solutions for each question.

Data Management

Save and manage generated data in structured formats.

HuggingFace Integration

Upload datasets directly to HuggingFace for sharing.

Understanding the Workflow

Question Generator

Creates unique math and logic questions with answers. Uses write_csv and count_questions tools.

Questions Evaluator

Validates the total number of generated questions. Uses count_questions tool.

CoT Generator

Produces detailed step-by-step solutions. Uses cot_save tool for solution management.

HuggingFace Uploader

Publishes datasets to HuggingFace. Uses cot_upload_to_huggingface tool.
Used in question generation and evaluation phases.
Decision Task Example
Conditions determine whether to continue generating or move forward. The task can loop back to itself or proceed to the next task.
Each task type serves a specific purpose in the workflow:
  • Decision Tasks: Control flow and branching logic
  • Loop Tasks: Process data iteratively with validation

Next Steps

Introduction

Learn more about PraisonAI and its core concepts

Quick Start

Get started with the basics of PraisonAI

Best Practices

Loop tasks that produce chain-of-thought data should always set output_pydantic to a model like DecisionModel. Structured validation rejects malformed reasoning before it reaches your dataset, keeping training data consistent and machine-parseable.
Route generated question–answer pairs through an evaluator agent ahead of the CoT generator. A cheap evaluation pass filters low-quality or ambiguous items early, so expensive reasoning generation runs only on data worth keeping.
Decision tasks branch the workflow (continue generating vs. move on) based on the model’s response. Define clear stop conditions so the CoT generator loops enough times to build depth without running away — pair this with a target count check on your CSV.
Set OPENAI_API_KEY and HF_TOKEN as environment variables rather than in code, so datasets can be regenerated and uploaded from CI without editing the script.

Enable step-by-step reasoning inside a single agent run.

Compose multi-agent generate–evaluate–upload pipelines.