Compressed Chain of Thought: Efficient Reasoning Through Dense Representations

Jeffrey Cheng, Benjamin Van DurmearXiv 2024 · arXiv · OpenReview

TL;DR

This paper introduces Compressed Chain-of-Thought (CCoT), a novel method for improving Large Language Model (LLM) reasoning by generating "contemplation tokens." These tokens are compressed, continuous representations of reasoning steps, offering a more efficient alternative to traditional, verbose Chain-of-Thought (CoT) prompting, leading to improved accuracy with minimal latency increase.

What Problem Does This Paper Address?

Large Language Models (LLMs) often struggle with complex reasoning tasks. While Chain-of-Thought (CoT) prompting, where the model explicitly "thinks out loud" by generating intermediate reasoning steps, significantly improves performance, it comes at a substantial cost: increased generation latency. For instance, a GPT-4o response can take up to 10x longer with CoT. Existing methods to mitigate this latency, like "filler tokens" or "pause tokens," often use discrete, non-contentful tokens and don't fully leverage the potential for richer, compressed reasoning. This paper aims to bridge this gap by proposing a method that generates contentful, continuous contemplation tokens that are compressed representations of reasoning chains, thereby achieving better reasoning performance with significantly reduced latency.

Methods

The core innovation is the Compressed Chain-of-Thought (CCoT) framework. CCoT trains two modules:

  1. CCOT Module: This module is responsible for generating the "contemplation tokens." Unlike previous approaches that used discrete tokens, CCoT generates continuous, dense representations. These tokens are trained to approximate a compressed version of the hidden states that would correspond to a full reasoning chain. The training involves teacher forcing, where the model learns to generate these compressed representations based on gold hidden states derived from actual reasoning chains.
  2. DECODE Module: This module takes the original query and the generated CCoT tokens to produce the final answer. It's finetuned to effectively condition on these compressed representations.

A key aspect is the variable compression ratio (r). This parameter allows users to control the trade-off between accuracy and efficiency. A higher r means a less compressed representation (closer to full CoT), leading to potentially higher accuracy but also more computation. A lower r means more compression, resulting in faster inference but potentially slightly lower accuracy. CCoT can be adapted to off-the-shelf decoder-only LLMs using LoRA finetuning.

Datasets

  • GSM8K: This dataset was used for both training and evaluation. The reasoning chains provided with the dataset were utilized for training the CCOT and DECODE modules. Calculator annotations were removed from these chains to focus on natural language reasoning.

Key Insights and Ideas

  • Contentful, Continuous Contemplation Tokens: The paper argues that using dense, continuous representations of reasoning steps (rather than discrete filler tokens) is crucial for achieving significant reasoning improvements. These tokens are "contentful" because they are derived from actual reasoning processes.
  • Compression as a Trade-off: CCoT frames reasoning as a performance-efficiency trade-off that can be adaptively controlled. The compression ratio r allows for on-demand adjustment, enabling users to balance accuracy needs with latency constraints.
  • Autoregressive Generation for Depth: CCoT generates contemplation tokens autoregressively, which, according to the paper's theoretical considerations, allows for increased computational depth in reasoning, complementing the width provided by parallel token generation. This is particularly beneficial for tasks requiring multi-hop reasoning or sequential decision-making.
  • Intermediate Layer Importance: The authors found that using hidden states from intermediate layers (around L/2) of the Transformer for generating contemplation tokens yields better results than using the very first or very last layers. This suggests these intermediate layers capture a good balance of localized and global information.

Key Results

  • Accuracy Improvement: CCoT achieved significant accuracy improvements on the GSM8K dataset. With a compression ratio of r=0.10, CCoT showed a 9-point accuracy gain over a baseline with no contemplation tokens. Even with a lower ratio (r=0.05), a 6-point improvement was observed.
  • Minimal Latency Increase: These accuracy gains were achieved with only a small increase in decode time. For r=0.10, the decode time increased by only 0.4 seconds.
  • Comparison to PAUSE: CCoT outperformed PAUSE, a method using discrete "pause tokens," which only showed nominal performance improvements. This highlights the advantage of CCoT's contentful and continuous approach.
  • Scalability: The method demonstrated better scalability to larger models and data efficiency compared to prior work.

Limitations and Future Work

  • Subset Selection: While the paper uses a learned scorer for selecting gold hidden states, they note that simply taking evenly spaced tokens yielded similar performance. They hypothesize that a better scorer could lead to lossless performance even with higher compression, suggesting future work in optimizing this selection process.
  • Hyperparameter Sensitivity: The choice of the autoregressive layer l was found to be important, with intermediate layers performing best. The authors suggest further exploration of optimal layer choices.
  • Theoretical Generalization: The paper extends theoretical results on contemplation tokens, but further formalization and exploration of the computational capacity of CCOT tokens are suggested.
  • Adaptive Stopping: While CCOT uses a compression ratio r for training, the inference process can be further refined with adaptive stopping mechanisms for contemplation token generation.

Summary updated

Abstract

Chain-of-thought (CoT) decoding enables language models to improve reasoning performance at the cost of high generation latency in decoding. Recent proposals have explored variants of contemplation tokens, a term we introduce that refers to special tokens used during inference to allow for extra computation. Prior work has considered fixed-length sequences drawn from a discrete set of embeddings as contemplation tokens. Here we propose Compressed Chain-of-Thought (CCoT), a framework to generate contentful and continuous contemplation tokens of variable sequence length. The generated contemplation tokens are compressed representations of explicit reasoning chains, and our method can be applied to off-the-shelf decoder language models. Through experiments, we illustrate how CCoT enables additional reasoning over dense contentful representations to achieve corresponding improvements in accuracy. Moreover, the reasoning improvements can be adaptively modified on demand by controlling the number of contemplation tokens generated.
BibTeX
@misc{cheng2024compressed,
  author = {Jeffrey Cheng and Benjamin Van Durme},
  title = {{Compressed Chain of Thought: Efficient Reasoning Through Dense Representations}},
  year = {2024},
  eprint = {2412.13171},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2412.13171},
}
Figure