Guiding Language Models of Code with Global Context using Monitors

要約

コードの言語モデル(LM)は、周囲のコードが十分なコンテキストを提供している場合にうまく機能する。しかし、リポジトリやリンクされたライブラリの他の場所で定義された型や機能、API、特に学習中に見たことのないものを使用する必要がある場合は、そうはいかない。LM は、このようなグローバルなコンテキストを認識することができず、幻覚を見てしまう。 統合開発環境(IDE)は、静的解析を用いて開発者がリポジトリのコンテキストを理解するのを支援する。我々は、開発者が享受しているこの支援をLMにも拡張する。我々は、モニターが静的解析を用いてデコードをガイドするモニターガイドデコーディング(MGD)を提案する。Javaのメソッド補完のためのリポジトリレベルのデータセットPragmaticCodeを構築し、MGDを評価する。様々なパラメータ規模のモデルにおいて、型一貫性のあるオブジェクトの非参照を監視することで、MGDは一貫してコンパイル率とグランドトゥルースとの一致を改善する。さらに、MGDで補強されたパラメータ数の少ないLMは、より大きなLMを凌駕することができる。MGDにより、SantaCoder-1.1Bは、より大きなtext-davinci-003モデルよりも優れたコンパイル率と次識別子の一致を達成した。 また、MGDが複数のプログラミング言語(Java、C#、Rust)、コーディングシナリオ(例:メソッド呼び出しの正しい引数数)、およびより豊かな意味制約(例:ステートフルAPIプロトコル)を強制する能力を評価するために、一般化可能性の研究も行っています。我々のデータと実装は、https://github.com/microsoft/monitors4codegen で利用可能である。

要約(オリジナル)

Language models of code (LMs) work well when the surrounding code provides sufficient context. This is not true when it becomes necessary to use types, functionality or APIs defined elsewhere in the repository or a linked library, especially those not seen during training. LMs suffer from limited awareness of such global context and end up hallucinating. Integrated development environments (IDEs) assist developers in understanding repository context using static analysis. We extend this assistance, enjoyed by developers, to LMs. We propose monitor-guided decoding (MGD) where a monitor uses static analysis to guide the decoding. We construct a repository-level dataset PragmaticCode for method-completion in Java and evaluate MGD on it. On models of varying parameter scale, by monitoring for type-consistent object dereferences, MGD consistently improves compilation rates and agreement with ground truth. Further, LMs with fewer parameters, when augmented with MGD, can outperform larger LMs. With MGD, SantaCoder-1.1B achieves better compilation rate and next-identifier match than the much larger text-davinci-003 model. We also conduct a generalizability study to evaluate the ability of MGD to generalize to multiple programming languages (Java, C# and Rust), coding scenarios (e.g., correct number of arguments to method calls), and to enforce richer semantic constraints (e.g., stateful API protocols). Our data and implementation are available at https://github.com/microsoft/monitors4codegen .

arxiv情報

著者 Lakshya A Agrawal,Aditya Kanade,Navin Goyal,Shuvendu K. Lahiri,Sriram K. Rajamani
発行日 2023-11-03 11:13:15+00:00
arxivサイト arxiv_id(pdf)

提供元, 利用サービス

arxiv.jp, DeepL

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