4 ms·
YAML is just as effective at communicating data structure to the model while using ~50% less tokens. I now convert all my JSON to YAML before feeding it to GPT
by alexbouchard 3y ago
YAML is just as effective at communicating data structure to the model while using ~50% less tokens. I now convert all my JSON to YAML before feeding it to GPT API's
- aledalgrande 3y agodo you also get it to return responses in YAML?
- alexbouchard 3y agoYes and then format it back to JSON
- camjw 3y agoI've heard this a lot but don't understand where this idea comes from. With JSON you can strip whitespace whereas with YAML you're stuck with all these pointless whitespace tokens you can't do anything about. I would recommend the exact opposite, JSON is just as effective while using less tokens. This example JSON: {"glossary":{"title":"example glossary","GlossDiv":{"title":"S","GlossList":{"GlossEntry":{"ID":"SGML","SortAs":"SGML","GlossTerm":"Standard Generalized Markup Language","Acronym":"SGML","Abbrev":"ISO 8879:1986","GlossDef":{"para":"A meta-markup language, used to create markup languages such as DocBook.","GlossSeeAlso":["GML","XML"]},"GlossSee":"markup"}}}}} Is 112 tokens, and the corresponding YAML (which I won't paste) is 206. What am I missing?
- thomasfromcdnjs 3y agoI keep going back and fourth between the two. I have absolutely no proof but sometimes feel like the responses I get are weaker if there is no white space in the structured data.
- camjw 3y agoThis is fair, typically I supply data as compact JSON but ask for responses as pretty printed JSON which is quite a large token penalty but tends to strongly reduce malformed JSON outputs.
- trzy 3y agoNothing. They just didn’t realize that JSON doesn’t need to be pretty-printed :)
- SkyPuncher 3y agoIn my experience, the non-human characters cause GPT a lot of problems. They break a lot of the magic of GPT.