paper-with-me

홈 › Papers

Grammar-Constrained Decoding for Structured NLP Tasks without Finetuning

2023-05-23 · Saibo Geng, Martin Josifoski, Maxime Peyrard, Robert West

Despite their impressive performance, large language models (LMs) still struggle with reliably generating complex output structures when not finetuned to follow the required output format exactly. To address this issue, grammar-constrained decoding (GCD) can be used to control the generation of LMs, guaranteeing that the output follows a given structure. Most existing GCD methods are, however, limited to specific tasks, such as parsing or code generation. In this work, we demonstrate that formal grammars can describe the output space for a much wider range of tasks and argue that GCD can serve as a unified framework for structured NLP tasks in general. For increased flexibility, we introduce input-dependent grammars, which allow the grammar to depend on the input and thus enable the generation of different output structures for different inputs. We then empirically demonstrate the power and flexibility of GCD-enhanced LMs on (1) information extraction, (2) entity disambiguation, and (3) constituency parsing. Our results indicate that grammar-constrained LMs substantially outperform unconstrained LMs or even beat task-specific finetuned models. Grammar constraints thus hold great promise for harnessing off-the-shelf LMs for a wide range of structured NLP tasks, especially where training data is scarce or finetuning is expensive. Code and data: https://github.com/epfl-dlab/GCD.

📄 PDF Abstract BibTeX arXiv:2305.13971

Code (2)

epfl-dlab/gcd 공식 구현 pytorch
uiuc-focal-lab/syncode

Tasks

Code GenerationConstituency ParsingEntity Disambiguationvalid

Similar Papers 제목 키워드 기반

Grammar-Aligned Decoding

2024-05-31 · Kanghee Park, Jiayu Wang, Taylor Berg-Kirkpatrick, Nadia Polikarpova 외

Large Language Models (LLMs) struggle with reliably generating highly structured outputs, such as program code, mathematical formulas, or well-formed markup. Constrained decoding approaches mitigate this problem by greed…

Code Generation

Generating Structured Outputs from Language Models: Benchmark and Studies

2025-01-18 · Saibo Geng, Hudson Cooper, Michał Moskal, Samuel Jenkins 외

Reliably generating structured outputs has become a critical capability for modern language model (LM) applications. Constrained decoding has emerged as the dominant technology across sectors for enforcing structured out…

Flexible and Efficient Grammar-Constrained Decoding

2025-02-07 · Kanghee Park, Timothy Zhou, Loris D'Antoni

Large Language Models (LLMs) are often asked to generate structured outputs that obey precise syntactic rules, such as code snippets or formatted data. Grammar-constrained decoding (GCD) can guarantee that LLM outputs ma…

Using Grammar Masking to Ensure Syntactic Validity in LLM-based Modeling Tasks

2024-07-08 · Lukas Netz, Jan Reimer, Bernhard Rumpe

We present and evaluate a method called grammar masking, which is used to guide large language models (LLMs) toward producing syntactically correct models for a given context-free grammar. Prompt engineering methods such…

Few-Shot LearningLanguage ModelingLanguage ModellingPrompt Engineering+1

Stay Within Your Bounds: Distance-Guided Decoding for Guaranteed Context-Free Grammar Compliance

2026-08-28 · Vincenzo Collura, Karim Tit, Eleonora Giunchiglia, Mike Papadakis 외 arxiv

Grammar-constrained decoding helps large language models produce syntactically valid structured outputs, such as code, JSON, and SQL. For context-free grammars, many practical decoders enforce local prefix feasibility: e…