3 ms·
I had similar issue with gpt4, was looking for a library that given a grammar and a string, would produce a list of next valid symbols. Gpt4 only ever suggeste
by avereveard 3y ago
I had similar issue with gpt4, was looking for a library that given a grammar and a string, would produce a list of next valid symbols.
Gpt4 only ever suggested grammar validator to the point I had given up and was going to write a grammar generator, and so I started looking for the equivalent of antlr in python, and in three searches I find out nltk.grammar that actually solves the original problem
It's not a new library either, so I'm dumbfounded by why gpt4 couldn't make sense of my request.
- disgruntledphd2 3y agoIf it hasn't been used much/talked about much for this purpose then you wouldn't expect it to, right?
- avereveard 3y agotrue, but then it's neither interpolating between the public documentation nor extrapolating from the possible similarities between concepts
- IanCal 3y agoI tried this to see. It does suggest using validators, though in a way that mostly solves the problem. The failure mode is when the string is valid complete or extended. It does have a bit of a workaround for that. https://chat.openai.com/share/54cb8876-96ff-4434-a479-4d2ddebf14cb https://chat.openai.com/share/54cb8876-96ff-4434-a479-4d2dde...
- avereveard 3y agousing the exception only works at whole symbol level, i.e. with "cat do" as imput No terminal matches 'd' in the current parser context, at line 1 col 5 cat do ^ Expected one of: * CAT * SPACE * FISH * DOG Next valid symbols: ['* CAT\n\t* SPACE\n\t* FISH\n\t* DOG']
- IanCal 3y agoI'm not sure I understand, what that reports is enough to solve it right? Was the problem you couldn't get it to solve it from that point?
- avereveard 3y agoNo because if I add space to the original string I don't get a valid string Or given the context space is a valid production from the last error, but then I would need to roll back the incomplete "do" terminal and lose that context.
- IanCal 3y ago> No because if I add space to the original string I don't get a valid string Yeah, it's telling you what it was expecting when it hit an invalid token. You take the invalid part and filter the list of suggestions with it. If you tell chatgpt about the problem it solves it. (Edit - when I was running this, having any number of spaces was parsed as valid btw if that's the concern - space was a valid option)