Skip to Content
실무로 통하는 LLM 애플리케이션 설계
book

실무로 통하는 LLM 애플리케이션 설계

by 수하스 파이, 박조은
October 2025
Intermediate
424 pages
10h 19m
Korean
Hanbit Media, Inc.
Content preview from 실무로 통하는 LLM 애플리케이션 설계
279
9
추론 최적화
9.3
연산량 감소 기법
추론 시 필요한 연산량을 줄이는 방법은 다음과 같습니다.
캐싱과 같은 방법으로 계산을 추가 저장 공간과 교환합니다.
조기 종료와 같은 방법으로 추론 중 특정 연산을 생략합니다.
지식 증류와 같은 기법으로 큰 모델에서 작은 모델을 도출하면서 원래 모델의 특성과 기능을 최대한 보존합
니다.
다음 절에서는 각 방법을 자세히 살펴보겠습니다.
9.3.1
K
-
V
캐싱
1
장에서 살펴봤듯이,
LLM
에는 세션 메모리가 없습니다.
LLM
대화의 차례마다 이전 대화 기
록이 입력에 추가됩니다. 이는
LLM
에 대한 모든 요청이 프롬프트에 상당량의 반복 내용을 포
함할 수 있다는 의미입니다. 프롬프트의 반복되는 부분에 대해서는 추론 단계에서 동일한 계
산이 계속 수행됩니다. 더욱이 자기회귀적 디코딩에서는 각 토큰이 전체 입력과 이전에 생성된
토큰들의 함수로 생성되므로 중복 계산이 많이 발생합니다.
이러한 중복 계산을 줄이는 한 가지 방법은 데이터를 캐싱하고 필요할 때 재사용하는 것입니
다. 구체적으로는 트랜스포머 아키텍처의 셀프 어텐션 블록의 키(
K
)와 값(
V
)을 캐싱하는데,
이를
K
-
V
캐시라고 합니다.
4
장에서 다룬 트랜스포머의 셀프 어텐션 블록에서의 키와 값에
관한 내용을 떠올려 보세요.
몇 가지 예를 살펴보겠습니다. 영화 리뷰의 감정 분석 작업을 생각해 봅시다. 감정 분석에 필요
한 자세한 지침을 제공하는 긴 프롬프트가 있을 수 있습니다. 이러한 지침은
LLM
에 입력되는
모든 리뷰의 프롬프트에 포함됩니다. ...
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

What Successful Project Managers Do

What Successful Project Managers Do

W. Scott Cameron, Jeffrey S. Russell, Edward J. Hoffman, Alexander Laufer
How to Overcome a Power Deficit

How to Overcome a Power Deficit

Cyril Bouquet, Jean-Louis Barsoux
Relational Power Is the New Currency of Hybrid Work

Relational Power Is the New Currency of Hybrid Work

Lebene Soga, Yemisi Bolade-Ogunfodun, Nazrul Islam, Joseph Amankwah-Amoah

Publisher Resources

ISBN: 9791169214384