Lesson 47
Forcing valid output
Build an LLM From Scratch, 53 lessons
Lesson 47: Forcing valid output
Build an LLM From Scratch, Lesson 47 of 53

A model only writes text, so a tool call can come out as "Sure! Here you go" or with a tool that doesn't exist. Play one token with and without a mask, then build a whole call under a grammar, and find what a grammar cannot promise.
The question for this lesson: how can code force a model’s output to be valid?
Lesson 46 made tool calls cheaper to recover from: clear errors, clear descriptions, safe retries. It ended on a worse case. What if the call isn’t even valid?
BREAF Premium
The rest of this lesson is in Premium
Premium includes every lesson, with its notes, practice and progress.