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

要約

我々は、文法マスキングと呼ばれる方法を提示し、評価します。この方法は、特定の文脈自由文法に対して構文的に正しいモデルを生成するように大規模言語モデル (LLM) をガイドするために使用されます。
少数ショット学習やプライミングなどの即時エンジニアリング手法を使用すると、LLM が正しい構文を生成する可能性を高めることができますが、文法が複雑になればなるほど、これらの手法は時間がかかり、期待できなくなります。
これまでの研究は、主に言語モデル トレーニングまたはプロンプト エンジニアリングの使用に焦点を当てていました。
この研究では、出力が有効な構文に準拠していることを確認するために、制約付きデコードを使用して出力を特定の文法に制限する方法が紹介されています。
MontiCore で構築された複数の DSL を使用し、複数の LLM にタスクを課して、制約付きデコードの有無にかかわらずモデルを生成します。
対応するパーサーは、各モデルの構文の正しさを確認するために使用されます。
文法マスキングによっていくつかの LLM のモデリング機能が劇的に向上し、適切に洗練されたプロンプトの必要性が減り、同時に正しいモデルが生成される可能性が高まることを示します。

要約(オリジナル)

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 as few-shot learning or priming can be used to improve the chances of an LLM producing correct syntax, but the more complex the grammar, the more time-consuming and less promising these methods become. Previous work is focused primarily on the usage of either language model training or prompt engineering. In this work, a method is presented that restricts the output to a given grammar using constrained decoding to ensure the output adheres to a valid syntax. We use several DSLs built with MontiCore and task multiple LLMs to produce models with and without constrained decoding. A corresponding parser is used to confirm the syntactic correctness of each model. We show that grammar masking can dramatically improve the modeling capabilities of several LLMs, reducing the need for well-refined prompting while increasing the chance of producing correct models.

arxiv情報

著者 Lukas Netz,Jan Reimar,Bernhard Rumpe
発行日 2024-07-08 17:19:59+00:00
arxivサイト arxiv_id(pdf)

提供元, 利用サービス

arxiv.jp, Google

カテゴリー: cs.AI, cs.CL, cs.SE パーマリンク