Lecture 9 - Knowledge Graph
Lecture 9 - Knowledge Graph
Knowledge
Graph
Lecturer: Dr. Reem Essameldin Ebrahim
This led to the development of a W3C standard called RDF (Resource Description
Framework). It is widely used withing web resources, but also within the context
of scientific data representation.
RDF is capable to link data by describing relations. It was
developed in the 1990s for the Semantic Web and inspired a
lot of approaches like Linked Open Data.
Illustrative Example
In video games, identifying the friends of a friend
of a given player using a SQL database would
have involved a cumbersome set of table joins
and conditional filters. The same task using the
Cypher query language was rather
straightforward, and the speed of those queries
on a Neo4j graph database is much greater than
the SQL equivalent.
Mathematical Definition
We define a knowledge graph as a graph
𝐺 = (𝐸, 𝑅) , with entities 𝑒 ∈ 𝐸 = 𝐸1
∪ 𝐸2 ∪ … ∪ 𝐸𝑛 , coming from formal
structures 𝐸𝑖 and relations 𝑅.
where 𝐸1 = 𝐴1 , … , 𝐴𝑚 is a set of 𝑚
actors, forms an extended social network.
All other structures 𝐸2 , … , 𝐸𝑛 describe data
from other sources or other domains. Both
𝐸 and 𝑅 are finite discrete spaces.
Example:
Mona Lisa (a node) and Da Vinci
(another node) and they are connected
with the relationship type (paintedBy).
Moreover, nodes will have connected
attributes like data of births, death, etc.
Knowledge Graph
Applications
One very popular application is how information is served. So, knowledge graph
essentially what powers Google on the internet. For example, for the query “latest films
by the director of titanic”, Google has to figure out what titanic is, what director is, what
is the relation between director and titanic and then what is the relation between this
director and the other the latest films. Therefore, given this query it was able to give all
this different answers.
Question answering agents
Knowledge Graph
Applications
Siri or any of these modern conversational agents, are powered essentially by
knowledge graphs. For example, if you say something like that first query in the above
given Figure, many different entities are extracted (e.g. travel, thanksgiving, NY, etc.).
Then it has to figure out the relations between these entities and provide answers
accordingly.
Knowledge Graph – Representation
How do we represent knowledge graph is very important because that will
essentially help us to query and reason about these knowledge graphs. One
popular way to do that is heterogenous networks.
Example
Bibliographic networks have the schema:
We just have one type of node, but This schema type has two or more one type of node.
there are a lot different types of In this example, we have nodes that represent
edges. In this example, different documents and other represent words. This schema
users are connected to each other says documents contain words. Each paper with
via different types of relationships certain words will be connected to them.
Copyright © Dr. Reem Essameldin 2023-2024
Types of Network Schema
Common network schema of heterogeneous networks
We have one central type of nodes, In this schema type we have two or more central
and the other nodes types can be types of nodes (hub; node with multiple connections)
treated as attributes of this type each has its attributes (connections to other types of
node. E.g. a paper can has an nodes). E.g. genes are connected with other genes
attribute of venue. with chemical reactions.
Copyright © Dr. Reem Essameldin 2023-2024
Multi-hub network schema
Example
We have nodes representing users,
posts, words, and communities. This
schema says that users can subscribe to
communities, posts belongs to
communities. Users create posts, can
upvote posts and downvote posts.
Where posts contains words.
Note that:
There is no self loop on the “user” node type; this
means users are not connected to each others. They
only can subscribe to communities, create posts, etc.
Instead, two users are considered connected if they
subscribe to the same community. The two nodes are
connected via the common interaction (Meta-path).
We can consider one path instance where, Jim write paper 1 (P1) and Ann is a co-author of that.
Ann has two different authors for two different papers. In figure, meta-paths are sequences of
paths, author write a paper and the paper is written by the author.
Examples:
𝑊𝑟𝑖𝑡𝑒 𝑊𝑟𝑖𝑡𝑒 −1
co-author relation: 𝐴 𝑃 A (short for A-P-A)
Note that:
Relations can be inverted to query in reverse direction.
E.g., write(Author) gives Paper while 𝑊𝑟𝑖𝑡𝑒 −1 (Paper) gives Author
Note that:
What we are doing is that we are trying to find relationships between end nodes. In
figure, what is the relationship between two authors (they write the same paper).
Copyright © Dr. Reem Essameldin 2023-2024
Meta-Paths Composing Meta-paths
Given a network schema and an instantiation of the network, meta-paths can be
composed. Thus, the composed meta-path can have different meaning than the
individual meta-paths.
Meta-path 1: P-A-P (Papers by same author)
Meta-path 2: P-V-P-A (Author of a paper published at same venue)
Note that:
The meaning of that composed path is that papers published by similar experts in the same
area. In the figure the two authors worked in the same area as they published in the same
venue. This meta-path returns papers that are written by authors that work in the same area.
Copyright © Dr. Reem Essameldin 2023-2024
Meta-Paths Composing Meta-paths - Example
Note that:
Different meta-paths give different results. They can be generated using domain knowledge or
expertise. In general, given a network schema you can answer interesting questions like the
one given in that example even without doing any computer vision (just from the knowledge graph)
Copyright © Dr. Reem Essameldin 2023-2024
Important KG Tasks