GPT-3 swipl API?

I’m interested in developing a swipl library to interface with the GPT-3 API. Is anyone already working on that?

Motivation: Large language models (LLM) like GPT are all the rage right now because they’ve advanced the quality of natural language processing. While OpenAI’s GPT isn’t open source, it does provide free and low-cost access. It also has a well-documented API.

At the moment, libraries exist for Python and NodeJS, but not Prolog. However, some of the current issues with using LLMs like GPT is that they suffer from reasoning problems like hallucinations and unfaithful chains of reasoning (see “Faithful Chain-of-Thought Reasoning” 2023 Lyu et al). One avenue of tackling these problems is to integrate non-machine learning modules, like logic engines, with the LLM. This seems like an opportunity for environments like Prolog, which are strong in the older approaches to AI, like rule-based inference.


Would be a nice pack! If there is an OpenAPI (prev swagger) description, the pack may help you.

That said I’m not a great fan of these automatic wrapper generators. Yes, you get some Prolog predicates that talk to the API, but they are typically not the ones you want to use in your application. Thus you need to write a layer on top of it to make it all look friendly. And then it typically turns out that interfacing this nice user facing API directly to the (HTTP) API isn’t much harder.


This sounds like a great idea! Best of both worlds. I am not aware of anybody doing that.