CV Courseversity

Knowledge Graphs

Introduces knowledge graphs as directed labeled graphs of entities and relations, covering how they are built and curated, how embeddings turn discrete triples into vectors for learning, and how querying, completion, and reasoning operate over inherently incomplete graphs.

“Search for a well-known person's name and a search engine often answers with a box of facts and connections rather than a list of blue links: birthplace, occupation, the people they worked with. That box is a knowledge graph answering your query as a network of things, not a match of strings. How does a system store hundreds of millions of entities and billions of relations between them, keep that structure queryable, and still make sound new inferences — like guessing a missing fact or ranking a plausible but unstated connection — without a human writing down every single fact by hand?”

Entities, Relations, and Graph Construction · 15 min

A knowledge graph represents the world as a set of triples — (subject, predicate, object) — where subjects and objects are entities such as people, places, organizations, or concepts, and predicates are the relations that connect them, such as born_in, employed_by, or part_of. Formally this is a directed, labeled multigraph: nodes are entities, edges are relations, and the same pair of entities can be connected by more than one relation at once. This structure differs sharply from a relational database table, which fixes a schema of columns in advance; a knowledge graph instead lets new entity types and relation types be added incrementally as the domain grows, and it makes the connections between records first-class, queryable objects rather than something a query must reconstruct through joins. Many knowledge graphs also carry a schema or ontology layer above the raw triples — classes, subclass hierarchies, and constraints on which relations can hold between which types of entities — that supports consistency checking and more structured reasoning over the data, an approach sometimes called ontological engineering.

Building a knowledge graph at scale draws on two complementary sources: curated structured data (encyclopedic infoboxes, government registries, licensed databases) and automated extraction from unstructured text using named-entity recognition and relation-extraction techniques that identify mentions of entities and the relations asserted between them in sentences. The shift toward this entity-centric view was made vivid to the public in 2012, when Google announced its Knowledge Graph as a move from "strings" — treating a search query as a bag of characters to match — to "things": real-world entities disambiguated from one another (the Taj Mahal the monument versus the Taj Mahal the musician) and enriched with a summary of connected facts. At launch, Google described the graph as containing more than 500 million objects and over 3.5 billion facts about the relationships among them, built in part from open sources such as Wikipedia and augmented and tuned using patterns observed in user search behavior. That announcement is a useful industry data point about scale and motivation, not a peer-reviewed account of the underlying methods, and the field's academic literature is where the construction techniques themselves are documented and compared.

Because knowledge graphs are assembled from heterogeneous, imperfect sources, construction does not end at initial population. Ongoing work distinguishes open knowledge graphs, built and published for broad reuse, from enterprise knowledge graphs, built internally around an organization's own data and products, and both require continual enrichment (adding new facts), quality assessment (detecting errors and duplicate entities), and refinement (correcting or removing incorrect triples) as the underlying world changes and new sources are integrated. The schema layer plays a direct role in this maintenance: well-defined classes and relation constraints make some errors mechanically detectable, for instance when a triple asserts a relation between two entities of the wrong types, while looser or missing schemas leave more of the burden on statistical and learned quality-assessment methods. Identity also has to be managed explicitly, since the same real-world entity is frequently mentioned under different names or identifiers across sources — resolving those mentions to a single canonical node, sometimes called entity resolution or entity linking, is itself a nontrivial part of construction, because merging two distinct entities incorrectly is just as damaging to a graph's usefulness as failing to merge two mentions of the same one.

Embeddings and Representation Learning · 15 min

Triples are discrete and symbolic, which makes them awkward inputs for statistical and neural methods that expect continuous, comparable representations. Knowledge graph embedding addresses this by learning a vector for every entity and every relation such that the geometry of the vector space reflects the graph's structure, enabling machine-learning techniques to generalize beyond the triples that were explicitly observed. The best-known early approach, TransE, treats a relation as a translation operating on entity vectors: for a true triple (h, r, t), the entity vector for the head h plus the relation vector r should land close to the entity vector for the tail t, so that h + r ≈ t in the shared embedding space. Training minimizes the distance between h + r and t for observed true triples while pushing that same sum away from the vectors of entities involved in corrupted, almost-certainly-false triples generated by swapping the head or tail — a discriminative signal that shapes the embedding space without requiring explicit negative facts to be supplied by hand.

TransE was deliberately designed to be lightweight: it uses far fewer parameters than earlier multi-relational factorization approaches, which lets it scale to large graphs, and the original evaluation trained it on knowledge bases with on the order of a million entities, tens of thousands of relations, and tens of millions of training triples, reporting that it significantly outperformed the prior state of the art on link-prediction benchmarks built from Freebase and WordNet. Achieving that result with so few parameters per entity and relation was itself part of the contribution, since it meant the model's training and storage costs grew gently with the size of the graph rather than exploding as more relation types were added, which mattered directly for whether the approach could plausibly scale toward graphs the size of Freebase or larger. That translation-based idea proved to be a starting point rather than an endpoint: because a single additive operation makes strong geometric assumptions about how relations compose, later embedding research explored alternative scoring functions — bilinear interactions, complex-valued embeddings, and small neural networks — each trading off expressiveness, training cost, and interpretability differently, and the space of embedding architectures remains an active area of comparison rather than a settled question.

Once learned, embeddings support tasks beyond reproducing the training triples: ranking candidate entities for link prediction, measuring semantic similarity between entities whose vectors are close together, and feeding downstream models such as recommender systems or search ranking with a compact numeric summary of an entity's position in the graph. Evaluation for these tasks typically corrupts a held-out true triple by replacing its head or tail with every other entity in the graph, has the model score every resulting candidate, and reports where the true entity ranks among them — a link-prediction protocol that mirrors the same head/tail corruption idea used during training. A genuinely open research front concerns how well these representations generalize to entities the model has rarely or never seen during training — the few-shot and inductive setting — and how embedding-based methods can be combined with symbolic, rule-based reasoning over the same graph rather than treated as a separate, purely statistical alternative to it.

Querying, Completion, and Reasoning · 15 min

Querying a knowledge graph typically means specifying a graph pattern — a small subgraph with some nodes left as variables — and asking the system to find all bindings of those variables that make the pattern match triples actually stored in the graph, the approach underlying graph query languages built for this purpose. This kind of exact pattern matching is precise but brittle: if the specific triple needed to satisfy the pattern was never extracted or curated, the query returns nothing, even if the fact is true in the world and only missing from the graph. That gap matters because every real knowledge graph is incomplete by construction, and it motivates treating the graph under an open-world assumption — the absence of a triple is treated as unknown rather than as a guarantee that the corresponding fact is false — in contrast to the closed-world assumption common in traditional databases, where anything not stated is simply taken to be false.

Knowledge graph completion, often operationalized as link prediction, is the problem of proposing the missing triples that make an incomplete graph more complete, and it draws on several complementary strategies: rule-based methods that mine logical patterns from the existing graph (for example, that a mother's spouse tends to be a father of the same children) and apply them to infer new facts; embedding-based methods that rank candidate triples by their learned plausibility score; and hybrid approaches that use ontological entailment — subclass and relation-hierarchy reasoning defined by the schema — to derive facts that follow logically from what is already asserted, complementing statistical guesses with facts that are logically guaranteed rather than merely likely. These strategies do not always agree, and combining a rule that is logically sound with a statistical score that is only probabilistically supported is itself a design choice with real consequences for how much to trust an inferred triple.

Knowledge graph completion and reasoning remain active research areas rather than solved engineering problems: open questions include how to combine symbolic and neural reasoning coherently (an area often called neuro-symbolic reasoning), how to keep multi-hop inference chains — reasoning that strings several relations together to answer a query no single triple can answer alone — both accurate and explainable to a human user, and how to do all of this at genuinely web- or enterprise-scale graphs with billions of edges. Recognizing that this is unsettled territory, rather than treating any one current technique as a final answer, is itself part of understanding the field's actual state. A useful habit when evaluating a claimed completion or reasoning result, in coursework or in the literature, is to ask which of these strategies produced it — a logically sound schema entailment, a statistically ranked embedding guess, or some blend of the two — since that distinction determines how much confidence the inferred fact actually deserves.

Practice

A Knowledge Graph Fragment

Marie Curie Warsaw Pierre Curie Physics born_in spouse field field

Four entities linked by three relation types; because Marie Curie and Pierre Curie both connect to the shared node Physics via the field relation, a two-hop query over this fragment can infer that they worked in the same field without that connection being stored as its own triple.

  • A knowledge graph's core unit is the triple (subject, predicate, object); the value of the graph comes from how many triples share entities, since shared nodes are what make multi-hop queries and indirect inferences possible.
  • Embedding methods like TransE turn discrete graph structure into continuous vectors precisely so that statistical and neural methods can generalize to triples never explicitly observed, rather than being confined to models pattern-matching only against exact stored facts.
  • Because every real knowledge graph is incomplete, treating a missing triple as merely unknown rather than false (the open-world assumption) is what motivates completion as a genuine inference problem instead of dismissing it as pointless.

Recall Practice

TriplesClick to reveal
What three components make up a knowledge graph triple, and which two of them are typically entities?
A triple consists of a subject, a predicate (relation), and an object; the subject and object are typically entities, while the predicate is the labeled, directed relation connecting them.
TransEClick to reveal
In plain language, what does TransE assume about how a relation acts on a head entity's vector?
TransE assumes a relation behaves like a translation: adding the relation's vector to the head entity's vector should land close to the tail entity's vector, so h + r ≈ t for true triples.
Open-worldClick to reveal
Why does the open-world assumption matter for interpreting a knowledge graph query that returns no results?
Because the graph is inherently incomplete, a query returning nothing means the specific triple was not found in the graph — it does not prove the fact is false in the real world, which is why completion methods are needed rather than treating absence as negation.
CompletionClick to reveal
Name two different strategies used for knowledge graph completion and one reason they might disagree.
Rule-based methods mine logical patterns from existing triples and apply them to infer new facts, while embedding-based methods rank candidate triples by a learned plausibility score; they can disagree because a rule-derived fact is logically guaranteed given the rule's premises while an embedding-derived fact is only statistically likely, so the two can assign different confidence to the same candidate triple.

Glossary

Triple
The atomic unit of a knowledge graph: a (subject, predicate, object) statement asserting a directed relation between two entities.
Entity
A distinct real-world or abstract object represented as a node in a knowledge graph, such as a person, place, or concept.
Ontology
A schema layer defining classes, subclass hierarchies, and constraints on which relations can hold between which entity types, supporting consistency checking and structured reasoning.
Knowledge graph embedding
A learned mapping from entities and relations to vectors in a continuous space, designed so the geometry of the space reflects the graph's structure.
Open-world assumption
The convention that a missing triple is treated as unknown rather than false, appropriate for graphs that are known to be incomplete.
Link prediction / knowledge graph completion
The task of proposing plausible missing triples to fill gaps in an incomplete knowledge graph.
Practical Activity

Hand-Build a Knowledge Graph Fragment and Trace a Toy Embedding Score

This is a fully paper-based simulation — no software is run and no real data is fetched. Part 1: on paper, build a small knowledge graph of 6–8 triples about a domain of your choosing (e.g., a family tree, a set of films and their directors and actors, or a handful of courses and prerequisites), writing each fact as (subject, predicate, object) and drawing it as a labeled directed graph. Part 2: pick one true triple from your graph and assign small 2-D integer vectors by hand to its subject, relation, and object to check a TransE-style score. For example, with head vector h = (1, 2), relation vector r = (3, 1), and tail vector t = (4, 3): h + r = (4, 3), which exactly matches t, giving a distance of 0. Now construct one corrupted triple by swapping in a different, false tail, assign it a tail vector such as t' = (5, 6), and compute the Euclidean distance from h + r = (4, 3) to t': the differences are (5-4, 6-3) = (1, 3), so the squared distance is 1² + 3² = 10 and the distance is √10 ≈ 3.16. Confirm by hand that the true triple's distance (0) is smaller than the corrupted triple's distance (≈3.16), which is exactly the signal a real embedding model would use to prefer the true fact over the false one. Write two sentences explaining, in your own words, why a smaller distance corresponds to a more plausible triple.

Ready to test yourself?

5 questions on this module.

Start Quiz