Month: November 2023

Multihub question answering with ChatGPT and Wikidata

Posted on Updated on

One of the newer versions of ChatGPT enables you to write custom chatbots (“My GPTs”) with pre-specified prompts. This facility also allows you to make so-called actions that call external APIs. The format for actions is a bit difficult to understand, but ChatGPT itself can help you create the action. I used two chained prompts to generate an action for the Wikidata API: first “Can you make “Add actions” template for ChatGPTs MyGPTs that uses the Wikidata REST API. One of the paths could go to entities. The Wikidata REST API is described at https://doc.wikimedia.org/Wikibase/master/js/rest-api/. The OpenAPI Wikidata server is https://wikidata.org” and then as the second prompt “It needs to be in a JSON or YAML format. Here is an example:”. The second prompt featured a copy-and-past from an example I found on the Web.

I have now generated the bot and it is available under the name Wikibåt. If you are a ChatGPT Plus user you may be able to use it. This bot is able to do multihub searches with the Wikidata API using the wbsearchentities query and entity lookup. Below is a screenshot of a session with the initial prompt “With the help of Wikidata can you answer who is the supervisor of the supervisor of the developer of the webapp Scholia? I am looking for the supervisor of the supervisor – not just the supervisor of the developer.” It need a bit of help to get to the supervisor of the supervisor and you could also say that it forgets for instance Egon Willighagen that is also a developer of Scholia and my formal co-supervisor Jan Larsen. The first prompt results in four lookups on Wikidata: one wbsearchentities query and three entity lookups. Vanilla ChatGPT 4 with Bing search was – with my initial attempt – not able to answer the multihub question.

This approach cannot “go backwards” in the Wikidata API, e.g., if I ask “Can you with the help of Wikidata find the 3 latest articles published by Finn Årup Nielsen?” there is no relevant result as the articles are not listed on the Finn Årup Nielsen Wikidata page, but rather on the article pages (and the article pages link to the Finn Årup Nielsen Wikidata page). A SPARQL approach might be helpful here. I attempted this back in March 2023, see Wikidata and ChatGPT.