Re:Every Way to Get Structured Output from LLMs
by hellovai on Tuesday June 18, 2024 @03:21AM
(#40714984)
the main one is that most people don't own the model. so if you use openai / anthropic / etc then you can't use token masking. in that case, reprompting is pretty much the only option
[ Parent
| on HN ]
Re:Every Way to Get Structured Output from LLMs
by michaelt on Tuesday June 18, 2024 @07:02AM
(#40716262)
In the specific cases of openai and anthropic, both have 'tool use' interfaces which will generate valid JSON following a schema of your choice.
You're right, though, that reprompting works with pretty much everything out there, including hosted models that don't have tool use as part of their API. And its simple too, you don't even need to know what "token masking" is.
Reprompting can also apply arbitrarily criteria that are more complex than just a json schema. You ask it to choose an excerpt of a document and the string it returns isn't an excerpt? Just reprompt.
Re:Every Way to Get Structured Output from LLMs
by StrauXX on Wednesday June 19, 2024 @02:21AM
(#40725394)
It does. With OpenAI at least you definetly can use token masking. There are some limitations but even those are circumventable. I have used token masking on the OpenAI API with LMQL without any issues.