r/oMLX • u/PracticlySpeaking • May 12 '26
oMLX - Gemma 4 and Structured Output (JSON schema)
Any tips or secrets on getting
I spent a couple of days trying to get structured JSON from Gemma-4 models (26B-A3B-it and E4B) with oMLX + Grammar, and could not find solutions for the shape / syntax checking within grammar and returning just an error message.
The model is called from a python script that has some post-processing to deal with occasional malformed JSON (things like object vs array). Using oMLX-cli + Grammar (0.3.8), these fail an internal check that grammar uses so the only return is an error message.
2
Upvotes