Presentation is loading. Please wait.

Presentation is loading. Please wait.

First Order Representations and Learning coming up later: scalability!

Similar presentations


Presentation on theme: "First Order Representations and Learning coming up later: scalability!"— Presentation transcript:

1 First Order Representations and Learning coming up later: scalability!

2 Announcements PIG assignment (last one) is out Added some other examples to the “PIG workflow” lecture, as well as pointers to documentation, etc. PIG has been installed on Gates cluster see docs on cluster on course page Sample exam questions will be out soon (Friday?) think about the non-programming exercises in the HWs also Exam is 4/30 (in-class)

3 A little history Tasks you do well: Recognizing human faces Character recognition (7 vs 4) Simulations of physical events Understanding statements in natural language Proving mathematical theorems Playing chess, Othello, … Solving logic puzzles (Soduko) logical approaches statistical approaches

4 Logical approaches “All men are mortal, Socrates is a man, so Socrates is mortal”. for all X: man(X)  mortal(X) man(socrates) for all W,X,Y,Z: father(X,Y) & mother(X,Z) & father(W,Y) & father(W,Z) & W!=X sibling(X,W) for all X: feedsYoungMilk(X)  mammal(X) for all X: mammal(X)  hasSpine(X) quantification: for all, there exists plus logical connectives: and, or, … quantification: for all, there exists plus logical connectives: and, or, …

5 Markov Logic Networks Mostly pilfered from Pedro’s slides

6 Motivation The real world is complex and uncertain Logic handles complexity Probability handles uncertainty

7 MLN’s Bold Agenda: “Unify Logical and Statistical AI” FieldLogical approach Statistical approach Knowledge representation First-order logicGraphical models Automated reasoning Satisfiability testing Markov chain Monte Carlo (e.g. Gibbs) Machine learningInductive logic programming Neural networks, …. PlanningClassical planning Markov decision processes Natural language processing Definite clause grammars Prob. context- free grammars

8 Markov Networks: [Review] Undirected graphical models Cancer CoughAsthma Smoking Potential functions defined over cliques SmokingCancer Ф(S,C) False 4.5 FalseTrue 4.5 TrueFalse 2.7 True 4.5

9 Markov Networks Undirected graphical models Log-linear model: Weight of Feature iFeature i Cancer CoughAsthma Smoking

10 Inference in Markov Networks Goal: Compute marginals & conditionals of Exact inference is #P-complete Conditioning on Markov blanket is easy: Gibbs sampling exploits this

11 MCMC: Gibbs Sampling state ← random truth assignment for i ← 1 to num-samples do for each variable x sample x according to P(x|neighbors(x)) state ← state with new value of x P(F) ← fraction of states in which F is true

12 Overview Motivation Foundational areas Probabilistic inference [Markov nets] Statistical learning Logical inference Inductive logic programming Putting the pieces together MLNs Applications

13 Learning Markov Networks Learning parameters (weights) Generatively Discriminatively Learning structure (features) In this tutorial: Assume complete data (If not: EM versions of algorithms)

14 Generative Weight Learning Maximize likelihood or posterior probability Numerical optimization (gradient or 2 nd order) No local maxima Requires inference at each step (slow!) No. of times feature i is true in data Expected no. times feature i is true according to model

15 Pseudo-Likelihood Likelihood of each variable given its neighbors in the data Does not require inference at each step Consistent estimator Widely used in vision, spatial statistics, etc. But PL parameters may not work well for long inference chains

16 Discriminative Weight Learning Maximize conditional likelihood of query ( y ) given evidence ( x ) Approximate expected counts by counts in MAP state of y given x [Like CRF learning – WC] No. of true groundings of clause i in data Expected no. true groundings according to model

17 Overview Motivation Foundational areas Probabilistic inference [Markov nets] Statistical learning Logical inference Inductive logic programming Putting the pieces together MLNs Applications

18 First-Order Logic Constants, variables, functions, predicates E.g.: Anna, x, MotherOf(x), Friends(x, y) Literal: Predicate or its negation Clause: Disjunction of literals Grounding: Replace all variables by constants E.g.: Friends (Anna, Bob) World (model, interpretation): Assignment of truth values to all ground predicates

19 Inference in First-Order Logic “Traditionally” done by theorem proving (e.g.: Prolog) Propositionalization followed by model checking turns out to be faster (often a lot) [This was popularized by Kautz & Selman – WC] Propositionalization: Create all ground atoms and clauses Model checking: Satisfiability testing Two main approaches: Backtracking (e.g.: DPLL) Stochastic local search (e.g.: WalkSAT)

20 Satisfiability Input: Set of clauses (Convert KB to conjunctive normal form (CNF)) (A v B v ~C)(~B v D) … Output: Truth assignment that satisfies all clauses, or failure The paradigmatic NP-complete problem Solution: Search Key point: Most [random] SAT problems are actually easy Hard region: Narrow range of #Clauses / #Variables

21 Backtracking Assign truth values by depth-first search Assigning a variable deletes false literals and satisfied clauses Empty set of clauses: Success Empty clause: Failure Additional improvements: Unit propagation (unit clause forces truth value) Pure literals (same truth value everywhere)

22 Stochastic Local Search Uses complete assignments instead of partial Start with random state Flip variables in unsatisfied clauses Hill-climbing: Minimize # unsatisfied clauses Avoid local minima: Random flips Multiple restarts

23 The WalkSAT Algorithm for i ← 1 to max-tries do solution = random truth assignment for j ← 1 to max-flips do if all clauses satisfied then return solution c ← random unsatisfied clause with probability p flip a random variable in c else flip variable in c that maximizes number of satisfied clauses return failure

24 Overview Motivation Foundational areas Probabilistic inference [Markov nets] Statistical learning Logical inference Inductive logic programming Putting the pieces together MLNs Applications

25 Markov Logic Logical language: First-order logic Probabilistic language: Markov networks Syntax: First-order formulas with weights Semantics: Templates for Markov net features Learning: Parameters: Generative or discriminative Structure: ILP with arbitrary clauses and MAP score Inference: MAP: Weighted satisfiability Marginal: MCMC with moves proposed by SAT solver Partial grounding + Lazy inference

26 Markov Logic: Intuition A logical KB is a set of hard constraints on the set of possible worlds Let’s make them soft constraints: When a world violates a formula, It becomes less probable, not impossible Give each formula a weight (Higher weight  Stronger constraint)

27 Markov Logic: Definition A Markov Logic Network (MLN) is a set of pairs (F, w) where F is a formula in first-order logic w is a real number Together with a set of constants, it defines a Markov network with One node for each grounding of each predicate in the MLN One feature for each grounding of each formula F in the MLN, with the corresponding weight w

28 Example: Friends & Smokers

29

30

31 Two constants: Anna (A) and Bob (B)

32 Example: Friends & Smokers Cancer(A) Smokes(A)Smokes(B) Cancer(B) Two constants: Anna (A) and Bob (B)

33 Example: Friends & Smokers Cancer(A) Smokes(A)Friends(A,A) Friends(B,A) Smokes(B) Friends(A,B) Cancer(B) Friends(B,B) Two constants: Anna (A) and Bob (B)

34 Example: Friends & Smokers Cancer(A) Smokes(A)Friends(A,A) Friends(B,A) Smokes(B) Friends(A,B) Cancer(B) Friends(B,B) Two constants: Anna (A) and Bob (B)

35 Example: Friends & Smokers Cancer(A) Smokes(A)Friends(A,A) Friends(B,A) Smokes(B) Friends(A,B) Cancer(B) Friends(B,B) Two constants: Anna (A) and Bob (B)

36 Markov Logic Networks MLN is template for ground Markov nets Probability of a world x : Typed variables and constants greatly reduce size of ground Markov net Functions, existential quantifiers, etc. Infinite and continuous domains Weight of formula iNo. of true groundings of formula i in x

37 Relation to Statistical Models Special cases: Markov networks Markov random fields Bayesian networks Log-linear models Exponential models Max. entropy models Gibbs distributions Boltzmann machines Logistic regression Hidden Markov models Conditional random fields Obtained by making all predicates zero-arity Markov logic allows objects to be interdependent (non-i.i.d.)

38 Relation to First-Order Logic Infinite weights  First-order logic Satisfiable KB, positive weights  Satisfying assignments = Modes of distribution Markov logic allows contradictions between formulas

39 Is this a good thing? Pros: Drawing connections between problems Specifying/visualizing/prototyping new methods … Cons: Robust, general tools are very hard to build for computationally hard tasks This is especially true when learning is involved Eg, MCMC doesn’t work well for large weights -wc

40 Learning Data is a relational database Closed world assumption (if not: EM) Learning parameters (weights) Learning structure (formulas)

41 Parameter tying: Groundings of same clause Generative learning: Pseudo-likelihood Discriminative learning: Cond. Likelihood [still just like CRFs - all we need is to do inference efficiently. Here they use a Collins-like method. WC] Weight Learning No. of times clause i is true in data Expected no. times clause i is true according to MLN

42 Problem 1… Memory Explosion Problem: If there are n constants and the highest clause arity is c, the ground network requires O(n ) memory Solution: Exploit sparseness; ground clauses lazily → LazySAT algorithm [Singla & Domingos, 2006] [WC: this is a partial solution….] c

43 Ground Network Construction network ← Ø queue ← query nodes repeat node ← front(queue) remove node from queue add node to network if node not in evidence then add neighbors(node) to queue until queue = Ø

44 Example: Friends & Smokers Cancer(A) Smokes(A)Friends(A,A) Friends(B,A) Smokes(B) Friends(A,B) Cancer(B) Friends(B,B) Two constants: Anna (A) and Bob (B)

45 Problem 2: MAP/MPE Inference Problem: Find most likely state of world given evidence QueryEvidence

46 MAP/MPE Inference Problem: Find most likely state of world given evidence

47 MAP/MPE Inference Problem: Find most likely state of world given evidence

48 MAP/MPE Inference Problem: Find most likely state of world given evidence This is just the weighted MaxSAT problem Use weighted SAT solver (e.g., MaxWalkSAT [Kautz et al., 1997] ) Potentially faster than logical inference (!)

49 The MaxWalkSAT Algorithm 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

50 MaxWalkSAT does MAP – can we compute expectations? P(Formula|MLN,C) = ? MCMC: Sample worlds, check formula holds P(Formula1|Formula2,MLN,C) = ? If Formula2 = Conjunction of ground atoms First construct min subset of network necessary to answer query (generalization of KBMC) Then apply MCMC (or other) Can also do lifted inference [Braz et al, 2005]

51 MCMC is Insufficient for Logic Problem: Deterministic dependencies break MCMC Near-deterministic ones make it very slow Solution: Combine MCMC and WalkSAT → MC-SAT algorithm [Poon & Domingos, 2006]

52 Current Best Solution: The MC-SAT Algorithm [Basic idea: figure out how to sample from SAT assignments, and use this as a subroutine for MCMC - WC] MC-SAT = MCMC + SAT MCMC: Slice sampling with an auxiliary variable for each clause SAT: Wraps around SampleSAT (a uniform sampler) to sample from highly non-uniform distributions Sound: Satisfies ergodicity & detailed balance Efficient: Orders of magnitude faster than Gibbs and other MCMC algorithms

53 The MC-SAT Algorithm X ( 0 )  A random solution satisfying all hard clauses for k  1 to num_samples M  Ø forall C i satisfied by X ( k – 1 ) With prob. 1 – exp ( – w i ) add C i to M endfor X ( k )  A uniformly random solution satisfying M endfor

54 Auxiliary-Variable Methods Main ideas: Use auxiliary variables to capture dependencies Turn difficult sampling into uniform sampling Given distribution P(x) Sample from f (x,u), then discard u

55 Slice Sampling [Damien et al. 1999] X x (k) u (k) x (k+1) Slice U P(x)P(x)

56 Slice Sampling Identifying the slice may be difficult Introduce an auxiliary variable u i for each Ф i

57 The MC-SAT Algorithm Approximate inference for Markov logic Use slice sampling in MCMC Auxiliary var. u i for each clause C i : C i unsatisfied: 0  u i  1  exp ( w i f i ( x ) )  u i for any next state x C i satisfied: 0  u i  exp ( w i )  With prob. 1 – exp ( – w i ), next state x must satisfy C i to ensure that exp ( w i f i (x) )  u i

58 The MC-SAT Algorithm Select random subset M of satisfied clauses Larger w i  C i more likely to be selected Hard clause ( w i   ): Always selected Slice  States that satisfy clauses in M Sample uniformly from these

59 The MC-SAT Algorithm X ( 0 )  A random solution satisfying all hard clauses for k  1 to num_samples M  Ø forall C i satisfied by X ( k – 1 ) With prob. 1 – exp ( – w i ) add C i to M endfor X ( k )  A uniformly random solution satisfying M endfor

60 The MC-SAT Algorithm Sound: Satisfies ergodicity and detailed balance Assuming we have a perfect uniform sampler Of course, we don’t (since the problem is #P-hard) But there is an approximate uniform sampler [Wei et al. 2004] SampleSAT = WalkSAT + Simulated annealing Trade off uniformity vs. efficiency by tuning the prob. of WS steps vs. SA steps

61 Overview Motivation Foundational areas Probabilistic inference [Markov nets] Statistical learning Logical inference Inductive logic programming Putting the pieces together MLNs Applications

62 Basics Logistic regression Hypertext classification Information retrieval Entity resolution Hidden Markov models Information extraction Statistical parsing Semantic processing Bayesian networks Relational models Robot mapping Planning and MDPs Practical tips

63 Uniform Distribn.: Empty MLN Example: Unbiased coin flips Type: flip = { 1, …, 20 } Predicate: Heads(flip)

64 Binomial Distribn.: Unit Clause Example: Biased coin flips Type: flip = { 1, …, 20 } Predicate: Heads(flip) Formula: Heads(f) Weight: Log odds of heads: By default, MLN includes unit clauses for all predicates (captures marginal distributions, etc.)

65 Multinomial Distribution Example: Throwing die Types: throw = { 1, …, 20 } face = { 1, …, 6 } Predicate: Outcome(throw,face) Formulas: Outcome(t,f) ^ f != f’ => !Outcome(t,f’). Exist f Outcome(t,f). Too cumbersome!

66 Multinomial Distrib.: ! Notation Example: Throwing die Types: throw = { 1, …, 20 } face = { 1, …, 6 } Predicate: Outcome(throw,face!) Formulas: Semantics: Arguments without “!” determine arguments with “!”. Also makes inference more efficient (triggers blocking).

67 Multinomial Distrib.: + Notation Example: Throwing biased die Types: throw = { 1, …, 20 } face = { 1, …, 6 } Predicate: Outcome(throw,face!) Formulas: Outcome(t,+f) Semantics: Learn weight for each grounding of args with “+”.

68 Logistic regression: Type: obj = { 1,..., n } Query predicate: C(obj) Evidence predicates: F i (obj) Formulas: a C(x) b i F i (x) ^ C(x) Resulting distribution: Therefore: Alternative form: F i (x) => C(x) Logistic Regression

69 Text Classification page = { 1, …, n } word = { … } topic = { … } Topic(page,topic!) HasWord(page,word) !Topic(p,t) [bias term, since topics are sparse? –WC] HasWord(p,+w) => Topic(p,+t)

70 Problem: Given database, find duplicate records HasToken(token,field,record) SameField(field,record,record) SameRecord(record,record) HasToken(+t,+f,r) ^ HasToken(+t,+f,r’) => SameField(f,r,r’) SameField(f,r,r’) => SameRecord(r,r’) SameRecord(r,r’) ^ SameRecord(r’,r”) => SameRecord(r,r”) Entity Resolution TFIDFSimGreaterThan0.8(+t,+f,r’) TFIDFSimGreaterThan0.6(+t,+f,r’) => SameField(f,r,r’) TFIDFSimGreaterThan0.4(+t,+f,r’) => SameField(f,r,r’) Etc, etc

71 Problem: Given database, find duplicate records HasToken(token,field,record) SameField(field,record,record) SameRecord(record,record) HasToken(+t,+f,r) ^ HasToken(+t,+f,r’) => SameField(f,r,r’) SameField(f,r,r’) => SameRecord(r,r’) SameRecord(r,r’) ^ SameRecord(r’,r”) => SameRecord(r,r”) Entity Resolution

72 Can also resolve fields: HasToken(token,field,record) SameField(field,record,record) SameRecord(record,record) HasToken(+t,+f,r) ^ HasToken(+t,+f,r’) => SameField(f,r,r’) SameField(f,r,r’) SameRecord(r,r’) SameRecord(r,r’) ^ SameRecord(r’,r”) => SameRecord(r,r”) SameField(f,r,r’) ^ SameField(f,r’,r”) => SameField(f,r,r”) P. Singla & P. Domingos, “Entity Resolution with Markov Logic”, in Proc. ICDM-2006. Entity Resolution

73

74 Hidden Markov Models obs = { Obs1, …, ObsN } state = { St1, …, StM } time = { 0, …, T } State(state!,time) Obs(obs!,time) State(+s,0) State(+s,t) => State(+s',t+1) Obs(+o,t) => State(+s,t)

75 Information Extraction (simplified) Problem: Extract database from text or semi-structured sources Example: Extract database of publications from citation list(s) (the “CiteSeer problem”) Two steps: Segmentation: Use HMM to assign tokens to fields Entity resolution: Use logistic regression and transitivity

76 Motivation for joint extraction and matching

77 Token(token, position, citation) InField(position, field, citation) SameField(field, citation, citation) SameCit(citation, citation) Token(+t,i,c) => InField(i,+f,c) InField(i,+f,c) InField(i+1,+f,c) f != f’ => (!InField(i,+f,c) v !InField(i,+f’,c)) Token(+t,i,c) ^ InField(i,+f,c) ^ Token(+t,i’,c’) ^ InField(i’,+f,c’) => SameField(+f,c,c’) SameField(+f,c,c’) SameCit(c,c’) SameField(f,c,c’) ^ SameField(f,c’,c”) => SameField(f,c,c”) SameCit(c,c’) ^ SameCit(c’,c”) => SameCit(c,c”) Information Extraction (simplified)

78 Token(token, position, citation) InField(position, field, citation) SameField(field, citation, citation) SameCit(citation, citation) Token(+t,i,c) => InField(i,+f,c) InField(i,+f,c) ^ !Token(“.”,i,c) InField(i+1,+f,c) f != f’ => (!InField(i,+f,c) v !InField(i,+f’,c)) Token(+t,i,c) ^ InField(i,+f,c) ^ Token(+t,i’,c’) ^ InField(i’,+f,c’) => SameField(+f,c,c’) SameField(+f,c,c’) SameCit(c,c’) SameField(f,c,c’) ^ SameField(f,c’,c”) => SameField(f,c,c”) SameCit(c,c’) ^ SameCit(c’,c”) => SameCit(c,c”) More: H. Poon & P. Domingos, “Joint Inference in Information Extraction”, in Proc. AAAI-2007. Information Extraction (simplified)

79 Token(token, position, citation) InField(position, field, citation) SameField(field, citation, citation) SameCit(citation, citation) Token(+t,i,c) => InField(i,+f,c) InField(i,+f,c) ^ !Token(“.”,i,c) InField(i+1,+f,c) f != f’ => (!InField(i,+f,c) v !InField(i,+f’,c)) Information Extraction (less simplified) Token(+t,i,c) => InField(i,+f,c) ~Token("aardvark",i,c) v InField(i,”author”,c) … ~Token("zymurgy",i,c) v InField(i,"author",c) … ~Token("zymurgy",i,c) v InField(i,"venue",c)

80 Token(token, position, citation) InField(position, field, citation) SameField(field, citation, citation) SameCit(citation, citation) Token(+t,i,c) => InField(i,+f,c) InField(i,+f,c) ^ !Token(“.”,i,c) InField(i+1,+f,c) f != f’ => (!InField(i,+f,c) v !InField(i,+f’,c)) Information Extraction (less simplified) Token(+t,i,c) => InField(i,+f,c) InField(i,+f,c) => InField(i+1,+f,c) InField(i,+f,c) ^ !HasPunct(c,i) => InField(i+1,+f,c) InField(i,+f,c) ^ !HasComma(c,i) => InField(i+1,+f,c) => InField(1,”author”,c) => InField(2,”author”,c) => InField(midpointOfC, "title", c)

81 Token(token, position, citation) InField(position, field, citation) SameField(field, citation, citation) SameCit(citation, citation) Token(+t,i,c) => InField(i,+f,c) f != f’ => (!InField(i,+f,c) v !InField(i,+f’,c)) Information Extraction (less simplified) Token(+t,i,c) => InField(i,+f,c) InField(i,+f,c) => InField(i+1,+f,c) InField(i,+f,c) ^ !HasPunct(c,i) => InField(i+1,+f,c) InField(i,+f,c) ^ !HasComma(c,i) => InField(i+1,+f,c) => InField(1,”author”,c) => InField(2,”author”,c) => InField(midpointOfC, "title", c)

82 Token(+t,i,c) => InField(i,+f,c) f != f’ => (!InField(i,+f,c) v !InField(i,+f’,c)) Information Extraction (less simplified) Token(+t,i,c) => InField(i,+f,c) InField(i,+f,c) => InField(i+1,+f,c) InField(i,+f,c) ^ !HasPunct(c,i) => InField(i+1,+f,c) InField(i,+f,c) ^ !HasComma(c,i) => InField(i+1,+f,c) => InField(1,”author”,c) => InField(2,”author”,c)  InField(midpointOfC, "title", c) Initial(t) => InField(t,i,"author") v InField(t,i,"venue") i !InField(t’,j,”author”) v !InField(t’,j,”title”) Initial(t) => InField(t,”venue”) v InField(t,”author”) i !InField(i,”title”) ^ !InField(i,”venue”) i !InField(k,”venue”) v [!InField(i,”author”) v !InField(i,”title”)]

83 Information Extraction (less simplified) SimilarTitle(c,i,j,c’,i’,j’): true if c[i..j] and c’[i’…j’] are both “titlelike” i.e., no punctuation, doesn’t violate rules above c[i..j] and c’[i’…j’] are “similar” i.e. start with same trigram and end with same token SimilarVenue(c,c’): true if c and c’ don’t contain conflicting venue keywords (e.g., journal vs proceedings)

84 Information Extraction (less simplified) SimilarTitle(c,i,j,c’,i’,j’): … SimilarVenue(c,c’): … JointInferenceCandidate(c,i,c’): trigram starting at i in c also appears in c’ and trigram is a possible title and punct before trigram in c’ but not c

85 Information Extraction (less simplified) SimilarTitle(c,i,j,c’,i’,j’): … SimilarVenue(c,c’): … JointInferenceCandidate(c,i,c’): trigram starting at i in c also appears in c’ and trigram is a possible title and punct before trigram in c’ but not c

86 Information Extraction (less simplified) SimilarTitle(c,i,j,c’,i’,j’): … SimilarVenue(c,c’): … JointInferenceCandidate(c,i,c’): InField(i,+f,c) ^ !HasPunct(c,i) => InField(i+1,+f,c) InField(i,+f,c) ^ ~HasPunct(c,i) ^ (!exists c’:JointInferenceCandidate(c,i,c’)) => InField(i+1,+f,c) Jnt-Seg

87 Information Extraction (less simplified) SimilarTitle(c,i,j,c’,i’,j’): … SimilarVenue(c,c’): … JointInferenceCandidate(c,i,c’): InField(i,+f,c) ^ ~HasPunct(c,i) ^ (!exists c’:JointInferenceCandidate(c,i,c’) ^ SameCitation(c,c’) ) => InField(i+1,+f,c) Jnt-Seg-ER

88 Results

89 Cora F-S: 0.87 F1 Cora TFIDF: 0.84 max F1 Fraction of clusters correctly constructed using transitive closure of pairwise decisions

90 William’s summary MLNs are a compact, elegant way of describing a Markov network Standard learning methods work Network may be very very large Inference may be expensive Doesn’t eliminate feature engineering E.g., complicated “feature” predicates Experimental results for joint matching/NER are not that strong overall Cascading segmentation and then matching improves segmentation, probably not matching But it needs to be carefully restricted (efficiency?) And it’s no better than a “pseudo” joint model using plausible matches as features


Download ppt "First Order Representations and Learning coming up later: scalability!"

Similar presentations


Ads by Google