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アプリケーション開発

7章モデルの制御

前章では、すべてのコンテキストを1つの一貫性のあるプロンプトに抽出することができました。ここからは、LLMにLLMらしい仕事をさせ、それがすべてスムーズに進むようにあなたが確認する番です。

本章では、まず補完の形式について説明し、期待する通りに補完が完了するように制御する方法を解説します。また、「logprobトリック」と呼ばれるテクニックを使って補完の内容を分析・解釈する方法についても説明します。

次に、一歩下がって、専門家向けの商用サービス、オープンソースの選択肢、独自のファインチューニングされたモデルの、どのモデルを呼び出すかを自問できるようにします。さあ、始めましょう。

7.1 理想的な補完の構造

本節では、補完(従来の補完、またはチャットレスポンス)がどのように現れるかを調べます。さらに重要なことは、不要な待ち時間や紛らわしい詳細といった問題を避けながら、明確で効果的な解決策を確保するために、補完をどのようなものにしたいかについて議論することです。「6章 プロンプトの組み立て」でプロンプトに対して行ったように、LLMによる補完の要素を分解し、それらを1つずつ見ていきます(図7-1を参照)。

LLMによる補完

図7-1 LLMによる補完

7.1.1 序文

補完のコンテキストでは、「序文」は生成されたテキストの最初の部分であり、主要なコンテンツの準備をします。これが役立つ場合もあれば、あなたが提起した問題への解決策を生み出す前に、面白くない、または役立たない詳細から始まる補完になる場合もあります。これはしばしば煩わしいことであり、コストもかかります。トークンの生成には、時間(待ち時間)と計算(リソースとお金)がかかります。ですので、使わないテキストを作成することは無駄ですが、時には望ましいこともあります。わかりにくいかもしれませんが、お付き合いください。 ...

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