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

05/30/2023
by   Bailin Wang, et al.
0

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).

READ FULL TEXT

page 1

page 2

page 3

page 4

research
01/24/2019

A model for a Lindenmayer reconstruction algorithm

Given an input string s and a specific Lindenmayer system (the so-called...
research
09/15/2023

Generating Semantic Graph Corpora with Graph Expansion Grammar

We introduce Lovelace, a tool for creating corpora of semantic graphs. T...
research
08/27/2022

On Unsupervised Training of Link Grammar Based Language Models

In this short note we explore what is needed for the unsupervised traini...
research
05/17/2021

RL-GRIT: Reinforcement Learning for Grammar Inference

When working to understand usage of a data format, examples of the data ...
research
06/02/1999

Learning Efficient Disambiguation

This dissertation analyses the computational properties of current perfo...
research
02/16/2021

Have Attention Heads in BERT Learned Constituency Grammar?

With the success of pre-trained language models in recent years, more an...
research
08/16/2023

Types, equations, dimensions and the Pi theorem

The languages of mathematical physics and modelling are endowed with a r...

Please sign up or login with your details

Forgot password? Click here to reset