UMBC CMSC 491/691 Fall 2022
Knowledge Graphs

Home · Schedule · HW · Exams · Notes · GitHub · Examples · Resources · Colab · Discord · Webex


Homework Ex: What does ChatGPT know about Knowledge Graphs?

out 2022-12-13, due 2022-12-23

get your repo link


This extra credit homework will let you evaluate ChatGPT's knowledge about the technologies we explored in our course.

ChatGPT

ChatGPT is a new web-based chatbot released earlier this month by OpenAI. It interacts with people using conversation and has received attention for its detailed responses and historical knowledge, although it is responses are not always completely accurate. Your goal is to test it's knowledge of the kind of semantic knowledge graphs and their underlying technologies that we've covered in this class. You assignment is to register for a free OpenAI account and use that to interact with ChatGPT, asking it to answer questions and solve six problems and comment on how well it performed.

Clone your HWex repository which will have just one file: README.md. You will use this to enter your experiments and comments.

Five true/false questions

Read OpenAI's page on ChatGPT and take a look at this article on how to use it. Choose five random True/False questions from our old midterm and final exams. Ask ChatGPT to answer each one. You may want to rephrase one of the exam questions to make it more natural. For example, the T/F question from an old exam "An XML element cannot have two attributes with the same name" might be rewritten as a "prompt" question like the following:

In XML, can an element have two attributes with the same name?

ChatGPT does a good job in answering this question, producing the following response.

No, an element cannot have two attributes with the same name in XML. Each attribute must have a unique name within an element. XML is a markup language that is used to define the structure and content of a document, and it is based on the idea of elements that contain attributes and values. In XML, each element must have a unique name, and each attribute must have a unique name within that element. If an element has two attributes with the same name, it would be considered invalid according to the XML specification.

When asking it a question, you may need to give ChatGPT several tries and/or rephrasing the question slightly to make it clearer. Like many transformer-based conversational systems, there is a degree of randomness involved and it will sometimes give a very strange response. you might try having it answer each question three times and use its best response. Take the best response you got and the prompt and add it to README.md file along with your assessment. Your evaluation should judge whether the answer was both correct, complete, easy to understand, and well written. We added our example question as an example in the README.md file

SPARQL questions

You also should ask it one question of your own that asks it to to write a SPARQL question for both DBpedia and Wikidata. For example

Write a SPARQL query for DBpedia that finds the largest city in India and its population.

which returns the following answer.

Unfortunately, I am not able to browse the web, so I cannot provide you with a specific SPARQL query for DBpedia. However, I can provide you with an example of how such a query might look. Here is an example of a SPARQL query that finds the largest city in India and its population:

	    PREFIX dbpedia-owl: <http://dbpedia.org/ontology/>
	    SELECT ?city ?population WHERE {
	          ?city a dbpedia-owl:City ;
	              dbpedia-owl:country dbpedia:India ;
	              dbpedia-owl:populationTotal ?population .
	          ?city dbpedia-owl:populationTotal ?pop .
	          FILTER(?pop = (SELECT MAX(?pop)
	          WHERE {
	            ?city a dbpedia-owl:City ;
	            dbpedia-owl:country dbpedia:India ;
	            dbpedia-owl:populationTotal ?pop .
	          }))
	      }

This query uses the PREFIX keyword to define a namespace for the DBpedia ontology, which is used to specify the types of entities that are being queried (in this case, cities and their populations). The SELECT keyword is used to specify the variables that the query should return, and the WHERE clause is used to define the constraints on these variables. In this case, the query is looking for cities that are located in India and have a populationTotal attribute, and it is filtering the results to only include the city with the highest populationTotal. Keep in mind that this is just an example, and it may not work as-is with DBpedia. To write a query that will work with DBpedia, you will need to know the specific namespaces and ontologies that are used by the DBpedia dataset, as well as the specific properties and classes that are relevant to the information you are trying to retrieve.

Ask the same question for both DBpedia and Wikidata. Your evaluation should judge whether the answer was both correct, complete, easy to understand, andwell written. You should also try to run it. If it fails to run for a simple reason, you can correct it and note this in the your evaluation comments.

What and how to submit

Your HWex repository has just the README.md file. Complete this (including the final question), commit it, and push it back to GitHub.