An Introduction to Knowledge Graphs
A comprehensive guide to Knowledge Graphs and their applications
Knowledge Graphs (KGs) represent complex relationships. By organizing data into a network of interconnected entities and relationships, knowledge graphs provide a structured way to represent information and extract insights.
In traditional data systems, information is often stored in siloed databases, making it difficult to extract meaningful insights. For instance:
- Disconnected Data: Systems that store data independently struggle to provide a unified view.
- Implicit Relationships: A relationship may be clear within one application but hard to interpret when its data is shared.
- Search Limitations: Searching across structured and unstructured data seamlessly is challenging.
A directory could use one source for its blogs and another for its authors. If the blog's owner field links to a named entity in those records, we can follow a blog to its owner even when the blog entry has no name for that person. The useful part is being able to ask a question across sources without losing track of what each thing represents.
What is a Knowledge Graph (KG)?
A knowledge graph describes entities and the relationships between them. The entities are nodes in the graph, and the relationships are edges. In this series, we bring records from different sources together using RDF, the Resource Description Framework. We use an ontology to define the kinds of things in our graph and what their relationships mean.
Google helped popularize the term when it introduced its Knowledge Graph in search results in 2012. Decades earlier, E. W. Schneider used the phrase for a graph of concepts a student needed to learn and the prerequisites connecting them. He presented the paper in 1972 and published it the following year. Google's Knowledge Graph announcement · Schneider's paper
LinkedIn's Economic Graph connects people, skills, companies and jobs. Researchers have proposed several definitions of a knowledge graph. Some emphasize the entities and their connections, while others require a schema or a particular way of representing the data. Ehrlinger and Wöß collected the examples below. LinkedIn's graph engineering team · Towards a Definition of Knowledge Graphs
| Definition | Source |
|---|---|
"A knowledge graph (i) mainly describes real-world entities and their interrelations, organized in a graph, (ii) defines possible classes and relations of entities in a schema, (iii) allows for potentially interrelating arbitrary entities with each other and (iv) covers various topical domains." | Paulheim 1 |
"Knowledge graphs are large networks of entities, their semantic types, properties, and relationships between entities." | Krötzsch and Weikum, Journal of Web Semantics call for papers |
"Knowledge graphs could be envisaged as a network of all kinds of things which are relevant to a specific domain or to an organization. They are not limited to abstract concepts and relations but can also contain instances of things like documents and datasets." | Semantic Web Company 2 |
"We define a Knowledge Graph as an RDF graph. An RDF graph consists of a set of RDF triples where each RDF triple (s, p, o) is an ordered set of the following RDF terms: a subject s ∈ U ∪ B, a predicate p ∈ U, and an object o ∈ U ∪ B ∪ L. An RDF term is either a URI u ∈ U, a blank node b ∈ B, or a literal l ∈ L." | Färber et al. 3 |
"[...] systems exist, [...], which use a variety of techniques to extract new knowledge, in the form of facts, from the web. These facts are interrelated, and hence, recently this extracted knowledge has been referred to as a knowledge graph." | Pujara et al. 4 |
When is a Knowledge Graph useful?
1. Is your data highly connected?
Graph solutions are useful when the relationships are part of the question. A directory might need more than a list of blogs: who owns each blog, who administers it, and which source supports that information? Those links deserve names and definitions of their own.
2. Do your questions cross data sources?
One source might describe a person, another their blog, and a third an appointment to administer it. The challenge is deciding when those records refer to the same things and how their claims fit together. A knowledge graph gives us a place to represent those decisions explicitly. It doesn't resolve conflicting sources just because we've loaded them into the same database.
3. Does your model change as you learn more?
We may start with ownership and later need appointment dates, roles, or source records. RDF lets us add those descriptions without requiring every resource to have the same fields. We still need to agree on the meaning of each property and check that incoming records meet the application's requirements.
These are questions about the data and what we want to do with it. Query performance also depends on the database, indexes, workload, and deployment; choosing a graph representation alone doesn't settle it.
Graphs as data structures
A graph is a non-linear data structure consisting of vertices and edges. The vertices are also called nodes, and the edges connect them. A directed edge has a source and a target. A labeled edge tells us what the connection means.
For example, a link from a blog to its owner has a direction. Reading it backwards changes the question: from “who owns this blog?” to “which blogs does this person own?” An application can follow either direction while preserving the meaning of the relationship.
A directed edge-labeled graph (or multi-relational graph 678) is a set of nodes connected by directed, labeled edges. Different relationships can connect the same nodes, and connections can form cycles. We don't need to squeeze the data into a tree.
Representing the graph with RDF
The Resource Description Framework (RDF) represents information as triples: a subject, a predicate, and an object. The subject is the thing being described, the predicate names the relationship, and the object is the related thing or a value. Together they form one statement.
RDF uses IRIs, or Internationalized Resource Identifiers, to name things and relationships. A literal represents a value, such as a name or a date. RDF also supports blank nodes for things described without an IRI. The RDF article goes into the term rules and syntax; here, we only need enough to read the model.
Let's describe Ahmad and his blog. This is Turtle, a text format for RDF:
The prefixes abbreviate IRIs. The shorthand a means “is an instance of,” and each semicolon continues describing the same subject with another predicate. So the last three lines say that this resource is a blog, give its name, and link it to Ahmad as its owner.
Suppose Ahmad renames the blog tomorrow. We change the aa:hasName value. The IRI stays the same, so its ownership link still refers to that blog. This separation between identity and a display name matters when descriptions come from different sources.
A predicate is identified by an IRI too. We can make statements about aa:owner, define its relationship to other properties, and share those definitions with the data. RDF provides the common representation. The vocabulary tells readers what the terms mean. RDF 1.1 Concepts
From identity to validation
Suppose we import Ahmad's blog into the directory a second time. The new record gives us the same IRI and still says it's a blog, but this time the title is missing. We know which blog the record describes. Do we have enough to accept the update?
| Question | What we need |
|---|---|
Identity · Which blog is this? | Both records use http://assaf.website/blog. Changing its title leaves that IRI intact. |
Representation · Where does the title live? | The title is the object of an aa:hasName triple whose subject is the blog. |
Meaning · Does the blog count as a website? | In RDF Schema (RDFS), we can declare aa:Blog a subclass of schema:WebSite, the website class from Schema.org. A reasoner can then infer that this blog is a website. |
Querying · What title should we display for Ahmad's blog? | SPARQL, the RDF query language, matches a blog with aa:owner :ahmadassaf, then reads its aa:hasName value. |
Quality · Can we accept a record without a title? | With the Shapes Constraint Language (SHACL), we can require an aa:hasName value for each aa:Blog. Validating this incoming record reports the missing title. |
One importer can handle both the identity lookup and the title check. If we merge the incoming RDF into the directory before checking it, the old title can satisfy the shape. We'd have checked the directory when what we wanted to check was the submission.
The Web Ontology Language (OWL) lets us express more involved definitions, such as a category for people who own at least one blog. My introduction to the Semantic Web explains how the directory can use that definition.
Sharing the descriptions
RDF gives us a common format for combining descriptions. If two files use the same IRI for the blog, their statements describe the same resource when we combine them. If the files use different IRIs, a matching display name alone doesn't establish that they mean the same blog.
The vocabulary is also shareable RDF. Classes, property definitions, and instance data can be published together or separately. Text literals can carry language tags, and other literals can carry datatypes, so a receiving application can distinguish a date from an ordinary string.
Standard formats such as Turtle, RDF/XML, and JSON-LD let applications exchange the graph. SPARQL provides a standard way to query it. This makes it easier to move and reuse data, though database-specific features and operational choices still need attention when migrating an application.
What makes this a knowledge model?
Recording the ownership link is a start. We also need to say what we mean by a blog and an owner, distinguish ownership from administration, and retain the sources behind disputed information. Those decisions make the data useful beyond the application that first recorded it.
There isn't a universally agreed threshold at which an RDF graph becomes a knowledge graph; the definitions above differ. For our purposes, the useful test is whether its connected descriptions and definitions let us interpret and query the domain consistently. A collection of RDF statements can carry very little domain meaning, or it can represent a detailed model. The serialization doesn't decide that for us.
The same graph can serve as a database we query, a network we analyze, and a knowledge base from which we derive conclusions. Those conclusions depend on the supplied facts and definitions. A reasoner cannot establish that an ownership claim is true in the world simply because a source asserted it.
Why Knowledge Graphs are interesting for ML
Knowledge graphs can also supply structure to machine learning applications: types, relationships, and context that might otherwise be missing from the training data. Hogan et al.'s survey covers how deductive and inductive techniques contribute to building and using knowledge graphs.
Data insufficiency
When training data is sparse, graph information can help construct additional examples or features. Replacing an entity with another of the same type is one possible augmentation technique, but the resulting example still needs to make sense. If we substitute a different person for Ahmad in an ownership triple, the result makes a new ownership claim. Sharing the type foaf:Person tells us nothing about whether that claim is true.
Zero-shot learning
Zero-shot learning asks a model to handle classes it hasn't seen during training. Descriptions and relationships between classes can supply information about those unseen classes. A knowledge graph can provide that context; it doesn't make an unseen class predictable without a learning method that uses it.
Explainability
A graph can make the evidence behind a result inspectable. If a system lists Ahmad's blog as a website, we can show the blog's classification and the definition that made it a website. For a learned prediction, however, a related graph path is only an explanation if it reflects how the system actually reached the result.
References
- Heiko Paulheim (2016). Knowledge graph refinement: A survey of approaches and evaluation methods. Semantic Web. View source
- Andreas Blumauer (2016). From Taxonomies over Ontologies to Knowledge Graphs.
- Michael Färber and Achim Rettinger (2015). A Statistical Comparison of Current Knowledge Bases. International Conference on Semantic Systems. View source
- Jay Pujara and Hui Miao and Lise Getoor and William W. Cohen (2013). Knowledge Graph Identification. International Workshop on the Semantic Web. View source
- Lisa Ehrlinger and Wolfram Wöß (2016). Towards a Definition of Knowledge Graphs. International Conference on Semantic Systems. View source
- Maximilian Nickel and Volker Tresp (2013). Tensor factorization for multi-relational learning. Machine Learning and Knowledge Discovery in Databases - European Conference, ECML PKDD 2013, Prague, Czech Republic, September 23-27, 2013, Proceedings, Part III. View source
- Antoine Bordes and Nicolas Usunier and Alberto Garcı́a-Durán and Jason Weston and Oksana Yakhnenko (2013). Translating Embeddings for Modeling Multi-relational Data. Advances in Neural Information Processing Systems 26: 27th Annual Conference on Neural Information Processing Systems 2013. Proceedings of a meeting held December 5-8, 2013, Lake Tahoe, Nevada, United States. View source
- Ivana Balazevic and Carl Allen and Timothy M. Hospedales (2019). Multi-relational Poincaré Graph Embeddings. Advances in Neural Information Processing Systems 32: Annual Conference on Neural Information Processing Systems 2019, NeurIPS 2019, 8–14 December 2019, Vancouver, BC, Canada. View source
The opinions and views expressed on this blog are solely my own and do not reflect the opinions, views, or positions of my employer or any affiliated organizations. All content provided on this blog is for informational purposes only.
I'm glad to speak at events, join a panel or a podcast, or compare notes on AI, knowledge graphs and engineering leadership. Get in touch if you'd like to talk.