Skip to Content
LLMのプロンプトエンジニアリング ―GitHub Copilotを生んだ開発者が教える生成AIアプリケーション開発
book

LLMのプロンプトエンジニアリング ―GitHub Copilotを生んだ開発者が教える生成AIアプリケーション開発

by John Berryman, Albert Ziegler, 服部 佑樹, 佐藤 直生
May 2025
Intermediate to advanced
276 pages
4h
Japanese
O'Reilly Japan, Inc.
Content preview from LLMのプロンプトエンジニアリング ―GitHub Copilotを生んだ開発者が教える生成AIアプリケーション開発

6章プロンプトの組み立て

前章までで、プロンプトの構成要素となる豊富なコンテンツを収集しました。ここからは、それらのパーツを組み合わせて、あなたの要望を効果的に伝えるプロンプトを作成していきます。本章では、まず利用できる構造やさまざまな選択肢を整理しながら、どのようにプロンプトを形作っていくかを解説します。それぞれのスニペットをどのように整理して配置するかが、最終的なプロンプトの有効性を大きく左右するのです。

次のステップでは、サイズ制限の中で何を残し何を削除するかを判断するコンテンツの選別を行います。このプロセスは、プロンプトを洗練させ、焦点を絞って関連性を保つために重要です。コンテンツが確定したら、モデルから関連性があり、一貫性のある、コンテキストに即したレスポンスを引き出すためのツールとなるプロンプトの組み立てに移ります。それでは詳しく見ていきましょう。

6.1 理想的なプロンプトの構造

具体的な手順に入る前に、まずは最終的な目標をイメージしてみましょう。図6-1は、プロンプトがどのように「見えるべきか」を俯瞰的に示しています。これからその構成要素を順を追って説明していきます。プロンプトは、簡潔でわかりやすいほど効果的ですし、計算資源を節約できるだけでなく、処理速度も上がります。加えて、コンテキストウィンドウサイズには厳密な上限があることを忘れてはいけません。

「5章 プロンプトのコンテンツ」で説明したように、プロンプトは動的なコンテキストと、質問を明確にする静的な指示から構成されています。これらの要素のサイズや数に厳密なルールはありません。実際、アプリケーションが進化するにつれて、大きなプロンプト要素がより正確な構成のために複数の小さな要素に分割されることもあります。私たちが携わったプロジェクトの中には、長文要素が3つしかないプロンプトもあれば、一行の要素が数百にわたって列挙されたものもありました。 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

実用 Git 第3版

実用 Git 第3版

Prem Kumar Ponuthorai, Jon Loeliger, 萬谷 暢崇, 長尾 高弘
入門 Kubernetes

入門 Kubernetes

Kelsey Hightower, Brendan Burns, Joe Beda, 松浦 隼人

Publisher Resources

ISBN: 9784814401130Publisher Website