ChatPaper.aiChatPaper

대규모 언어 모델을 활용한 도메인 특화 언어 생성을 위한 문법 프롬프팅

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

May 30, 2023
저자: Bailin Wang, Zi Wang, Xuezhi Wang, Yuan Cao, Rif A. Saurous, Yoon Kim
cs.AI

초록

대형 언어 모델(LLM)은 소수의 문맥 내 예시만으로도 다양한 자연어 작업을 수행하는 방법을 학습할 수 있습니다. 그러나 고도로 구조화된 언어(예: 복잡한 도메인 특화 언어로의 의미론적 파싱)에서 문자열을 생성하는 작업의 경우, LLM이 단 몇 가지 예시로부터 일반화하는 것은 어려운 과제입니다. 본 연구에서는 문법 프롬프팅(grammar prompting)을 통해 LLM이 문맥 내 학습 과정에서 외부 지식과 도메인 특화 제약 조건을 활용할 수 있는 간단한 접근 방식을 탐구합니다. 이때 제약 조건은 Backus-Naur 형식(BNF)으로 표현된 문법을 통해 나타냅니다. 문법 프롬프팅은 각 데모 예시를 해당 출력 예시를 생성하는 데 최소한으로 필요한 특화 문법으로 보강하며, 이 특화 문법은 전체 도메인 특화 언어(DSL) 문법의 부분집합입니다. 추론 단계에서 LLM은 먼저 테스트 입력이 주어졌을 때 BNF 문법을 예측한 다음, 해당 문법의 규칙에 따라 출력을 생성합니다. 실험 결과, 문법 프롬프팅을 통해 LLM이 다양한 DSL 생성 작업에서 경쟁력 있는 성능을 발휘할 수 있음이 입증되었습니다. 이 작업에는 의미론적 파싱(SMCalFlow, Overnight, GeoQuery), PDDL 계획 생성, 심지어 분자 생성(SMILES)까지 포함됩니다.
English
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).
PDF34December 15, 2024