Remix.run Logo
shmolyneaux 6 hours ago

Are there output formats that are more reliable (better adherence to the schema, easier to get parse-able output) or cheaper (fewer tokens) than JSON? YAML has its own problems and TOML isn't widely adopted, but they both seem like they would be easier to generate.

What have folks tried?

marquesine 6 hours ago | parent | next [-]

Yes, that's the purpose of TOON.

https://github.com/toon-format/toon

prats226 5 hours ago | parent | next [-]

Nice, it would be good idea to develop CFG for this as well so can embed it into all these constrained decoding libraries

koakuma-chan 5 hours ago | parent | prev [-]

Is there evidence that LLMs adhere to this format better than to JSON? I doubt that.

TheTaytay an hour ago | parent | next [-]

Their benchmarks compare it against other formats as input, not as output.

koakuma-chan 21 minutes ago | parent [-]

Now it makes sense.

iLoveOncall 4 hours ago | parent | prev [-]

It is 100% guaranteed that they DON'T. Toon is 3 months old, it's not used by anyone, and it's therefore not in the training set of any model.

greiskul 4 hours ago | parent | prev | next [-]

Just brainstorming. Human beings have trouble writing json, cause it is too annoying. Too strict. In my experience, for humans writing typescript is a lot better than writing json directly, even when the file is just a json object. It allows comments, it allows things like trailing commas which are better for readability.

So maybe an interesting file to have the LLM generate is instead of the final file, a program that creates the final file? Now there is the problem of security of course, the program the LLM generates would need to be sandboxed properly, and time constrained to prevent DOS attacks or explosive output sizes, not to mention the cpu usage of the final result, but quality wise, would it be better?

orbital-decay 2 hours ago | parent | prev | next [-]

You should do your own evals specific to your case. In my evals XML outperforms JSON on every model for out of distribution tasks (i.e. not for JSON that was in the data).

tlarkworthy 5 hours ago | parent | prev [-]

I use regex to force an XML schema and then use a normal XML parser to decode.

XML is better for code, and for code parts in particular I enforce a cdata[[ part so there LLM is pretty free to do anything without escaping.

OpenAI API lets you do regex structured output and it's much better than JSON for code.