𝗧𝗵𝗶𝘀 𝗜𝘀 𝗔 𝗚𝗨𝗜𝗗𝗘 𝗧𝗢 𝗨𝗦𝗜𝗡𝗚 𝗚𝗕𝗡𝗙 𝗚𝗥𝗔𝗠𝗠𝗔𝗥𝗦 𝗙𝗢𝗥 𝗢𝗡-𝗗𝗘𝗩𝗜𝗖𝗘 𝗟𝗟𝗠𝗦 You want to get valid JSON from your on-device LLMs on Android every time.

To get started, you need:

The key is to move validation into the decoder.

You pay roughly 13% on raw decode speed, but you eliminate retries entirely.

Source: https://dev.to/software_mvp-factory/structured-output-grammars-for-on-device-llms-550j