Skip to Content
파이토치로 배우는 LLM & AI
book

파이토치로 배우는 LLM & AI

by 로런스 모로니, 박해선
March 2026
Intermediate
504 pages
11h 26m
Korean
Hanbit Media, Inc.
Content preview from 파이토치로 배우는 LLM & AI
337
13
장
서빙을 위해 파이토치 모델 호스팅하기
이를 담당합니다. 예를 들어 기본적인 매개변수로 받거나
JSON
파일을 받을 수 있습니다. 이
는 개발자의 선택 사항이며
TorchServe
는 유연하므로 다양한 방법을 수용할 수 있습니다.
다음은 간단히 기본적인 매개변수만 받는 코드입니다.
def preprocess(self, data):
# 디코딩 없이 직접 값을 받습니다.
value = float(data[0].get("body"))
tensor = torch.tensor([value], dtype=torch.float32).view(1, 1)
return tensor.to(self.device)
여기서 보듯이 이 메서드의 목적은 매개변수를 받는 것뿐만 아니라 모델이 원하는 형식으로 재
구성하는 것입니다. 따라서 호출할 때 받은 매개변수를
1
차원 텐서로 변환하여 반환합니다. 이
텐서가 추론 메서드에서 사용됩니다.
오버라이드할 다음 메서드는 모델에 데이터를 전달하고 응답을 받아올 추론 메서드입니다. 코
드는 다음과 같습니다.
def inference(self, data):
"""전처리된 데이터로 추론을 실행합니다."""
with torch.no_grad():
results = self.model(data)
return results
이 메서드는 ...
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 에이전트 엔지니어링

마이클 알바다
핸즈온 LLM

핸즈온 LLM

제이 알아마르, 마르턴 흐루턴도르스트
만들면서 배우는 생성 AI

만들면서 배우는 생성 AI

데이비드 포스터

Publisher Resources

ISBN: 9791175790223