ChatPaper.aiChatPaper

Statische Kontextualisierung großer Sprachmodelle mit typisierten Lücken

Statically Contextualizing Large Language Models with Typed Holes

September 2, 2024
papers.authors: Andrew Blinn, Xiang Li, June Hyung Kim, Cyrus Omar
cs.AI

papers.abstract

Große Sprachmodelle (LLMs) haben die Landschaft der Programmsynthese neu gestaltet. Allerdings halluzinieren zeitgenössische LLM-basierte Code-Vervollständigungssysteme oft fehlerhaften Code, da ihnen der geeignete Kontext fehlt, insbesondere bei der Arbeit mit Definitionen, die nicht in den Trainingsdaten enthalten oder in der Nähe der Cursorposition sind. Dieses Papier zeigt, dass eine enge Integration mit der Typ- und Bindungsstruktur einer Sprache, wie sie ihr Language Server bereitstellt, dieses Kontextualisierungsproblem auf token-effiziente Weise lösen kann. Kurz gesagt, wir sind der Ansicht, dass auch KIs IDEs benötigen! Insbesondere integrieren wir die LLM-Codegenerierung in die Hazel Live-Programm-Skizzierungsumgebung. Der Hazel Language Server identifiziert den Typ und den Typisierungskontext der zu füllenden Lücke, selbst bei Vorhandensein von Fehlern, und stellt so sicher, dass stets eine aussagekräftige Programmskizze verfügbar ist. Dies ermöglicht das Prompting mit kontextuellen Informationen aus der gesamten Codebasis, die nicht lexikalisch lokal zum Cursor stehen und nicht notwendigerweise in derselben Datei liegen, aber wahrscheinlich semantisch lokal zum Ziel des Entwicklers sind. Durch den LLM synthetisierte Vervollständigungen werden dann iterativ durch weiteren Dialog mit dem Language Server verfeinert. Um diese Techniken zu evaluieren, führen wir MVUBench ein, einen Datensatz von Model-View-Update (MVU) Webanwendungen. Diese Anwendungen dienen als Herausforderungsprobleme aufgrund ihrer Abhängigkeit von anwendungsspezifischen Datenstrukturen. Wir stellen fest, dass die Kontextualisierung mit Typdefinitionen besonders wirkungsvoll ist. Nach der Vorstellung unserer Ideen im Kontext von Hazel replizieren wir unsere Techniken und portieren MVUBench nach TypeScript, um die Anwendbarkeit dieser Methoden auf ressourcenstärkere Sprachen zu validieren. Abschließend skizzieren wir ChatLSP, eine konservative Erweiterung des Language Server Protocol (LSP), die Language Server implementieren können, um Fähigkeiten bereitzustellen, die KI-Code-Vervollständigungssysteme verschiedener Designs nutzen können, um statischen Kontext bei der Generierung von Prompts für ein LLM einzubeziehen.
English
Large language models (LLMs) have reshaped the landscape of program synthesis. However, contemporary LLM-based code completion systems often hallucinate broken code because they lack appropriate context, particularly when working with definitions not in the training data nor near the cursor. This paper demonstrates that tight integration with the type and binding structure of a language, as exposed by its language server, can address this contextualization problem in a token-efficient manner. In short, we contend that AIs need IDEs, too! In particular, we integrate LLM code generation into the Hazel live program sketching environment. The Hazel Language Server identifies the type and typing context of the hole being filled, even in the presence of errors, ensuring that a meaningful program sketch is always available. This allows prompting with codebase-wide contextual information not lexically local to the cursor, nor necessarily in the same file, but that is likely to be semantically local to the developer's goal. Completions synthesized by the LLM are then iteratively refined via further dialog with the language server. To evaluate these techniques, we introduce MVUBench, a dataset of model-view-update (MVU) web applications. These applications serve as challenge problems due to their reliance on application-specific data structures. We find that contextualization with type definitions is particularly impactful. After introducing our ideas in the context of Hazel we duplicate our techniques and port MVUBench to TypeScript in order to validate the applicability of these methods to higher-resource languages. Finally, we outline ChatLSP, a conservative extension to the Language Server Protocol (LSP) that language servers can implement to expose capabilities that AI code completion systems of various designs can use to incorporate static context when generating prompts for an LLM.
PDF42November 14, 2024