Live data from Hacker News

Show HN: LLMs can generate valid JSON 100% of the time

github.com

251–260 of 315 posts

Re: Show HN: LLMs can generate valid JSON 100% of the time

#251
post #97

Earlier quoted context omitted.

It’s starting to feel like LLMs are to “classical” software engineering what quantum physics was to classical physics

How so? I’m not quite following the analogy.

Oh it was just a glib way of moaning about non-determinism making its way into software engineering. Much like how physicists had to make peace with the probabilistic nature of quantum physics.

Re: Show HN: LLMs can generate valid JSON 100% of the time

#252
post #238

Earlier quoted context omitted.

Truly.. one of the greatest minds in our ML era. Don't get caught up on the format :)

I just don't find it an effective way of learning personally. I didn't expect this to be so controversial - different people learn differently.

I recommend this for groundwork to get you near LLM, and cover the journey deeply. I used some of this as a helper course for Karpathy. I learned things here he didn’t cover and vice versa. https://www.cs.toronto.edu/~rgrosse/courses/csc321_2018/

I haven’t done tonnes of courses so there might be better. But this is good as a free one.

Re: Show HN: LLMs can generate valid JSON 100% of the time

#253

Earlier quoted context omitted.

Your comment here doesn’t feel like it’s in good faith, but there’s a good chance I’m misreading it.

I'm serious that the similarities between the papers are superficial. I don't think it's fair of you to criticize the authors for not citing some obscure preprint, when that manuscript itself neglected to cite decades of prior, relevant work.

I have some other comment on this thread where I point out why I don’t think it’s superficial. Would love to get your feedback on that if you feel like spending more time on this thread.

But it’s not obscure? FlashText was a somewhat popular paper at the time (2017) with a popular repo (https://github.com/vi3k6i5/flashtext). Their paper was pretty derivative of Aho-Corasick, which they cited. If you think they genuinely fucked up, leave an issue on their repo (I’m, maybe to your surprise lol, not the author).

Anyway, I’m not a fan of the whatabboutery here. I don’t think OG’s paper is up to snuff on its lit review - do you?

Re: Show HN: LLMs can generate valid JSON 100% of the time

#254
post #183
post #160

Earlier quoted context omitted.

Maybe it's just me, but I'm not doing anything that calls itself 'zero to hero'. Would love some good resources (preferably textbook, or at least written) on LLMs though. I don't even understand the link to 'generative' image/video AI, which seems to have exploded at roughly the same time and surely isn't a coincidence. I studied a little (literally 'intro to') ML at university, about enough to grok it as an applicat…

Since you are "judging a book by its cover", or this case a name. This might interest you, that karpathy was co-founding developer of OpenAI, left to work at Tesla to head their AI development for 5-ish years and now back at OpenAI. I can understand that you might be interested in book form only, I was lile this for the longest time, until I bumped into some really high quality video series that changed my mind to be…

Karpathy has flash attention of Pytorch in his repo. I understand that is fairly recent (in human weeks, maybe not AI dog weeks)

Re: Show HN: LLMs can generate valid JSON 100% of the time

#255

Earlier quoted context omitted.

100% have observed the same over many tests. No loss in fidelity when responding in spoken language style of formatting but using json is disastrous.

While not ideal, could a workaround be to ask in spoken language first, and then ask to format it in JSON?

That’s what we have been doing. Two passes. The task and then the format.

Re: Show HN: LLMs can generate valid JSON 100% of the time

#256
post #151

Earlier quoted context omitted.

100% have observed the same over many tests. No loss in fidelity when responding in spoken language style of formatting but using json is disastrous.

Using OpenAI Function Calls or asking for JSON in the prompt?

I have noticed it in both but have been working with json output before function calling was introduced so I have more evidence on that side. The times I have tried to implement it in a function call I was equally unimpressed with it.

Re: Show HN: LLMs can generate valid JSON 100% of the time

#257
post #246
post #8

I can make GPT4 return valid JSON simply by providing examples in the system message. This works nine times out of ten. But it's still probabilistic, and nine times out of ten isn't good enough. Occasionally it will hallucinate responses like this: {"key1": "value1", "key2": "value2" for i in range(n)} Re-prompting with the parsing error message is usually enough to get it on the second try. But escaping double-quote…

>I can make GPT4 return valid JSON simply by providing examples in the system message. This works nine times out of ten But you can do both. For my current use case of extracting information from articles, I have a json schema + one/two example articles along with their correct answers. This increases token costs but 3.5 is so cheap that it doesn't matter and for 4 you can use batching to decrease token cost per arti…

Can you please explain what is batching ? any pointers?

Re: Show HN: LLMs can generate valid JSON 100% of the time

#258

Earlier quoted context omitted.

I'm serious that the similarities between the papers are superficial. I don't think it's fair of you to criticize the authors for not citing some obscure preprint, when that manuscript itself neglected to cite decades of prior, relevant work.

I have some other comment on this thread where I point out why I don’t think it’s superficial. Would love to get your feedback on that if you feel like spending more time on this thread. But it’s not obscure? FlashText was a somewhat popular paper at the time (2017) with a popular repo ( https://github.com/vi3k6i5/flashtext ). Their paper was pretty derivative of Aho-Corasick, which they cited. If you think they genu…

> I don’t think OG’s paper is up to snuff on its lit review - do you?

Not in the slightest. Caching the logit masks and applying the right one based on where you are in your grammar is obvious. This is what I'd expect some bright undergrads to come up with for a class project. This manuscript could've been a blog post.

Although arXiv is displacing some traditional publishing, I think it's a little silly to try to hold it to the same standards.

I saw your argument for why you think it's relevant and I think you're overstating the case. There are a _heap_ of papers they could've cited.

As an aside, when can we stop citing _Attention is All You Need_?

Re: Show HN: LLMs can generate valid JSON 100% of the time

#259

How is this different from generating such things without an LLM? In other words picking random valid tokens from the grammar via fuzzing or similar techniques.

LLMS allows for building systems that take user requests in text: "book the next flight to Egpyt" and convert them into a system message: `{"action": "book_flight", "destination": "Egypt", ... }`

However, anyone who's tried to build a system like this on GPT or other LLM soon learns that they don't always do as they're told, and it can be hard to get them to return valid JSON or correct instructions translation reliably. Sometimes, they make stuff up that has nothing to do with your system.

OpenAI has a solution to this with their new function calling API, by introducing models fine-tuned to return JSON, but they still can't make guarantees.

Outlines seems to be a neat approach to constrain an LLM to return JSON, or any grammar, reliably.

Re: Show HN: LLMs can generate valid JSON 100% of the time

#260

Hi, remilouf. You say that your background is in "probabilistic, relational and symbolic programming". In that case I suspect you understand that it is no problem to generate text from a regular or context-free grammar, or really any level of grammar. For example, you can do that very easily in Prolog (a relational language) given a grammar in Definite Clause Grammars notation. As far as I can tell your approach requ…

IanCal said it all. But for alternative approaches that also use LLM (with miniKanren) you can check https://arxiv.org/abs/1809.02840
Post reply on HN