Chain-of-Thought Tokens are Computer Program Variables

Fangwei Zhu, Peiyi Wang, Zhifang Sui
5/8/2025
cs.CLcs.AI

Official code: solitaryzero/CoTs_are_Variables (5 stars, MIT, last commit 2025-12-13).

Abstract

Chain-of-thoughts (CoT) requires large language models (LLMs) to generate intermediate steps before reaching the final answer, and has been proven effective to help LLMs solve complex reasoning tasks. However, the inner mechanism of CoT still remains largely unclear. In this paper, we empirically study the role of CoT tokens in LLMs on two compositional tasks: multi-digit multiplication and dynamic programming. While CoT is essential for solving these problems, we find that preserving only tokens that store intermediate results would achieve comparable performance. Furthermore, we observe that storing intermediate results in an alternative latent form will not affect model performance. We also randomly intervene some values in CoT, and notice that subsequent CoT tokens and the final answer would change correspondingly. These findings suggest that CoT tokens may function like variables in computer programs but with potential drawbacks like unintended shortcuts and computational complexity limits between tokens. The code and data are available at https://github.com/solitaryzero/CoTs_are_Variables.

View on arXivView PDF

Code Implementations(1)

MIT

Repository for paper "Chain-of-Thought Tokens are Computer Program Variables"

52Shell, PythonMay 7, 202510 months agoMIT

Similar Papers

Cite this paper

@article{zhu2025chainofthought,
  title  = {Chain-of-Thought Tokens are Computer Program Variables},
  author = {Fangwei Zhu and Peiyi Wang and Zhifang Sui},
  year   = {2025},
  eprint = {2505.04955},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2505.04955v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2505.04955.svg)](https://codeofpaper.com/paper/2505.04955)

Discussion