News for hackers. Stuff that matters.
Re:Structured Outputs in LLMs by electroglyph on Tuesday September 23, 2025 @08:57AM (#45346403)
If the current position in the structure only has one possibility (like a comma, bracket, etc.) do you just force that as the next token and continue?
Re:Structured Outputs in LLMs by FlyingLawnmower on Tuesday September 23, 2025 @09:42AM (#45346926)
We do enable forcing these sequences of tokens in guidance, and find that it significantly speeds up structured generation. There are tricky alignment issues to make sure you pick the right sequence of tokens, but you can often proxy this well by using the model's native tokenizer. Some details here in an old blog: https://guidance.readthedocs.io/en/latest/example_notebooks/...
Re:Structured Outputs in LLMs by ninadpathak on Tuesday September 23, 2025 @09:55AM (#45347092)
In most cases, yes—forcing is common when the grammar dictates a single valid option. It's a fast path. Trickier cases arise if multiple tokens could satisfy the same grammar position, especially with weird tokenizations or BPE merges. Edge cases can trip token selection, but for things like brackets/commas, forced emission usually works flawlessly.
Re:Structured Outputs in LLMs by maccam912 on Tuesday September 23, 2025 @09:22AM (#45346656)
I don't think so, because multiple tokens might match. If it needs a comma as the next character, but you have tokens for `, "blah` and `, "foo` you still want to leave those on the table.