Table of Contents
Fetching ...

Causal Language Modeling Can Elicit Search and Reasoning Capabilities on Logic Puzzles

Kulin Shah, Nishanth Dikkala, Xin Wang, Rina Panigrahy

TL;DR

This work investigates whether causal language modeling with Transformers can learn search and reasoning for complex logic puzzles. By training on solver-decomposed sequences that separate search from value deduction, the model solving Sudoku and Zebra puzzles achieves high success rates, with beam search and hints further boosting performance. Probing reveals that candidate-set information emergently aligns with solver reasoning, suggesting a latent reasoning engine within the weights. The study highlights the potential of decomposed training data to unlock nontrivial planning capabilities in standard next-token prediction frameworks, while acknowledging limitations due to the synthetic nature of the tasks and the scope of reasoning involved.

Abstract

Causal language modeling using the Transformer architecture has yielded remarkable capabilities in Large Language Models (LLMs) over the last few years. However, the extent to which fundamental search and reasoning capabilities emerged within LLMs remains a topic of ongoing debate. In this work, we study if causal language modeling can learn a complex task such as solving Sudoku puzzles. To solve a Sudoku, the model is first required to search over all empty cells of the puzzle to decide on a cell to fill and then apply an appropriate strategy to fill the decided cell. Sometimes, the application of a strategy only results in thinning down the possible values in a cell rather than concluding the exact value of the cell. In such cases, multiple strategies are applied one after the other to fill a single cell. We observe that Transformer models trained on this synthetic task can indeed learn to solve Sudokus (our model solves $94.21\%$ of the puzzles fully correctly) when trained on a logical sequence of steps taken by a solver. We find that training Transformers with the logical sequence of steps is necessary and without such training, they fail to learn Sudoku. We also extend our analysis to Zebra puzzles (known as Einstein puzzles) and show that the model solves $92.04 \%$ of the puzzles fully correctly. In addition, we study the internal representations of the trained Transformer and find that through linear probing, we can decode information about the set of possible values in any given cell from them, pointing to the presence of a strong reasoning engine implicit in the Transformer weights.

Causal Language Modeling Can Elicit Search and Reasoning Capabilities on Logic Puzzles

TL;DR

This work investigates whether causal language modeling with Transformers can learn search and reasoning for complex logic puzzles. By training on solver-decomposed sequences that separate search from value deduction, the model solving Sudoku and Zebra puzzles achieves high success rates, with beam search and hints further boosting performance. Probing reveals that candidate-set information emergently aligns with solver reasoning, suggesting a latent reasoning engine within the weights. The study highlights the potential of decomposed training data to unlock nontrivial planning capabilities in standard next-token prediction frameworks, while acknowledging limitations due to the synthetic nature of the tasks and the scope of reasoning involved.

Abstract

Causal language modeling using the Transformer architecture has yielded remarkable capabilities in Large Language Models (LLMs) over the last few years. However, the extent to which fundamental search and reasoning capabilities emerged within LLMs remains a topic of ongoing debate. In this work, we study if causal language modeling can learn a complex task such as solving Sudoku puzzles. To solve a Sudoku, the model is first required to search over all empty cells of the puzzle to decide on a cell to fill and then apply an appropriate strategy to fill the decided cell. Sometimes, the application of a strategy only results in thinning down the possible values in a cell rather than concluding the exact value of the cell. In such cases, multiple strategies are applied one after the other to fill a single cell. We observe that Transformer models trained on this synthetic task can indeed learn to solve Sudokus (our model solves of the puzzles fully correctly) when trained on a logical sequence of steps taken by a solver. We find that training Transformers with the logical sequence of steps is necessary and without such training, they fail to learn Sudoku. We also extend our analysis to Zebra puzzles (known as Einstein puzzles) and show that the model solves of the puzzles fully correctly. In addition, we study the internal representations of the trained Transformer and find that through linear probing, we can decode information about the set of possible values in any given cell from them, pointing to the presence of a strong reasoning engine implicit in the Transformer weights.
Paper Structure (45 sections, 9 figures, 5 tables)

This paper contains 45 sections, 9 figures, 5 tables.

Figures (9)

  • Figure 1: An example Zebra puzzle with 3 entities, each having 3 attributes.
  • Figure 2: Examples of complex strategies that involves reasoning about multiple cells. Left: XY-Wing, where a pivot cell (gray) has two candidate values (X and Y), the wing cells (green) share a column, row or box with the pivot and share one candidate value (X or Y) with pivot and another common candidate value (Z), then in any cell that shares a column, row or box with both wing cells (yellow), we can eliminate Z from the candidate set; Right: Unique Rectangle, where four cells form a rectangle, among which three cells (gray) share the exact same 2 candidate values, and the fourth cell (green) share at least one of the 2 values, then both values can be eliminated from the candidate set for the fourth cell.
  • Figure 3: Comparison of cell accuracy and full puzzle accuracy for fixed order training, random order training and solver-decomposed reasoning order training.
  • Figure 4: Complete puzzle accuracy for different difficulty Sudoku puzzles. The difficulty rating is computed as the average number of guesses the rating-solver had to make to solve the puzzle therefore, the difficulty rating is an imperfect measure of the difficulty.
  • Figure 5: A failure case of the model in searching for easy-to-decode cells. The left figure shows the sudoku puzzle state when the model makes the first mistake and the right figure shows the puzzle's solution. Numbers given in the blue are provided in the puzzle. The puzzle makes a mistake by choosing to fill the red-colored cell whereas the green background cell can be easily filled.
  • ...and 4 more figures