cs.CLMar 1, 2026

Suffix-Constrained Greedy Search Algorithms for Causal Language Models

Authors: Ayoub HammalPierre ZweigenbaumCaio Corro

Organizations: 1Université Paris-Saclay, CNRS, LISN · 2INSA Rennes, IRISA, CNRS, Université de Rennes

Abstract

Large language models (LLMs) are powerful tools that have found applications beyond human-machine interfaces and chatbots. Beside free-form generation, there has been an interest in constrained generation, a setting where LLMs are constrained to generate well-formed outputs with respect to the language defined by a formal grammar. Although appealing, this setting may be over restrictive for downstream applications. For example, many LLM tasks require the model to reason freely before generating its final response in a specific format. In this work, we introduce suffix-constrained generation, a constrained generation setting in which only the end of the response is constrained by a grammar, a scenario that is not supported by existing constrained generation methods. We introduce several suffix-constrained generation algorithms that are based on greedy search. We experiment on several datasets, and show that our approach allows to guarantee suffix constraints without having a negative impact on results, and even improving them in many settings.

Explore similar work

CardsList
  1. Grammar-Aligned Decoding

    May 31, 2024Kanghee Park, Jiayu Wang, Taylor Berg-Kirkpatrick +2Large Language Model GenerationCode Generation

  2. Learning the Error Patterns of Language Models

    May 27, 2026Jinwoo Kim, Taylor Berg-KirkPatrick, Loris D'AntoniErrorsSymbol-