Skip to content
Go back 2502.09061 arXiv logo

CRANE: Reasoning with constrained LLM generation

Published:  at  11:08 AM
61.03 🤔

This paper introduces CRANE, a reasoning-augmented constrained decoding algorithm that alternates between unconstrained and constrained generation to preserve LLM reasoning capabilities while ensuring syntactic correctness, achieving up to 10% accuracy improvement on symbolic reasoning benchmarks like GSM-Symbolic and FOLIO.

Large Language Model, Reasoning, Constrained Decoding, Symbolic Reasoning, Grammar Augmentation

Debangshu Banerjee, Tarun Suresh, Shubham Ugare, Sasa Misailovic, Gagandeep Singh

University of Illinois Urbana-Champaign

Generated by grok-3

Background Problem

Large Language Models (LLMs) are increasingly integrated with traditional software tools (e.g., Python interpreters, logical solvers) for tasks like code generation and symbolic math reasoning, which require outputs to adhere to specific syntactic and semantic constraints. However, unconstrained LLM outputs often fail to meet these requirements, leading to errors when interfacing with downstream tools. While constrained decoding ensures syntactic correctness by enforcing formal grammars, recent studies have observed a decline in functional correctness due to reduced reasoning capabilities. This paper addresses two key questions: whether LLMs truly lose reasoning abilities under constrained decoding, and how to balance the benefits of constrained decoding with the preservation of reasoning capabilities.

Method

The paper proposes CRANE (Constrained Reasoning Augmented Generation), a decoding algorithm that balances constrained and unconstrained generation to preserve LLM reasoning while ensuring syntactic correctness. The core idea is to theoretically demonstrate that restrictive grammars limit LLM expressivity by preventing intermediate reasoning steps, and to mitigate this by augmenting the grammar with rules that allow reasoning sequences before the final constrained output. Practically, CRANE alternates between unconstrained generation for reasoning and constrained generation for output correctness using delimiters (S1 and S2) to mark transitions. The algorithm initializes with an augmented grammar, starts in unconstrained mode, switches to constrained mode upon detecting the start delimiter, and reverts to unconstrained mode after the end delimiter, ensuring flexibility in reasoning while enforcing structure in the final output.

Experiment

The experiments evaluate CRANE on two benchmarks: GSM-Symbolic for math reasoning and FOLIO for logical reasoning, using multiple open-source LLMs like Qwen2.5 and Llama-3.1. The setup compares CRANE against unconstrained generation (with and without Chain-of-Thought prompting) and state-of-the-art constrained decoding methods (ITERGEN for GSM-Symbolic, SYNCODE for FOLIO), with correctness verified by solvers like Z3 and Prover9. Results show CRANE consistently outperforms baselines, achieving up to 10% accuracy improvement (e.g., 38% vs. 29% for Qwen2.5-Math-7B-Instruct on GSM-Symbolic). Syntactic correctness is also improved, with nearly 100% parseable outputs compared to unconstrained methods. The experimental design is reasonable for the targeted symbolic tasks, though limited to structured domains, and the results match the expectation of balancing reasoning and correctness. However, reliance on specific constrained decoding tools and logits access may limit broader applicability.

Further Thoughts

The theoretical insight that restrictive grammars limit LLM expressivity to lower complexity classes like TC^0 is a significant contribution, as it provides a formal basis for understanding the trade-off between correctness and reasoning. However, I wonder if CRANE’s delimiter-based approach could be extended to tasks beyond symbolic reasoning, such as creative writing or dialogue systems, where reasoning steps are less structured and delimiters harder to define. Could reinforcement learning or meta-learning be used to dynamically learn when to switch between constrained and unconstrained modes without explicit delimiters? Additionally, connecting this work to recent advancements in parameter-efficient fine-tuning, such as Low-Rank Adaptation, might offer a hybrid approach where models are lightly tuned to recognize task-specific constraints while retaining general reasoning abilities. This could address CRANE’s limitation of requiring logits access, potentially making it applicable to black-box commercial models. Lastly, exploring CRANE’s interaction with emergent abilities in larger models could reveal whether scaling laws impact the balance between constrained correctness and reasoning depth.



Previous Post
Unveiling Language-Specific Features in Large Language Models via Sparse Autoencoders
Next Post
How do Humans and Language Models Reason About Creativity? A Comparative Analysis