Live data from Hacker News

Use Prolog to improve LLM's reasoning

shchegrikovich.substack.com

91–100 of 158 posts

Re: Use Prolog to improve LLM's reasoning

#91
post #83
post #45

Earlier quoted context omitted.

Did you just answer me with chatgpt?

> top of a Prolog-derived language who's name escapes me are you saying we've made a huge leap in LLMs - that they can now admit when they don't know something?

With the right prompting you can get LLMs to output pretty much anything :)

> What is the airspeed velocity of an unladen Eurasian blue tit?

> I’m not sure. The specific airspeed velocity of an unladen Eurasian blue tit hasn't been studied or widely documented in the same way that birds like swallows have been. It would likely depend on many factors like the bird’s weight, wing shape, and wind conditions. If you’re looking for general information about bird flight or blue tits, I can help with that!

/GPT-4o

Re: Use Prolog to improve LLM's reasoning

#92
post #42

Earlier quoted context omitted.

I've programmed in Prolog for ~13 years and my PhD thesis is in machine learning of Prolog programs. How deep would you like me to go?

As deep as is required to actually make your argument!

You'll have to be more specific than that. For me what I point out is obvious: Prolog is not magick. Your program won't magickally reason if you write it in Prolog, much less reason correctly. If an LLM translates a Problem to the wrong Prolog program, Prolog won't magickally turn it into a correct program. And that's just rephrasing what I said in my comment above. There's really not much more to say.

Here's just one more observation: the problems where translating reasoning to Prolog will work best are problems where there are a lot of examples of Prolog to be found on the web, e.g. wolf-cabbage-goat problems and the like. With problems like that it is much easier for an LLM to generate a correct translation of the problem to Prolog and get a correct solution just because there's lots of examples. But if you choose a problem that's rarely attacked with Prolog code, like, I don't know, some mathematical problem that obtains in nuclear physics as a for instance, then an LLM will be much more likely to generate garbage Prolog, while e.g. Fortran would be a better target language. From what I can see, the papers linked in the article above concentrate on the Prolog-friendly kind of problem, like logical puzzles and the like. That smells like cherry picking to me, or just good, old confirmation bias.

Again, Prolog is not magick. The article above and the papers it links to seem to take this attitude of "just add Prolog" and that will make LLMs suddenly magickally reason with fairy dust on top. Ain't gonna happen.

Re: Use Prolog to improve LLM's reasoning

#93

That's not going to work. Garbage in - Garbage out is success-set equivalent to Garbage in - Prolog out. Garbage is garbage and failure to reason is failure to reason no matter the language. If your LLM can't translate your problem to a Prolog program that solves your problem- Prolog can't solve your problem.

Why do you think that the LLM cannot translate the problem into a program? Granted, it has been said that the Curry or Mercury languages may be better than Prolog at times with their functional logic programming features. Ultimately it's best if the LLM has the freedom to decide what's best to use for the problem from what it knows.

>> Why do you think that the LLM cannot translate the problem into a program?

No, the question is why do you think I think that? I never said anything like that.

Re: Use Prolog to improve LLM's reasoning

#94

That's not going to work. Garbage in - Garbage out is success-set equivalent to Garbage in - Prolog out. Garbage is garbage and failure to reason is failure to reason no matter the language. If your LLM can't translate your problem to a Prolog program that solves your problem- Prolog can't solve your problem.

Agree, reasoning has to come from within the model. These are hacks that only work in specific use cases

Yep. Specifically ones for which there are lost of examples of Prolog programs on the web so an LLM can learn the correct translation more easily.

Re: Use Prolog to improve LLM's reasoning

#95

ChatGPT seems to do awful with Prolog. Do you guys have any experiences with using an LLM to write Prolog?

See my top-level comment for an example. Though different, there's also casual experimentation described in [1] (and additional posts linking to academic research on the SWI Prolog forum). Do you mind sharing your experience with ChatGPT (which version)? [1]: https://swi-prolog.discourse.group/t/chatgpt-prompts-prolog-...

I do not think that I have the conversation / chat anymore, but I was trying to get it to make a monthly schedule for N workers with specific constraints[1]. I thought Prolog is suitable for this (is it?), but the generated code got stuck / hung up.

[1] https://news.ycombinator.com/item?id=41756679

Re: Use Prolog to improve LLM's reasoning

#96

I made a pipeline using Z3 (another prover language) to get LLMs to solve very specific puzzle problems: https://youtu.be/UjSf0rA1blc (and a presentation: https://youtu.be/TUAmfi8Ws1g ) Some thoughts: 1. Getting an LLM to model a problem accurately is a significant prompting exercise. Bridging casual logical statements and formal logic is difficult. E.g., "or" statements in English usually mean "xor" in logic. 2. Dom…

Thanks, really interesting. I'm going to watch your videos and learn something since I'm on the other side of the fence: I'm creating Zebra Puzzles algorithmically [1] and then feeding their raw and generic rules ("The person who has Dog=Doberman lives next to the person who has House=Green") to a LLM to get the English representation of a thematic puzzle.

[1]: https://www.zebrapuzzles.com/

Re: Use Prolog to improve LLM's reasoning

#97
post #58

Earlier quoted context omitted.

> over the past 2 years of heavy Prolog use Oh, cool. Mind if I pick your brain a bit? Recently, there was an HN post[0] of a paper that makes a case against pure logic languages in favor of "functional logic" ones, which they exhibit with Curry[1]. The setup argument is that Prolog's specs backtracking, which strongly downlimits it from full SLD resolution, causing fatally sharp edges in real world usage. Being fair…

> What is some of your most hard-earned knowledge? 1. If you find yourself straying too often from coding in relations, and instead coding in instructive steps, you're going to end up with problems. 2. Use DCGs to create a DSL for any high level operations performed on data structures. The bi-directionality of Prolog's clauses means you can use this DSL to generate an audit trail of "commands executed" when Prolog so…

How do you debug DCGs? I get "false." instead of "syntax error at line 23", which is unacceptable for bigger inputs.

Also DCGs for high level operations? Do you mean "use DCGs to parse strings that contain instructions" or do you parse things other than strings with DCGs? I'm assuming you take the parsed instructions and run them through some kind of interpreter that does the execution and audit trail.

Re: Use Prolog to improve LLM's reasoning

#99
post #36

Earlier quoted context omitted.

"Prolog" is like Lisp, a wide array of superficially similar languages that actually are quite diverse. Mind you, in that sense, Java and C# are more or less the same language, which has Prolog programmers nodding their heads and Java and C# developers screaming.

Nope. Prolog is an ISO-standardized language since 1995 and the spec was updated in 2012. Where older "legacy" Prolog implementations such as SWI, YAP, and SICStus are deviating from the standard is generally pretty well-known to Prolog practitioners, and the convener of ISO 13211 actually can verify claims of ISO conformance; for example, [1] is a link to the ISO certification of Quantum Prolog (the web app at [2]).…

Also on Lisp there's Common Lisp with ANSI and maybe closer-mop from QuickLisp standarizing the cores, and then Scheme is it's own universe of compiler with official (SRFI) and own extensions and libraries.

Re: Use Prolog to improve LLM's reasoning

#100
post #14

i've come to appreciate, over the past 2 years of heavy Prolog use, that all coding should be (eventually) be done in Prolog. It's one of few languages that is simultaneously a standalone logical formalism, and a standalone representation of computation. (With caveats and exceptions, I know). So a Prolog program can stand in as a document of all facts, rules and relations that a person/organization understands/declar…

Has anyone tried to mine LLM world model via sampling to extract all relations it's believes to be true (like 99%+ certain) into Prolog like clauses. I think this is way to achieve reliable world/domain models in logical sense (non-probabilistic). Probably brain doesn't do it but it could be cool anyway. Seems like good sampler could somehow mine this info by using stuff like I believe that X is true or false for all X imaginable. Then try go generate relations for these etc.
Post reply on HN