次回の更新記事:AIエージェントの実力はハーネスで変わる(公開予定日:2026年06月01日)
AIDB Daily Papers

LLMにデザインパターンを使わせる戦略:シングルトンパターンを例に

原題: Strategies for Guiding LLMs to Use Software Design Patterns: A Case of Singleton
著者: Viktor Kjellberg, Farnaz Fotrousi, Miroslaw Staron
公開日: 2026-05-26 | 分野: LLM cs.AI cs.SE プロンプトエンジニアリング ソフトウェア工学 AI支援

※ 日本語タイトル・ポイントはAIによる自動生成です。正確な内容は原論文をご確認ください。

ポイント

  • 大規模言語モデル(LLM)がソースコード生成時にシングルトンデザインパターンを適用する能力を評価した。
  • 指示、自動フィードバック、few-shotプロンプトなどの戦略を比較し、モデルタイプによって最適な戦略が異なることを発見した。
  • 反復的なバイナリフィードバックがシングルトンパターンの適用と機能性を両立させるのに最も効果的であり、Llama 3.3やQwen 3 (8B)で顕著な成果が得られた。

Abstract

Large Language Models (LLMs) can generate functional source code from natural-language prompts, but often fail to consistently follow higher-level architectural structures or design patterns. Since LLMs are increasingly used in software engineering, their ability to apply established design principles to generated code is crucial to the long-term success of software products. Therefore, the goal of this paper is to identify strategies for guiding LLMs to incorporate design patterns into the generated source code. We designed a computational experiment to evaluate the ability of 13 LLMs to generate code that follows the Singleton design pattern, using four prompting strategies: instructions, binary automated feedback, extensive automated feedback, and extensive feedback with few-shot prompts, in 164 Java coding challenges from HumanEval-X. Our results shows that the optimal strategy to guide LLMs to include design patterns depends heavily on the type of model. Still, overall, iterative binary feedback provides the best alignment with Singleton while preserving or improving the code's functionality. With guiding with instructions, Llama 3.3 generated Singleton classes in 100% of cases and improved code functionality, increasing the number of tests passed by 34.1 percentage points. It achieved a similar result with guidance through instructions and binary feedback. Qwen 3 (8B) increased the alignment with Singleton to 99.2% and the functionality to 58.6% using binary feedback. Our result suggests that even simple strategies can be used to guide LLMs to use design patterns.

Paper AI Chat

この論文のPDF全文を対象にAIに質問できます。

質問の例:

AIチャット機能を利用するには、ログインまたは会員登録(無料)が必要です。

会員登録 / ログイン

💬 ディスカッション

ディスカッションに参加するにはログインが必要です。

ログイン / アカウント作成 →

関連するAIDB記事