[論文レビュー] Grammar Prompting for Domain-Specific Language Generation with Large Language Models
文法 prompting は各例ごとに最小の専門BNF文法を予測し、その文法で制約してデコードすることで、意味解析、計画、分子生成タスクで少数ショットのDSL生成を改善する。
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 propose \emph{grammar prompting}, a simple approach to enable LLMs to use external knowledge and domain-specific constraints, expressed through a grammar 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 SMILES-based molecule generation.
研究の動機と目的
- 少数の例しかない場合の構造化DSL出力のデータ効率の良い生成を動機付ける。
- 専門的で最小限のBNF文法を活用して、イン-context学習を制約しデコードを導く。
- 意味解析、計画、分子生成を横断する標準 prompting との改善を示す。
提案手法
- 各イン-contextデモに対して、目標出力yを生成するのに十分な最小限の専門文法G[y]を追加する。
- Gとイン-context例から専門文法G_hatを予測し、G_hatを条件にyを生成する。
- 適合するデコードアルゴリズム(Earleyベース)を適用して出力をL(G_hat)に収め、無効なプレフィックスを修正する。
- 生のLLM継続が無効な場合、有効なプレフィックスを抽出してトークン選択を導くためにEarleyパーサを使用する。
- 複数のDSLドメインで文法 prompting を標準 prompting および制約付きデコードのベースラインと比較する。
実験結果
リサーチクエスチョン
- RQ1文法 prompting は、少数ショット設定で標準 prompting より DSL 出力をより正確に生成できるか?
- RQ2専門文法を予測・制約することで、 unseen DSL 構造や関数への一般化が向上するか?
- RQ3文法案内付き制約付きデコードは計算コストと出力の妥当性にどのように影響するか?
- RQ4文法 prompting は意味解析、PDDL計画、SMILESベースの分子生成を含む多様な DSL で効果的か?
主な発見
- 文法 prompting は GeoQuery、SMCalFlow、Overnight-Blocks の意味解析ベンチマークで標準 prompting よりプログラムおよび実行精度を向上させる。
- 予測された文法を用いた制約付きデコードは、いくつかのタスクで制約なしの文法 prompting よりさらなる利得をもたらす。
- 専門的な文法 prompting は未見の関数や組成的/generalization分野(GeoQuery)への一般化が raw prompting より良好。
- 複数のベースLLMにおいて、文法 prompting は少数ショット設定で一貫して性能を向上させ、分野とモデルによって若干の変動。
より良い研究を、今すぐ始めましょう
論文設計から論文執筆まで、研究時間を劇的に削減しましょう。
クレジットカード登録不要
このレビューはAIが作成し、人間の編集者が確認しました。