Teaching Transformers to Solve Combinatorial Problems through Efficient Trial & Error
Panagiotis Giannoulis, Yorgos Pantis, Christos Tzamos
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. 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.
Ask about this paper
Your agent reads all of it.
Lune indexed this paper to the last equation, along with the top-tier papers that cite it. Ask a question and the answer quotes them.
Cited by top-tier papers2
- HONet: Data-Efficient Learning for Exact Cover Tasks via Hypergraph OptimizationPengyang Huang, Zirui Zhuang, Haifeng Sun, Qi Qi et al.ICML 2026
- The Expressive Power of Low Precision Softmax Transformers with (Summarized) Chain-of-ThoughtMoritz Brösamle, Stephan EcksteinICML 2026
Builds on27
- Language Models are Few-Shot LearnersTom B. Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah et al.NeurIPS 2020 · 64,255 citations
- Tree of Thoughts: Deliberate Problem Solving with Large Language ModelsShunyu Yao, Dian Yu, Jeffrey Zhao, Izhak Shafran et al.NeurIPS 2023 · 5,068 citations
- Self-Refine: Iterative Refinement with Self-FeedbackAman Madaan, Niket Tandon, Prakhar Gupta, Skyler Hallinan et al.NeurIPS 2023 · 4,972 citations
- Graph of Thoughts: Solving Elaborate Problems with Large Language ModelsMaciej Besta, Nils Blach, Ales Kubicek, Robert Gerstenberger et al.AAAI 2024 · 1,292 citations
- Faith and Fate: Limits of Transformers on CompositionalityNouha Dziri, Ximing Lu, Melanie Sclar, Xiang Lorraine Li et al.NeurIPS 2023 · 728 citations
Related papers
- Causal language modeling can elicit search and reasoning capabilities on logic puzzlesKulin Shah, Nishanth Dikkala, Xin Wang, Rina PanigrahyNeurIPS 2024 · 44 citations
- Assessing SATNet's Ability to Solve the Symbol Grounding ProblemOscar Chang, Lampros Flokas, Hod Lipson, Michael SprangerNeurIPS 2020 · 25 citations
- Techniques for Symbol Grounding with SATNetSever Topan, David Rolnick, Xujie SiNeurIPS 2021 · 32 citations
- TrustTable: A Neuro-Symbolic Auditing Framework for Faithful Table QAGuangzhen Zhao, Dechang Kong, Tongyu Wu, Zhenjiang DongACL 2026
- VeriSimpl: Robust Optimization Modeling from Natural Language using Simplification-based VerificationSumaya Abdul Rahman, Seckhen Cuellar, Ghani Raissov, Mohammad RazaICML 2026 · 1 citation
