An Introduction to Markov Logic Networks in Knowledge Bases 9/30/2014 Sean Goldberg sean@cise.ufl.edu
From Big Data to Big Wisdom Data is the constant deluge of sensory information: websites, status updates, e-mails, etc. Knowledge is a set of desciptions of and relations between data, understanding how things are connected. Wisdom is being able to identify patterns in knowledge and use to infer new knowledge and understand causality in the world.
From Big Data to Big Wisdom Data is the constant deluge of sensory information: websites, status updates, e-mails, etc. Knowledge is a set of desciptions of and relations between data, understanding how things are connected. Wisdom is being able to identify patterns in knowledge and use to infer new knowledge and understand causality in the world. Data Facts Rules
What is a Knowledge Base? So with that said? What is a knowledge base? In light of the previous definition, it’s…
What is a Knowledge Base? People….
What is a Knowledge Base? Places…
What is a Knowledge Base? Organizations…
What is a Knowledge Base? Things….
What is a Knowledge Base? And the relations between them all. For clarity and brevity, I’ve left out the names of entities and relations, hoping you can follow along by context. The relation arrows can be of specific types such as “has Ally”, ‘is member of”, or ‘has father’.
Graph Representation Viewing knowledge this way is known as the graph representation of a knowledge base. How it’s stored more practicality…
Triple Representation FatherOf(Darth Vader, Luke Skywalker) memberOf(Luke Skywalker, Rebel Alliance) hasWeapon(Luke Skywalker, lightsaber) isAlliedWith(Luke Skywalker, Han Solo) IsAlliedWith(Luke Skywalker, Chewbacca) livesOn(Luke Skywalker, Tatooine) hasAdviser(Luke Skywalker, Yoda) ….. Is with the triple representation. The relation is a binary function that takes two entities and evaluates to true if the relation is shared by those entities in the knowledge base. Referring to the data one can identify by a relationa and its arguments, or use the subject-predicate-object formalism, where the first argument is the subject, the relation is the predicate, and the second argument is the object.
Large Scale KBs KnowitAll (Univ. of Washington) 500M facts extracted from 100M webpages (ClueWeb) DBPedia (Univ. of Leipzig) 3.5M entities, 700M facts extracted from Wikipedia YAGO (Max-Planck Institute) 2M entities, 20M facts extracted from Wikipedia and WordNet Freebase (Google) 20M entities, 300M facts from integrated data sources and humans NELL (Carnegie Mellon) 850M facts extracted from 500M webpages A knowledge base is any collection of such facts, but what we’re really concerned with is the domain of large-scale KBs. These are created either through automated scraping of data or large crowdsourcing efforts.
Explicit vs. Implicit Information All of the previous databases are really good at identifying explicit information. But what about common sense implicit information? Consider the following small KB with three entities and two facts.
Does Obama live in the US? If we ran the following query, the KB would check for the relation liveIn(Obama, US) and not find it. So it would return a null result or no.
Knowledge Expansion But we know this isn’t entirely right. Obama living in the white house is subsumed by Obama living in the US and one can infer using transitivity that Obama must live in the US. Adding additional knowledge to the KB through the use of inference rules is known as “Knowledge Expansion” and puts us on the road to Wisdom.
Inferring New Facts Markov Network First Order Logic Undirected graphical model Markov Property: Probabilities for each node depend only on its neighbors Most probable assignment of random variables defined by cliques HARD to figure out all the clique potentials First Order Logic Data described by predicates with arguments Logical formulas denote inference rules over predicates Deterministic, ie. no probability EASY to specify logical formulas Markov Logic: Markov Networks + First Order Logic Statistical power of MLNs + specification power of FOL
Markov Networks Smoking Cancer Asthma Cough Smoking Cancer Ф(S,C) False 4.5 True 2.7
Markov Networks Smoking Cancer Asthma Cough Weight of Feature i
First Order Logic Fact A Fact B Fact A ^ Fact B Fact C
First Order Logic isA(Luke, Jedi) memberOf(Luke, Rebel Alliance)
First Order Logic isAlliedWith(Han, Luke) ^ memberOf(Luke, Rebel Alliance) memberOf(Han, Rebel Alliance)
First Order Logic isAlliedWith(X, Y) ^ memberOf(Y, Z) memberOf(X, Z)
Soft Rules vs. Hard Rules bornIn(X, Y) ^ locatedIn(Y, Z) bornIn(X, Z)
Soft Rules vs. Hard Rules bornIn(X, Y) ^ locatedIn(Y, Z) bornIn(X, Z) HARD
Soft Rules vs. Hard Rules bornIn(X, Y) ^ locatedIn(Y, Z) bornIn(X, Z) HARD friendOf(X, Y) ^ friendOf(Y, Z) friendOf(X, Z)
Soft Rules vs. Hard Rules bornIn(X, Y) ^ locatedIn(Y, Z) bornIn(X, Z) HARD friendOf(X, Y) ^ friendOf(Y, Z) friendOf(X, Z) SOFT
Soft Rules vs. Hard Rules bornIn(X, Y) ^ locatedIn(Y, Z) bornIn(X, Z) HARD friendOf(X, Y) ^ friendOf(Y, Z) friendOf(X, Z) SOFT MLN Basic Idea: Give every formula a weight (higher weight stronger constraint)
Markov Logic Networks: Logic + Probability A Markov Logic Network is a collection of pairs (F, W) memberOf(X, Z) ^ memberOf(Y, Z) -> alliedWith(X, Y) 8.5 alliedWith(X, Y) -> alliedWith(Y, X) 100 hasLightsaber(X) -> memberOf(X, Rebels) 0.5
Building a Markov Network Nodes = all possible instantiations of a predicate Edge between two nodes iff they appear together in some formula
Han (H) Luke (L) Rebels (R) Empire (E) memberOf(X, Z) ^ memberOf(Y, Z) -> alliedWith(X, Y) 8.5
Han (H) Luke (L) Rebels (R) Empire (E) memberOf(X, Z) ^ memberOf(Y, Z) -> alliedWith(X, Y) 8.5 memberOf(H, E) memberOf(L, E) alliedWith(H, L)
Han (H) Luke (L) Rebels (R) Empire (E) memberOf(X, Z) ^ memberOf(Y, Z) -> alliedWith(X, Y) 8.5 memberOf(H, E) memberOf(L, E) alliedWith(H, L)
Han (H) Luke (L) Rebels (R) Empire (E) memberOf(X, Z) ^ memberOf(Y, Z) -> alliedWith(X, Y) 8.5 memberOf(H, E) memberOf(L, E) alliedWith(H, L) alliedWith(L, H)
Han (H) Luke (L) Rebels (R) Empire (E) memberOf(X, Z) ^ memberOf(Y, Z) -> alliedWith(X, Y) 8.5 memberOf(H, E) memberOf(L, E) alliedWith(H, L) alliedWith(L, H)
Han (H) Luke (L) Rebels (R) Empire (E) memberOf(X, Z) ^ memberOf(Y, Z) -> alliedWith(X, Y) 8.5 memberOf(H, E) memberOf(L, E) alliedWith(H, L) alliedWith(L, H) memberOf(L, R) memberOf(H, R)
Han (H) Luke (L) Rebels (R) Empire (E) memberOf(X, Z) ^ memberOf(Y, Z) -> alliedWith(X, Y) 8.5 memberOf(H, E) memberOf(L, E) alliedWith(H, L) alliedWith(L, H) memberOf(L, R) memberOf(H, R)
Han (H) Luke (L) Rebels (R) Empire (E) memberOf(X, Z) ^ memberOf(Y, Z) -> alliedWith(X, Y) 8.5 memberOf(H, E) memberOf(L, E) alliedWith(H, L) alliedWith(L, H) memberOf(L, R) memberOf(H, R)
Han (H) Luke (L) Rebels (R) Empire (E) memberOf(X, Z) ^ memberOf(Y, Z) -> alliedWith(X, Y) 8.5 memberOf(H, E) alliedWith(X, Y) -> alliedWith(Y, X) 100 memberOf(L, E) alliedWith(H, L) alliedWith(L, H) memberOf(L, R) memberOf(H, R)
Han (H) Luke (L) Rebels (R) Empire (E) memberOf(X, Z) ^ memberOf(Y, Z) -> alliedWith(X, Y) 8.5 memberOf(H, E) alliedWith(X, Y) -> alliedWith(Y, X) 100 memberOf(L, E) alliedWith(H, L) alliedWith(L, H) memberOf(L, R) memberOf(H, R)
Han (H) Luke (L) Rebels (R) Empire (E) memberOf(X, Z) ^ memberOf(Y, Z) -> alliedWith(X, Y) 8.5 memberOf(H, E) alliedWith(X, Y) -> alliedWith(Y, X) 100 hasLightsaber(X) -> memberOf(X, Rebels) 0.5 memberOf(L, E) alliedWith(H, L) alliedWith(L, H) memberOf(L, R) memberOf(H, R)
Han (H) Luke (L) Rebels (R) Empire (E) memberOf(X, Z) ^ memberOf(Y, Z) -> alliedWith(X, Y) 8.5 memberOf(H, E) alliedWith(X, Y) -> alliedWith(Y, X) 100 hasLightsaber(X) -> memberOf(X, Rebels) 0.5 memberOf(L, E) alliedWith(H, L) alliedWith(L, H) memberOf(L, R) memberOf(H, R) hasLightSaber(L) hasLightSaber(H)
Han (H) Luke (L) Rebels (R) Empire (E) memberOf(X, Z) ^ memberOf(Y, Z) -> alliedWith(X, Y) 8.5 memberOf(H, E) alliedWith(X, Y) -> alliedWith(Y, X) 100 hasLightsaber(X) -> memberOf(X, Rebels) 0.5 memberOf(L, E) alliedWith(H, L) alliedWith(L, H) memberOf(L, R) memberOf(H, R) hasLightSaber(L) hasLightSaber(H)
Han (H) Luke (L) Rebels (R) Empire (E) memberOf(X, Z) ^ memberOf(Y, Z) -> alliedWith(X, Y) 8.5 memberOf(H, E) alliedWith(X, Y) -> alliedWith(Y, X) 100 hasLightsaber(X) -> memberOf(X, Rebels) 0.5 memberOf(L, E) alliedWith(H, L) alliedWith(L, H) memberOf(L, R) memberOf(H, R) hasLightSaber(L) hasLightSaber(H)
Han (H) Luke (L) Rebels (R) Empire (E) memberOf(X, Z) ^ memberOf(Y, Z) -> alliedWith(X, Y) 8.5 memberOf(H, E) alliedWith(X, Y) -> alliedWith(Y, X) 100 hasLightsaber(X) -> memberOf(X, Rebels) 0.5 memberOf(L, E) alliedWith(H, L) alliedWith(L, H) memberOf(L, R) memberOf(H, R) hasLightSaber(L) hasLightSaber(H)
Han (H) Luke (L) Rebels (R) Empire (E) memberOf(X, Z) ^ memberOf(Y, Z) -> alliedWith(X, Y) 8.5 memberOf(H, E) alliedWith(X, Y) -> alliedWith(Y, X) 100 hasLightsaber(X) -> memberOf(X, Rebels) 0.5 memberOf(L, E) alliedWith(H, L) alliedWith(L, H) Knowledge Base: memberOf(Luke, Rebels) memberOf(Han, Rebels) hasLightSaber(Luke) ~memberOf(Luke, Empire) memberOf(L, R) memberOf(H, R) hasLightSaber(L) hasLightSaber(H)
Probability of Possible World
Probability of Possible World
Probability of Possible World Weight of formula i No. of true groundings of formula i in x
Han (H) Luke (L) Rebels (R) Empire (E) memberOf(X, Z) ^ memberOf(Y, Z) -> alliedWith(X, Y) 8.5 memberOf(H, E) alliedWith(X, Y) -> alliedWith(Y, X) 100 hasLightsaber(X) -> memberOf(X, Rebels) 0.5 memberOf(L, E) alliedWith(H, L) alliedWith(L, H) memberOf(L, R) memberOf(H, R) hasLightSaber(L) hasLightSaber(H)
Inference in MLNs MAP Inference: Find the most likely possible world given some evidence
Inference in MLNs MAP Inference: Find the most likely possible world given some evidence
Solved with MaxWalkSAT Inference in MLNs MAP Inference: Find the most likely possible world given some evidence Solved with MaxWalkSAT
Solved with MaxWalkSAT Inference in MLNs MAP Inference: Find the most likely possible world given some evidence Solved with MaxWalkSAT Marginal Inference: Find the marginal distribution of a predicate (node) given all the others
MaxWalkSAT for i ← 1 to max-tries do solution = random truth assignment for j ← 1 to max-flips do if ∑ weights(sat. clauses) > threshold then return solution c ← random unsatisfied clause with probability p flip a random variable in c else flip variable in c that maximizes ∑ weights(sat. clauses) return failure, best solution found
Han (H) Luke (L) Rebels (R) Empire (E) memberOf(X, Z) ^ memberOf(Y, Z) -> alliedWith(X, Y) 8.5 memberOf(H, E) alliedWith(X, Y) -> alliedWith(Y, X) 100 hasLightsaber(X) -> memberOf(X, Rebels) 0.5 memberOf(L, E) alliedWith(H, L) alliedWith(L, H) Knowledge Base: memberOf(Luke, Rebels) memberOf(Han, Rebels) hasLightSaber(Luke) ~memberOf(Luke, Empire) memberOf(L, R) memberOf(H, R) hasLightSaber(L) hasLightSaber(H)
Fill in Observed Data Han (H) Luke (L) Rebels (R) Empire (E) memberOf(X, Z) ^ memberOf(Y, Z) -> alliedWith(X, Y) 8.5 memberOf(H, E) alliedWith(X, Y) -> alliedWith(Y, X) 100 hasLightsaber(X) -> memberOf(X, Rebels) 0.5 memberOf(L, E) alliedWith(H, L) alliedWith(L, H) Knowledge Base: memberOf(Luke, Rebels) memberOf(Han, Rebels) hasLightSaber(Luke) ~memberOf(Luke, Empire) 1 memberOf(L, R) memberOf(H, R) 1 hasLightSaber(L) hasLightSaber(H) 1 Fill in Observed Data
Find Missing Data Han (H) Luke (L) Rebels (R) Empire (E) ? memberOf(X, Z) ^ memberOf(Y, Z) -> alliedWith(X, Y) 8.5 memberOf(H, E) alliedWith(X, Y) -> alliedWith(Y, X) 100 hasLightsaber(X) -> memberOf(X, Rebels) 0.5 memberOf(L, E) alliedWith(H, L) alliedWith(L, H) Knowledge Base: memberOf(Luke, Rebels) memberOf(Han, Rebels) hasLightSaber(Luke) ~memberOf(Luke, Empire) ? ? 1 memberOf(L, R) memberOf(H, R) 1 hasLightSaber(L) hasLightSaber(H) 1 ? Find Missing Data
Initialization Assignment Han (H) Luke (L) Rebels (R) Empire (E) memberOf(X, Z) ^ memberOf(Y, Z) -> alliedWith(X, Y) 8.5 memberOf(H, E) alliedWith(X, Y) -> alliedWith(Y, X) 100 hasLightsaber(X) -> memberOf(X, Rebels) 0.5 memberOf(L, E) alliedWith(H, L) alliedWith(L, H) Knowledge Base: memberOf(Luke, Rebels) memberOf(Han, Rebels) hasLightSaber(Luke) ~memberOf(Luke, Empire) 1 memberOf(L, R) memberOf(H, R) 1 hasLightSaber(L) hasLightSaber(H) 1 Initialization Assignment
Flip One At Random Han (H) Luke (L) Rebels (R) Empire (E) memberOf(X, Z) ^ memberOf(Y, Z) -> alliedWith(X, Y) 8.5 memberOf(H, E) alliedWith(X, Y) -> alliedWith(Y, X) 100 hasLightsaber(X) -> memberOf(X, Rebels) 0.5 memberOf(L, E) alliedWith(H, L) alliedWith(L, H) Knowledge Base: memberOf(Luke, Rebels) memberOf(Han, Rebels) hasLightSaber(Luke) ~memberOf(Luke, Empire) 1 memberOf(L, R) memberOf(H, R) 1 hasLightSaber(L) hasLightSaber(H) 1 Flip One At Random
Flip One At Random Han (H) Luke (L) Rebels (R) Empire (E) memberOf(X, Z) ^ memberOf(Y, Z) -> alliedWith(X, Y) 8.5 memberOf(H, E) alliedWith(X, Y) -> alliedWith(Y, X) 100 hasLightsaber(X) -> memberOf(X, Rebels) 0.5 memberOf(L, E) alliedWith(H, L) alliedWith(L, H) Knowledge Base: memberOf(Luke, Rebels) memberOf(Han, Rebels) hasLightSaber(Luke) ~memberOf(Luke, Empire) 1 1 memberOf(L, R) memberOf(H, R) 1 hasLightSaber(L) hasLightSaber(H) 1 Flip One At Random
Flip One At Random Han (H) Luke (L) Rebels (R) Empire (E) memberOf(X, Z) ^ memberOf(Y, Z) -> alliedWith(X, Y) 8.5 memberOf(H, E) alliedWith(X, Y) -> alliedWith(Y, X) 100 hasLightsaber(X) -> memberOf(X, Rebels) 0.5 memberOf(L, E) alliedWith(H, L) alliedWith(L, H) Knowledge Base: memberOf(Luke, Rebels) memberOf(Han, Rebels) hasLightSaber(Luke) ~memberOf(Luke, Empire) 1 1 1 memberOf(L, R) memberOf(H, R) 1 hasLightSaber(L) hasLightSaber(H) 1 1 Flip One At Random
Learning in MLNs Data is a relational database or knowledge base memberOf(Luke, Rebels) hasLightSaber(Luke) memberOf(Han, Rebels) ~memberOf(Luke, Empire)
Learning in MLNs Data is a relational database or knowledge base Learning parameters (weights) Similar to learning weights for Markov networks Knowledge Base: memberOf(Luke, Rebels) hasLightSaber(Luke) memberOf(Han, Rebels) ~memberOf(Luke, Empire)
Learning in MLNs Data is a relational database or knowledge base Learning parameters (weights) Similar to learning weights for Markov networks Learning structure (formulas) Inductive logic programming Knowledge Base: memberOf(Luke, Rebels) hasLightSaber(Luke) memberOf(Han, Rebels) ~memberOf(Luke, Empire)
Learning Weights via Max-Likelihood No. of times clause i is true in data Expected no. times clause i is true according to MLN
Alchemy (Open Source Software) Full first-order logic syntax Inference (MAP and marginal probabilities) Lifted Inference Weight Learning (generative and discriminative) Structure Learning Large set of tutorials for learning Information extraction, social network modeling, entity resolution alchemy.cs.washington.edu
Current Problem: Scale to Large KBs! KnowitAll (Univ. of Washington) 500M facts extracted from 100M webpages (ClueWeb) DBPedia (Univ. of Leipzig) 3.5M entities, 700M facts extracted from Wikipedia YAGO (Max-Planck Institute) 2M entities, 20M facts extracted from Wikipedia and WordNet Freebase (Google) 20M entities, 300M facts from integrated data sources and humans NELL (Carnegie Mellon) 850M facts extracted from 500M webpages A knowledge base is any collection of such facts, but what we’re really concerned with is the domain of large-scale KBs. These are created either through automated scraping of data or large crowdsourcing efforts.