cs.AIOct 30, 2026

Specification-Guided Generation for Large Language Models

Authors: Alessandro Previti, Konstantinos Vandikas, Mario Alviano, Mats Carlsson, Albin Larsson Forsberg, Alexandros Nikou, Athanasios Karapantelakis, Aneta Vulgarakis Feljan

Organizations: Ericsson AB, Stockholm, Sweden · DEMACS, University of Calabria, Rende, Italy · RISE Research Institutes of Sweden, Stockholm, Sweden

Abstract

Large language models (LLMs) can generate structured outputs, but existing constrained-decoding methods mainly enforce syntax and cannot directly enforce satisfaction of a formal specification. We introduce a neuro-symbolic, specification-guided decoding framework that combines LLM generation with symbolic reasoning. At each step, the framework refines the decoding grammar by filtering out values that cannot be extended to an output satisfying the specification. We present a forward-only variant that guarantees specification satisfaction by construction, and a backtracking variant that revises earlier feasible choices when their downstream consequences leave only values that the LLM itself judges unsuitable. The framework is model-agnostic, requires no retraining, and builds on existing grammar-constrained decoding mechanisms. Experiments on configuration and constraint-solving benchmarks show that the forward-only variant reliably produces specification-compliant outputs while reducing repeated LLM inference compared with rejection sampling and incurring modest symbolic-reasoning overhead. The backtracking variant further reduces cases in which the model is forced to select values that it has itself judged unsuitable, thereby substantially improving adherence to the LLM's stated interpretation of the prompt.

Figures & tables

Explore similar work

CardsList
  1. Grammar-Aligned Decoding

    May 31, 2024Kanghee Park, Jiayu Wang, Taylor Berg-Kirkpatrick +2Constrained Generative ModelingConstrained Decoding

  2. The Hidden Cost of Structured Generation in LLMs: Draft-Conditioned Constrained Decoding

    Feb 8, 2026Avinash Reddy, Thayne T. Walker, James S. Ide +1Constrained Generative ModelingConstrained Decoding

  3. Constrained Decoding: Harmful or Beneficial? Revisiting Its Impact on LLM Performance

    Oct 26, 2026Ngoc Trinh Hung Nguyen, Alonso Silva, Armen Aghasaryan +1Constrained DecodingConstraint-Guided Reasoning in Language Models