Papers
arxiv:2305.19234

Grammar Prompting for Domain-Specific Language Generation with Large Language Models

Published on May 30, 2023
· Submitted by
AK
on May 31, 2023
Authors:
,
,

Abstract

Grammar prompting enhances LLMs' performance on DSL generation tasks by incorporating domain-specific grammars expressed in BNF.

Large language models (LLMs) can learn to perform a wide range of natural language tasks from just a handful of in-context examples. However, for generating strings from highly structured languages (e.g., semantic parsing to complex domain-specific languages), it is challenging for the LLM to generalize from just a few exemplars. We explore grammar prompting as a simple approach for enabling LLMs to use external knowledge and domain-specific constraints, expressed through a grammar expressed in Backus--Naur Form (BNF), during in-context learning. Grammar prompting augments each demonstration example with a specialized grammar that is minimally sufficient for generating the particular output example, where the specialized grammar is a subset of the full DSL grammar. For inference, the LLM first predicts a BNF grammar given a test input, and then generates the output according to the rules of the grammar. Experiments demonstrate that grammar prompting can enable LLMs to perform competitively on a diverse set of DSL generation tasks, including semantic parsing (SMCalFlow, Overnight, GeoQuery), PDDL planning, and even molecule generation (SMILES).

Community

Pasted image 20230609020817.png

explain what this is

Pasted image 20230609020817.png

•
This comment has been hidden

Sign up or log in to comment

Get this paper in your agent:

hf papers read 2305.19234
Don't have the latest CLI?
curl -LsSf https://hf.co/cli/install.sh | bash

Models citing this paper 0

No model linking this paper

Cite arxiv.org/abs/2305.19234 in a model README.md to link it from this page.

Datasets citing this paper 0

No dataset linking this paper

Cite arxiv.org/abs/2305.19234 in a dataset README.md to link it from this page.

Spaces citing this paper 0

No Space linking this paper

Cite arxiv.org/abs/2305.19234 in a Space README.md to link it from this page.

Collections including this paper 1