할 때 이런 현상이 두드러진다. 이는 길이와 복잡도가 증가할수록 후보 출력 토큰 중 어느 것도 문법에 맞지 않는
지점에 도달할 가능성이 커지기 때문이다.
부정확한 결과
이 패턴에서 모델의 출력에는 오직 문법이 허용하는 토큰만 포함된다. 그런데 문법이 너무 제한적이면 부정확한
결과를 얻을 수 있다. 따라서 모델이 제한적인 문법에서 벗어날 수 있는 선택지를 주는 것이 도움이 된다. 예를
들어 어떤 필드가 기본적으로
float
타입이어야 하지만 값을 알 수 없는 경우 모델이
"Unknown"
이라는 문자열
을 출력하도록 허용하고 싶다면 다음과 같이 필드를 정의하면 된다.
currency_rate: float| Literal["Unknown"]
문법 패턴에는 몇 가지 다른 이름이 있다. 문법 명세를 표현하는 데 자료구조
data
structure
가 흔히
쓰이기 때문에 이 패턴을
구조적 출력
패턴이라고 부르기도 한다. 또한, 가능한 로짓을 제약하
는 방식으로 작동하므로
제약 디코딩
constrained
decoding
이라고도 불린다. 하지만 어떤 모델이나 프
레임워크가 구조적 출력을 지원한다고 해서
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.