Grammar-Aligned Decoding

要約

大規模言語モデル (LLM) は、プログラム コード、数式、整形式のマークアップなど、高度に構造化された出力を確実に生成するのに苦労します。
制約付きデコード手法では、LLM が各ステップで出力できるトークンを貪欲に制限して、出力が指定された制約に一致することを保証することで、この問題を軽減します。
特に、文法制約デコード (GCD) では、LLM の出力は指定された文法に従う必要があります。
この論文では、GCD 技術 (および一般的な制約付きデコード技術) が LLM の分布を歪める可能性があり、その結果、文法的ではあるものの、LLM によって与えられる確率に比例しない可能性を持った出力が生成される可能性があることを実証します。
品質。
我々は、サンプリングを文法制約に合わせて調整する問題を文法整合復号化 (GAD) と呼び、近似予測未来を伴う適応的サンプリング (ASAp) を提案します。これは、出力が文法的であることを保証しながら、条件文に一致する出力を証明的に生成する復号化アルゴリズムです。
指定された文法制約を条件とした LLM の分布の確率。
私たちのアルゴリズムは、以前のサンプル出力を使用して、さまざまな出力プレフィックスの将来の文法性を正確に過近似します。
コード生成と構造化 NLP タスクに関する評価では、ASAp が、望ましい文法的制約を強制しながらも、既存の GCD 手法よりも (LLM の分布に従って) 高い確率で出力を生成することが多いことがわかります。

要約(オリジナル)

Large Language Models (LLMs) struggle with reliably generating highly structured outputs, such as program code, mathematical formulas, or well-formed markup. Constrained decoding approaches mitigate this problem by greedily restricting what tokens an LLM can output at each step to guarantee that the output matches a given constraint. Specifically, in grammar-constrained decoding (GCD), the LLM’s output must follow a given grammar. In this paper we demonstrate that GCD techniques (and in general constrained decoding techniques) can distort the LLM’s distribution, leading to outputs that are grammatical but appear with likelihoods that are not proportional to the ones given by the LLM, and so ultimately are low-quality. We call the problem of aligning sampling with a grammar constraint, grammar-aligned decoding (GAD), and propose adaptive sampling with approximate expected futures (ASAp), a decoding algorithm that guarantees the output to be grammatical while provably producing outputs that match the conditional probability of the LLM’s distribution conditioned on the given grammar constraint. Our algorithm uses prior sample outputs to soundly overapproximate the future grammaticality of different output prefixes. Our evaluation on code generation and structured NLP tasks shows how ASAp often produces outputs with higher likelihood (according to the LLM’s distribution) than existing GCD techniques, while still enforcing the desired grammatical constraints.

arxiv情報

著者 Kanghee Park,Jiayu Wang,Taylor Berg-Kirkpatrick,Nadia Polikarpova,Loris D’Antoni
発行日 2024-05-31 17:39:15+00:00
arxivサイト arxiv_id(pdf)

提供元, 利用サービス

arxiv.jp, Google

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