Building Knowledge Graph using wiki data

Sai Praveen
Everything is Connected
5 min readMay 12, 2023

Discover the Hidden Connections of Knowledge with Wiki data — The Ultimate Knowledge Graph!

Welcome to the first part of our “Everything is Connected” series. This blog will brief you about knowledge graphs, why we need them in our technology-oriented world, and how you can create one using Wiki data.

In this series, we are going to talk about knowledge graphs, how they work, why we should use them, and making three separate knowledge graphs using wiki data for Wikipedia articles (part-1), knowledge graph for Times Now articles using GraphGPT (part-2), and last but not the least knowledge graph for Cricinfo using protege(Part-3).

Everything in the world is connected, from the smallest living cell to the enormous expanse of the universe. These linkages can also be mapped to the world of knowledge or data. This is where knowledge graphs come into play. Just as human brains use mind maps to visualize better and understand the world, knowledge graphs can be created from existing datasets to transform the way we store knowledge and discover previously unnoticed insights and interconnections.

What are Knowledge Graphs?

A knowledge graph is a data structure that models tangible things in the real world as objects (or entities) and illustrates their connections (predicates). The subject, predicate, and object are its three fundamental parts. The statement’s subject, representing the thing being discussed, acts as its main point of attention. On the other hand, the predicate exemplifies the connection between the subject and the object. The object also shows the value or thing that the subject is related to. In this structure, nodes represent entities (people, places, or things), while edges stand for the connections between these entities. This complex illustration enables a more thorough and linked comprehension of content.

One benefit of organizing information in this way is that knowledge graphs make it easier to make sense of complex data and gather previously unknown insights quickly through statistical and analysis techniques.s.

By Jayarathina — Own work, CC BY-SA 4.0, https://commons.wikimedia.org/w/index.php?curid=37135596

Google’s knowledge card is a real-life example of knowledge graphs in action. Whenever a user searches a query, say “Leonardo da Vinci,” the Knowledge Graph will provide information about his life, his famous works of art, and other related entities such as his contemporaries and the places he lived and worked.

This type of optimization was not possible by previously known data management systems such as relational databases and data warehouses. With the increasing complexity of data today, more than these traditional systems are needed to capture rich relationships and connections between entities.

Applications of knowledge graphs

  • Web Search/ Queries

A popular application of knowledge graphs is in web searches and querying information from data sources. Search Engines like Google provide their users with optimized results. That is relevant to the query. When a user enters a search query, search engines can use the Knowledge Graph to identify and display relevant web links to provide specific information directly to the search results. This approach saves users time and gives them a complete understanding of their search topic.

  • Data Integration

Data from various sources is brought together and linked to form a connected knowledge network. For example, a company provides telecommunication services and an e-shopping service. The same user has registered on both services. It would be helpful if we identify that the registered user on both services is the same so that we can provide better insights to the user so that they can make data-driven decisions. This identification can be done quickly using a knowledge graph.

  • ML Algorithms

We can use Knowledge graphs to apply machine learning algorithms in fields like natural language processing (NLP) and object detection (computer vision). In the case of NLP, the user input has used to build and represent the relationships between words and concepts, allowing for more accurate and context-aware language models. Additionally, knowledge graphs can be used in object detection tasks, which can help identify and categorize objects based on their properties and relationships to other objects in the graph.

Creating Knowledge Graphs for Wikipedia Data using Wiki data

Wiki data is a free, open-source Knowledge graph created by the Wikimedia Foundation. It is a centralized repository for all Wikipedia and Wiki data project information. One can use Wiki data’s structured data to generate knowledge graphs. Below are the steps to see how one can access knowledge graphs on Wiki data.

Step 1:

Go to https://www.wikidata.org/wiki/Wikidata:Main_Page

You can search any topic you want in the search bar located at the top right corner.

Step 2:

Every Wikipedia article has a QID that uniquely identifies itself on Wiki data. They start with the letter “Q” or “P” and are beside the article’s title. Make sure you copy this QID.

Now click the “Query Service” link in the website’s left panel.

This will open the query service window where you can enter SPARQL queries to search through the Wikipedia database.

Step 3:

Query to search the article in the knowledge graph:

SELECT DISTINCT ?subjectLabel ?subject ?property ?object WHERE {

?subject ?property ?object .

bd:serviceParam wikibase:language “en” .

}

#defaultView:Graph

Just copy the QID of any Wikipedia article and replace it with Q1107 to view the knowledge graph of other articles of your liking.

Enter this query and click the blue play button to view the result.

Step 4:

Now the knowledge graph is visible on the bottom panel of the website. You can click on the link nodes to visit other related articles or click on nodes to see and study the ontology.

Useful resources

  1. Wiki data Website

2. Research paper

https://web.stanford.edu/~vinayc/kg/Knowledge_Graphs_v16.pdf

Conclusion

In a nutshell, knowledge graphs are unique tools for storing, organizing, and integrating data from different distinct sources. They create an informative and interconnected web of knowledge by making entities(nodes) and connecting them via their relationships(edges). This structure enables us to perform better, more powerful search and analysis capabilities, which would be a herculean task with other approaches/databases.

Authors — Reva Bharara, Aryan Rathore

--

--