Jsonformer: Generate structured output from LLMs
Oh nice! I built a similar system a few weeks ago: <a href="https://github.com/newhouseb/clownfish">https://github.com/newhouseb/clownfish</a><p>I think the main differentiating factor here is that this is better if you have a simpler JSON schema without enums or oneOf constraints. If you do have these constraints, i.e. let's say you wanted an array of different types that represented a items on a menu { kind: pizza, toppings: [pepperoni] } or { kind: ice_cream, flavor: vanilla | strawberry } then you would need something more sophisticated like clownfish that can ask the LLM to pick specific properties (and an ability to do some backtracking so you can do proper beam search).<p>For completeness, another common approach can be found here: <a href="https://github.com/ShreyaR/guardrails">https://github.com/ShreyaR/guardrails</a> which essentially boils down to "provide the schema in the prompt and ask the LLM to correct things if it fails to get the schema right the first time."