Compositional API Recommendation for Library-Oriented Code Generation

要約

大規模言語モデル (LLM) は、コード生成において優れたパフォーマンスを達成しました。
ただし、ライブラリ指向のコードを生成する場合、特に LLM のトレーニング データに存在しないライブラリの場合、パフォーマンスは依然として不十分です。
これまでの研究では、API 推奨テクノロジーを利用して、LLM によるライブラリの使用を支援しました。ユーザー要件に関連する API を取得し、LLM にプロンプ​​トを表示するコンテキストとして利用しました。
ただし、開発要件は粒度が粗く、複数の粒度の細かい API の組み合わせが必要になる場合があります。
この粒度の不一致により、API の推奨は困難な作業になります。
これに対処するために、私たちは CAPIR (Compositional API Recommendation) を提案します。これは、「分割統治」戦略を採用して、粗粒度の要件に対して API を推奨します。
具体的には、CAPIR は LLM ベースの Decomposer を使用して、大まかなタスクの記述をいくつかの詳細なサブタスクに分解します。
次に、CAPIR は埋め込みベースの Retriever を適用して、各サブタスクに対応する関連 API を識別します。
さらに、CAPIR は LLM ベースの Reranker を利用して冗長な API を除外し、最終的な推奨事項を提供します。
粗粒度の要件に関する API 推奨方法の評価を容易にするために、RAPID (ドキュメントに基づいた API の推奨) と LOCG (ライブラリ指向コード生成) という 2 つの難しいベンチマークを紹介します。
これらのベンチマークの実験結果は、既存のベースラインと比較した CAPIR の有効性を示しています。
具体的には、RAPID の Torchdata-AR データセットでは、最先端の API 推奨アプローチと比較して、CAPIR は再現率 @5 を 18.7% から 43.2% に、精度 @5 を 15.5% から 37.1% に向上させています。
LOCG の Torchdata-Code データセットでは、API 推奨なしのコード生成と比較して、CAPIR により pass@100 が 16.0% から 28.0% に向上しました。

要約(オリジナル)

Large language models (LLMs) have achieved exceptional performance in code generation. However, the performance remains unsatisfactory in generating library-oriented code, especially for the libraries not present in the training data of LLMs. Previous work utilizes API recommendation technology to help LLMs use libraries: it retrieves APIs related to the user requirements, then leverages them as context to prompt LLMs. However, developmental requirements can be coarse-grained, requiring a combination of multiple fine-grained APIs. This granularity inconsistency makes API recommendation a challenging task. To address this, we propose CAPIR (Compositional API Recommendation), which adopts a ‘divide-and-conquer’ strategy to recommend APIs for coarse-grained requirements. Specifically, CAPIR employs an LLM-based Decomposer to break down a coarse-grained task description into several detailed subtasks. Then, CAPIR applies an embedding-based Retriever to identify relevant APIs corresponding to each subtask. Moreover, CAPIR leverages an LLM-based Reranker to filter out redundant APIs and provides the final recommendation. To facilitate the evaluation of API recommendation methods on coarse-grained requirements, we present two challenging benchmarks, RAPID (Recommend APIs based on Documentation) and LOCG (Library-Oriented Code Generation). Experimental results on these benchmarks, demonstrate the effectiveness of CAPIR in comparison to existing baselines. Specifically, on RAPID’s Torchdata-AR dataset, compared to the state-of-the-art API recommendation approach, CAPIR improves recall@5 from 18.7% to 43.2% and precision@5 from 15.5% to 37.1%. On LOCG’s Torchdata-Code dataset, compared to code generation without API recommendation, CAPIR improves pass@100 from 16.0% to 28.0%.

arxiv情報

著者 Zexiong Ma,Shengnan An,Bing Xie,Zeqi Lin
発行日 2024-02-29 18:27:27+00:00
arxivサイト arxiv_id(pdf)

提供元, 利用サービス

arxiv.jp, Google

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