Skip to Content
実践 LLMアプリケーション開発 ―プロトタイプを脱却し、実用的な実装に迫るための包括的な手引き
book

実践 LLMアプリケーション開発 ―プロトタイプを脱却し、実用的な実装に迫るための包括的な手引き

by Suhas Pai, 金本 勝吉, オライリー・ジャパン編集部
September 2025
Beginner to intermediate
400 pages
6h 4m
Japanese
O'Reilly Japan, Inc.
Content preview from 実践 LLMアプリケーション開発 ―プロトタイプを脱却し、実用的な実装に迫るための包括的な手引き

9章推論の最適化

 これまでの数章では、特定のタスクを解くためにLLMを適応・活用するさまざまな手法について学んできました。本章では、LLMを実際に活用する際に欠かせない効率的な推論(Inference)方法に焦点を当てていきます※1。LLMは非常に大規模であるため、計算量、メモリ容量、消費電力などにより、デプロイと推論処理が難しいという課題があります。これは特に、スマートフォンのようなエッジデバイス上では顕著です。

※1 訳注:「推論」とは、一般的に学習して重みが固定されたモデルを利用して出力を得るための計算処理を指します。

 この章では、推論の最適化に注目し、まずLLMの推論時間に影響する要因を取り上げます。その後、キャッシュ、知識蒸留、早期終了、量子化、並列デコーディング、投機的デコーディングなど、さまざまな最適化手法について解説していきます。

9.1 LLMによる推論の課題

 LLMの推論に影響を与えるボトルネックには、どのようなものがあるでしょうか? ご存じの通り、LLMはモデルのサイズが非常に大きいため、多くの計算資源とメモリ容量を必要とします。それらに加えて、以下のような課題もあります。

  • 4章で紹介したように、現在主流のLLMは、自己回帰型のデコーダのみのアーキテクチャに基づいています。これは、出力トークンが1つずつ逐次的に生成される構造であるため、並列化が難しく、推論速度に制約がかかります。本章の後半では、この制約を打破するための並列デコーディングや投機的デコーディングの手法について解説します。
  • 入力系列の長さに対して、計算量が二次関数的に増加するため、長い系列を扱いづらいことです。これに対処する方法として、本章の後半で紹介するKVキャッシュなどの手法が有効です。 ...
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

実践 AIエージェント開発 ―マルチエージェントシステムの設計と実装

実践 AIエージェント開発 ―マルチエージェントシステムの設計と実装

Michael Albada, 鈴木 駿, 高山 洪銘, 山下 正浩
実践 パケット解析 第3版 ―Wiresharkを使ったトラブルシューティング

実践 パケット解析 第3版 ―Wiresharkを使ったトラブルシューティング

Chris Sanders, 髙橋 基信, 宮本 久仁男, 岡 真由美
直感 生成AI ―ハンズオンで動かして学ぶ拡散モデル入門

直感 生成AI ―ハンズオンで動かして学ぶ拡散モデル入門

Omar Sanseviero, Pedro Cuenca, Apolinário Passos, Jonathan Whitaker, 江川 崇

Publisher Resources

ISBN: 9784814401314Publisher Website