Rewriting the Code: A Simple Method for Large Language Model Augmented Code Search

要約

コード検索では、クエリを拡張するためのサンプル コード スニペットを生成する生成拡張検索 (GAR) フレームワークが、コード スニペットと自然言語クエリの間のモダリティの不整合という主要な課題 (特に実証済みのコード) に対処するための有望な戦略として浮上しています。
大規模言語モデル (LLM) の生成機能。
それにもかかわらず、私たちの予備調査では、このような LLM 拡張フレームワークによってもたらされる改善にはある程度の制限があることが示されています。
この制限は、生成されたコードが、機能的には正確であるにもかかわらず、コードベース内のグラウンド トゥルース コードからの顕著なスタイルの逸脱を頻繁に示すという事実に起因している可能性があります。
このペーパーでは、基本的な GAR フレームワークを拡張し、スタイル正規化のためにコードベース内のコードの書き換え (ReCo) を追加する、シンプルかつ効果的な方法を提案します。
実験結果は、ReCo がさまざまな検索シナリオにおいて、スパース (最大 35.7%)、ゼロショットデンス (最大 27.6%)、および微調整されたデンス (最大 23.6%) の検索設定全体で検索精度を大幅に向上させることを示しています。
ReCo の利点をさらに解明し、コード スタイルの正規化の研究を促進するために、コード内のスタイルの類似性を定量化するために調整された最初の指標であるコード スタイルの類似性を紹介します。
特に、私たちの経験的調査結果は、文体のニュアンスを捉える上で既存の指標が不十分であることを明らかにしています。

要約(オリジナル)

In code search, the Generation-Augmented Retrieval (GAR) framework, which generates exemplar code snippets to augment queries, has emerged as a promising strategy to address the principal challenge of modality misalignment between code snippets and natural language queries, particularly with the demonstrated code generation capabilities of Large Language Models (LLMs). Nevertheless, our preliminary investigations indicate that the improvements conferred by such an LLM-augmented framework are somewhat constrained. This limitation could potentially be ascribed to the fact that the generated codes, albeit functionally accurate, frequently display a pronounced stylistic deviation from the ground truth code in the codebase. In this paper, we extend the foundational GAR framework and propose a simple yet effective method that additionally Rewrites the Code (ReCo) within the codebase for style normalization. Experimental results demonstrate that ReCo significantly boosts retrieval accuracy across sparse (up to 35.7%), zero-shot dense (up to 27.6%), and fine-tuned dense (up to 23.6%) retrieval settings in diverse search scenarios. To further elucidate the advantages of ReCo and stimulate research in code style normalization, we introduce Code Style Similarity, the first metric tailored to quantify stylistic similarities in code. Notably, our empirical findings reveal the inadequacy of existing metrics in capturing stylistic nuances.

arxiv情報

著者 Haochen Li,Xin Zhou,Zhiqi Shen
発行日 2024-01-09 12:12:50+00:00
arxivサイト arxiv_id(pdf)

提供元, 利用サービス

arxiv.jp, Google

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