이번 패턴에서는 해법보다 예제를 먼저 살펴보는 것이 좋겠다. 그래야 이 문제의 해법을 명확
하게 이해할 수 있다.
6.3.2
예제
LLM
을 이용해서 오라일리 책의 소개문(온라인 서점과 실제 책 뒤표지에 실리는 마케팅용 설
명문)을 개선한다고 하자. 이 작업은 두 단계로 나눌 수 있는데, 첫 단계에서는 책 소개문을 개
선할 아이디어를 여러 개 생성하고, 둘째 단계에서는 가장 좋은 아이디어를 선택해서 소개문
을 실제로 변경한다. 짐작했겠지만 이는
CoT
패턴(제
5
장의 패턴
13
)과
성찰
패턴(이번 장의
패턴
18
)의 조합에 해당한다. 전체 코드는 원서 깃허브 저장소의
dependency
_
injection
.
ipynb
파일에 있다.
단계
1
: 비평 생성
첫 단계에서는 책 소개문을 보내고 비평을 받는다. 비평은
구조적 출력
(제
2
장의 §
2
.
2
“패턴
2
:
문법” 참고)로 주어진다. 다음은 이를 위한 파이썬 데이터클래스의 정의이다.
@dataclass
class Critique:
target_audience: List[str]
improvements: List[str]
이제 적절한 프롬프트를 이용해서 평가기
LLM
을 호출한다.
defcritique(in_text: str) -> Critique:
prompt =f"""
당신은 기술 ...
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.
O’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
I 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
I’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
I'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.