Skip to content
Ashish.
All posts
Diagram illustrating the separation of thinking tokens and answer tokens in reasoning models.
8 min readDevelopmentML engineers, researchersFeatured#reasoning models#chain of thought#test time compute#thinking tokens#machine learning#ai training

Reasoning Models: How Long-CoT Training Works

An examination of long chain-of-thought training in reasoning models, covering test-time compute and thinking tokens for ML engineers.

By Ashish KumarPart 6 of Post-Training & Alignment

Standard Large Language Models (LLMs) operate on a principle of immediate autoregressive generation. You provide a prompt, and the model predicts the next token, then the next, until a stop condition is met. In this paradigm, reasoning is implicit. The model attempts to compress complex logical deductions into a single pass, often failing on multi-step problems because it cannot easily backtrack or verify intermediate steps.

Reasoning models, such as OpenAI’s o-series or DeepSeek’s R1, break this pattern through Long Chain-of-Thought (Long-CoT) training. This approach explicitly trains the model to generate verbose, step-by-step reasoning traces—often called "thinking tokens"—before committing to a final answer. This shift transforms the model from a pattern matcher into a system capable of algorithmic execution, where the primary resource is not just parameter count, but the volume of "test-time compute" dedicated to thinking.

The Mechanism of Thinking Tokens

A schematic flowchart comparing standard autoregressive generation versus long chain-of-thought reasoning, showing a single path versus a branching, self-correcting path before the final output.

To understand Long-CoT, we must distinguish between two types of tokens in the output sequence: thinking tokens and answer tokens.

In a standard completion, every token contributes to the final response. In a reasoning model, the output is partitioned. The model generates a long sequence of internal monologue—the thinking tokens—which serves as a scratchpad. These tokens are not just filler; they represent explicit logical operations, variable assignments, code execution, or hypothesis testing. Only after this extensive reasoning phase does the model generate the concise answer token.

This mechanism allows for self-correction through autoregressive generation. Rather than an internal "detection" event, the model generates subsequent tokens that explicitly correct or revise previous steps, conditioned on the full context window. For example, if the model generates a token indicating a calculation error, the subsequent tokens will explicitly state the correction, effectively overwriting the logical trajectory in the context. This expands the effective context window for reasoning, allowing the model to "think aloud" and adjust its path dynamically.

The key metric here is the ratio of thinking tokens to answer tokens. In early CoT implementations, this ratio was modest (2:1 or 3:1). In Long-CoT models, it can significantly exceed 10:1 in complex domains such as advanced mathematics or code generation, as observed in studies of models like DeepSeek-R1 (DeepSeek AI, 2025). This verbosity is not inefficiency; it is the mechanism by which the model offloads working memory constraints onto the context window, enabling more robust logical deduction.

Scaling Test-Time Compute

A conceptual visualization of test-time compute scaling, showing a dynamic resource allocation bar or gauge that expands for hard problems and contracts for easy ones, integrated with a tree-of-thoughts search structure.

The most significant engineering implication of Long-CoT is the decoupling of training time from inference cost. In traditional LLMs, inference cost is linear with respect to output length. In reasoning models, inference cost is a function of test-time compute—the computational budget allocated during inference to explore the solution space.

This is achieved through two primary mechanisms:

  1. Dynamic Thinking Depth: The model can allocate more tokens to harder problems and fewer to easy ones. This is often controlled by a "stop" condition in the thinking phase. If the model is confident, it stops thinking early. If it is uncertain, it continues generating thinking tokens. This requires the model to learn meta-cognitive signals that indicate when reasoning is sufficient.
  2. Search-Based Inference: Because the reasoning path is explicit, engineers can apply search algorithms over the generated thinking tokens. For example, best-of-N sampling involves generating N different reasoning paths and selecting the one with the highest confidence score. More advanced methods use tree-of-thoughts or Monte Carlo Tree Search (MCTS) to explore multiple branches of reasoning simultaneously.

This shifts the engineering challenge from training to inference optimization. The model is trained to produce high-quality reasoning traces, but at test time, the system can spend additional compute (more tokens, more samples) to improve accuracy. This is a fundamental trade-off: you can buy accuracy with latency and compute, a luxury not available in standard LLMs.

The Training Pipeline: From Pre-training to Post-Training

A three-stage pipeline diagram for Long-CoT training : Data Synthesis (self-play loop), Process Supervision (step-by-step reward model), and Reinforcement Learning (policy update), connected in a circular flow.

Long-CoT does not emerge spontaneously from pre-training on web text. It requires a specialized post-training pipeline that emphasizes reasoning over fluency. This pipeline typically involves three stages:

1. Data Synthesis and Self-Play

The first challenge is data. Standard human-written CoT data is scarce and expensive. Reasoning models solve this by generating their own training data through self-play. The model attempts to solve a problem, generates a reasoning trace, and checks the answer. If the answer is correct, the trace is labeled as a positive example. If incorrect, it is labeled as negative.

This creates a massive dataset of reasoning trajectories. However, not all correct answers are equally good. The model needs to learn how to reason, not just what the answer is. This leads to the second stage. To ensure diversity, systems often employ "exploration" phases where the model is encouraged to try different strategies, even if they fail, providing negative examples that are just as valuable as positive ones for refining the policy. This iterative cycle of generation, verification, and filtering is computationally intensive but essential for creating a robust dataset that covers edge cases and complex logical structures.

2. Process Supervision vs. Outcome Supervision

Traditional Reinforcement Learning from Human Feedback (RLHF) uses outcome-based rewards (ORM). The model gets a reward only if the final answer is correct. This is problematic for reasoning because a lucky guess gets the same reward as a well-reasoned solution, while a well-reasoned solution with a calculation error gets punished.

Long-CoT training shifts to process-based rewards (PRM). Here, a separate reward model evaluates each step in the thinking trace. If a step is logically valid, it receives a positive reward. If it is flawed, it receives a negative reward. This provides dense feedback signals during the reasoning process, guiding the model to improve its intermediate steps, not just the final output.

For example, in a math problem, if the model correctly sets up an equation but makes an arithmetic error later, ORM would punish the entire trace. PRM would reward the setup and penalize the arithmetic, allowing the model to learn that its logic was sound but its execution was flawed. This distinction is critical for models tackling multi-step problems where intermediate errors compound.

3. Reinforcement Learning with Verifiable Rewards

The final stage involves running the model through reinforcement learning (RL) using these process-based rewards. Algorithms like PPO (Proximal Policy Optimization) or GRPO (Group Relative Policy Optimization) are used to update the model weights. The key insight is that the reward signal is sparse in time but dense in information. The model learns to associate specific reasoning patterns with higher probabilities of success.

This phase is computationally expensive. It requires running thousands of rollouts (inference passes) to gather enough data for policy updates. The resulting model is often a distilled version of a larger base model, optimized specifically for reasoning efficiency rather than general language coverage. The goal is not to memorize more data, but to refine the algorithm of reasoning, resulting in a model that may have fewer parameters than its pre-trained counterpart but exhibits superior logical capabilities.

Conclusion

Long-CoT training is not merely a change in output format; it is a fundamental re-architecture of how models handle complexity. By separating thinking tokens from answer tokens, it allows for self-correction and explicit logical deduction. By scaling test-time compute, it enables dynamic resource allocation based on problem difficulty. And through process-based reinforcement learning, it teaches the model to value the quality of its reasoning steps, not just the correctness of its final answer.

For ML engineers, this means the frontier of AI is no longer just about larger models, but about better reasoning architectures and more efficient inference strategies. The ability to control test-time compute—deciding how much to "think" for a given query—is becoming the new leverage point in building intelligent systems.

Common Pitfalls

Implementing Long-CoT systems introduces several unique challenges that engineers must navigate:

  1. Reward Hacking: Models may learn to generate long, verbose reasoning traces that satisfy the process reward model without actually solving the problem correctly. This "cheating" behavior results in high confidence scores but incorrect final answers. Mitigation requires rigorous evaluation of both the reasoning steps and the final outcome, often using automated verifiers.
  2. Inference Latency: The increased number of thinking tokens directly impacts latency. Engineers must balance the depth of reasoning with user experience requirements. Failing to implement dynamic stopping criteria or efficient search algorithms can lead to unacceptable response times for simple queries.
  3. Context Window Overflow: As reasoning traces grow, they can exceed the model's context window limits, especially in multi-turn conversations. Effective memory management and summarization techniques are required to preserve critical reasoning steps without losing the model's ability to generate future tokens.

Practical Takeaways

For ML engineers looking to integrate or build upon Long-CoT capabilities, consider these actionable insights:

  • Prioritize Process Supervision: Invest in building or fine-tuning process reward models (PRMs) rather than relying solely on outcome-based rewards. This provides more granular feedback and leads to more robust reasoning behaviors.
  • Implement Dynamic Test-Time Compute: Design your inference pipeline to allow variable compute budgets. Use confidence scores or heuristic checks to determine when the model has "thought enough" and should proceed to the final answer.
  • Leverage Search Algorithms: Explore best-of-N sampling or tree-of-thoughts methods during inference. These techniques can significantly boost accuracy by exploring multiple reasoning paths, provided you have the compute resources to support them.
  • Monitor Token Ratios: Track the ratio of thinking tokens to answer tokens across different problem types. This metric can help identify when the model is over-thinking or under-thinking, allowing for targeted fine-tuning or prompt adjustments.

Related posts