News for hackers. Stuff that matters.
Re:Native JSON Output from GPT-4 by jonplackett on Wednesday June 14, 2023 @05:50PM (#36333249)
Not that it matters now but just doing something like this works 99% of the time or more with 4 and 90% with 3.5.

It is VERY IMPORTANT that you respond in valid JSON ONLY. Nothing before or after. Make sure to escape all strings. Use this format:

{“some_variable”: [describe the variable purpose]}

Re:Native JSON Output from GPT-4 by SamPatt on Wednesday June 14, 2023 @06:17PM (#36333563)
99% of the time is still super frustrating when it fails, if you're using it in a consumer facing app. You have to clean up the output to avoid getting an error. If it goes from 99% to 100% JSON that is a big deal for me, much simpler.
Re:Native JSON Output from GPT-4 by jonplackett on Wednesday June 14, 2023 @06:22PM (#36333596)
Except it says in the small print to expect invalid JSON occasionally, so you have to write your error handling code either way
Re:Native JSON Output from GPT-4 by davepeck on Wednesday June 14, 2023 @06:45PM (#36333882)
Yup. Is there a good/forgiving "drunken JSON parser" library that people like to use? Feels like it would be a useful (and separable) piece?
Re:Native JSON Output from GPT-4 by golol on Wednesday June 14, 2023 @07:05PM (#36334103)
Honestly, I suspect asking GPT-4 to fix your JSON (in a new chat) is a good drunken JSON parser. We are only scraping the surface of what's possible with LLMs. If Token generation was free and instant we could come up with a giant schema of interacting model calls that generates 10 suggestions, iterates over them, ranks them and picks the best one, as silly as it sounds.
Re:Native JSON Output from GPT-4 by hhh on Wednesday June 14, 2023 @07:12PM (#36334178)
I already do this today to create domain-specific knowledge focused prompts and then have them iterate back and forth and a ‘moderator’ that chooses what goes in and what doesn’t.
Re:Native JSON Output from GPT-4 by andai on Thursday June 15, 2023 @04:05AM (#36337668)
That's hilarious... if parsing GPT's JSON fails, keep asking GPT to fix it until it parses!
Re:Native JSON Output from GPT-4 by golol on Thursday June 15, 2023 @07:34AM (#36338991)
It shouldn't be surprising though. If a human makes an error parsing JSON, what do you do? You make them look over it again. Unless their intelligence is the bottleneck they might just be able to fix it.
Re:Native JSON Output from GPT-4 by golergka on Thursday June 15, 2023 @07:48AM (#36339104)
It works. Just be sure to build a good error message.
Re:Native JSON Output from GPT-4 by golergka on Thursday June 15, 2023 @07:47AM (#36339096)
If you're building an app based on LLMs that expects higher than 99% correctness from it, you are bound to fail. Negative scenarios workarounds and retries are mandatory.
Re:Native JSON Output from GPT-4 by 8organicbits on Wednesday June 14, 2023 @07:15PM (#36334201)
Wouldn't you use traditional software to validate the JSON, then ask chatgpt to try again if it wasn't right?
Re:Native JSON Output from GPT-4 by girvo on Wednesday June 14, 2023 @08:04PM (#36334659)
In my experience, telling it "no thats wrong, try again" just gets it to be wrong in a new different way, or restate the same wrong answer slightly differently. I've had to explicitly guide it to correct answers or formats at times.
Re:Native JSON Output from GPT-4 by cjbprime on Thursday June 15, 2023 @12:23AM (#36336369)
Try different phrasing, like "Did your answer follow all of the criteria?".