大規模言語モデルを用いたコード生成のためのプロンプトガイドライン:実証的考察
Guidelines to Prompt Large Language Models for Code Generation: An Empirical Characterization
January 19, 2026
著者: Alessandro Midolo, Alessandro Giagnorio, Fiorella Zampetti, Rosalia Tufano, Gabriele Bavota, Massimiliano Di Penta
cs.AI
要旨
大規模言語モデル(LLM)は現在、主にコード生成をはじめとする様々なソフトウェアエンジニアリングタスクに広く活用されている。これまでの研究では、適切なプロンプトエンジニアリングが開発者のコード生成プロンプト改善に寄与し得ることが示されてきた。しかしながら、現時点では、コード生成に適したプロンプト作成を開発者に導く具体的なガイドラインは存在しない。本研究では、ソフトウェア開発に特化したプロンプト最適化ガイドラインを導出し評価する。まず、テスト駆動型の反復的アプローチを用いてコード生成プロンプトを自動改良し、このプロセスから得られた結果を分析して、テスト合格に繋がるプロンプト改善要素を特定する。これらの要素に基づき、入出力や事前事後条件の明確化、事例の提示、各種詳細情報の付与、あいまいさの解消などに関連する10のプロンプト改善ガイドラインを抽出した。50名の実務開発者を対象に評価を実施した結果、彼らが抽出されたプロンプト改善パターンをどの程度利用しているか、またその有用性をどのように認識しているかが明らかになった。有用性の認識は、ガイドラインを知る前の実際の使用頻度と必ずしも一致しないことが分かった。本研究の成果は、実務家や教育関係者だけでなく、より優れたLLM支援型ソフトウェア開発ツールの構築を目指す関係者にとっても示唆に富むものである。
English
Large Language Models (LLMs) are nowadays extensively used for various types of software engineering tasks, primarily code generation. Previous research has shown how suitable prompt engineering could help developers in improving their code generation prompts. However, so far, there do not exist specific guidelines driving developers towards writing suitable prompts for code generation. In this work, we derive and evaluate development-specific prompt optimization guidelines. First, we use an iterative, test-driven approach to automatically refine code generation prompts, and we analyze the outcome of this process to identify prompt improvement items that lead to test passes. We use such elements to elicit 10 guidelines for prompt improvement, related to better specifying I/O, pre-post conditions, providing examples, various types of details, or clarifying ambiguities. We conduct an assessment with 50 practitioners, who report their usage of the elicited prompt improvement patterns, as well as their perceived usefulness, which does not always correspond to the actual usage before knowing our guidelines. Our results lead to implications not only for practitioners and educators, but also for those aimed at creating better LLM-aided software development tools.