Teaching Transformers to Solve Combinatorial Problems through Efficient Trial & Error

Panagiotis Giannoulis, Yorgos Pantis, Christos Tzamos
9/1/2025
transformer-attention

No confident code implementation found for this paper.

Abstract

Despite their proficiency in various language tasks, Large Language Models (LLMs) struggle with combinatorial problems like Satisfiability, Traveling Salesman Problem, or even basic arithmetic. We address this gap through a novel trial&error approach for solving problems in the class NP, where candidate solutions are iteratively generated and efficiently validated using verifiers.

Show full abstract

We focus on the paradigmatic task of Sudoku and achieve state-of-the-art accuracy (99%) compared to prior neuro-symbolic approaches. Unlike prior work that used custom architectures, our method employs a vanilla decoder-only Transformer (GPT-2) without external tools or function calling. Our method integrates imitation learning of simple Sudoku rules with an explicit Depth-First Search (DFS) exploration strategy involving informed guessing and backtracking. Moving beyond imitation learning, we seek to minimize the number of guesses until reaching a solution. This is achieved using depth-1 guessing, showing empirically that almost all Sudoku can be solved using the puzzle's rules with at most one guess. We provide a rigorous analysis of this setup formalizing its connection to a contextual variant of Min-Sum Set Cover, a well-studied problem in algorithms and stochastic optimization.

View on arXivView PDF

Code Implementations

No confident code match yet

We couldn't find an author-owned or strongly-evidenced community implementation for this paper. Any repos shown below are weak matches — verify before relying on them.

No code implementations found yet.

Know of an implementation? Let us know in the comments below!

Similar Papers

Cite this paper

@article{giannoulis2025teaching,
  title  = {Teaching Transformers to Solve Combinatorial Problems through Efficient Trial & Error},
  author = {Panagiotis Giannoulis and Yorgos Pantis and Christos Tzamos},
  year   = {2025},
  eprint = {2509.22023},
  archivePrefix = {arXiv},
  doi    = {10.48550/arXiv.2509.22023},
  url    = {https://doi.org/10.48550/arXiv.2509.22023},
  journal = {Neural Information Processing Systems}
}

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/2509.22023.svg)](https://codeofpaper.com/paper/2509.22023)

Discussion