Report

Latent Variables Naman Agarwal Michael Nute May 1, 2013 Latent Variables Contents • Definition & Example of Latent Variables • EM Algorithm Refresher • Structured SVM with Latent Variables • Learning under semi-supervision or indirect supervision – CoDL – Posterior Regularization – Indirect Supervision Latent Variables General Definition & Examples A Latent Variable in a machine learning algorithm is one which is assumed to exist (or have null value) but which is not observed and is inferred from other observed variables. • Generally corresponds to some meaningful element of the problem for which direct supervision is intractable. • Latent variable methods often imagine the variable as part of the input/feature space (e.g. PCA, factor analysis), or as part of the output space (e.g. EM). – This distinction is only illustrative though and can be blurred, as we will see with indirect supervision. Latent Input Variables: ∗ (unobserved) As part of the input space, the variable ∈ affects the output ∈ only through the unobserved variable ∗ ∈ ∗ . This formulation is only helpful if the dimension of ∗ is smaller than the dimension of , so latent variables here are essentially an exercise in dimension reduction. Latent Output Variables: ∗ (unobserved) (observed) When we think of a latent variable as part of the output space, the method becomes an exercise in unsupervised or semi-supervised learning. Example Paraphrase Identification Problem: Given sentences A and B, determine whether they are paraphrases of each other. • Note that if they are paraphrases, then there will exist a mapping between named entities and predicates in the sentence. • The mapping is not directly observed, but is a latent variable in the decision problem of determining whether the sentences say the same thing. A: Druce will face murder charges, Conte said. (latent) B: Conte said Druce will be charged with murder. Revised Problem: Given sentences A and B, determine the mapping of semantic elements between A and B. • Now we are trying to learn specifically the mapping between them, so we can use the Boolean question in the previous problem as a latent variable. • In practice, the Boolean question is easy to answer, so we can use it to guide the semisupervised task of mapping semantic elements. • This is called indirect supervision (more on that later). 1Example taken from talk by D. Roth Language Technologies Institute Colloquium, Carnegie Mellon University, Pittsburgh, PA. Constraints Driven Structured Learning with Indirect Supervision. April 2010. The EM Algorithm Refresher In practice, many algorithms that use latent variables have a structure similar to the ExpectationsMaximization algorithm (even though EM is not discriminative and others are). So let’s review: The EM Algorithm (formally) Setup: Observed Data: Unobserved Data: Unknown Parameters: Log-Likelihood Function: = ∈ log(P , ) Algorithm: Initialize = () E-Step: Find the expected value of over the unobserved data given the current estimate of the parameters: = |, M-Step: Find the parameters that maximize the expected log-likelihood function: +1 = argmax Takes expectation over possible “labels” of The EM Algorithm Hard EM vs. Soft EM • The algorithm at left is often called Soft EM because it computes the expectation of the log-likelihood function in the E-Step. • An important variation on this algorithm is called Hard EM: — instead of computing expectation, we simply choose the MAP value for and proceed with the likelihood function conditional on the MAP value. • This is a simpler procedure which many latent variable methods will essentially resemble: Label Train (repeat until convergence) Yu & Joachims—Learning Structured SVMs with Latent Variables Model Formulation General Structured SVM Formulation: Solve: 1 min 2 2 max Δ , + ′ Φ , + =1 ∈ − ′ Φ , Where: ( , ) are input and structure for training example . Φ , is the feature vector Δ , is the loss function in the output space is the weight vector Structured SVM Formulation with Latent Variable: Let ℎ ∈ ℋ be an unobserved variable. Since the predicted now depends on ℎ, the predicted value of the latent variable ℎ, the loss function of the actual and may now become a function of ℎ as well: Δ , ⇒ Δ , , ℎ So our new optimization problem becomes: 1 min 2 2 + max =1 (,ℎ)∈×ℋ Δ , , ℎ + ′ Φ , , ℎ max ′ Φ , , ℎ − =1 ℎ∈ℋ Problem is now the difference of two convex functions, so we can solve it using a concave-convex procedure (CCCP). Yu & Joachims—Learning Structured SVMs with Latent Variables Optimization Methodology & Notes The CCCP: Notes: 1. Compute • Technically the loss function would compare the true values , ℎ to the predicted , ℎ , but since we do not observe ℎ , we are restricted to using loss functions that reduce to what is shown. ℎ∗ = argmax ′ Φ , , ℎ ℎ∈ℋ for each 2. Update by solving the standard Structured SVM formulation, treating each ℎ∗ as though it were an observed value. (repeat until convergence) Note the similarity to the simple way we looked at Hard-EM earlier: first we label the unlabeled values, then we re-train the model based on the newly labeled values. • It is not strictly necessary that the loss function depend on ℎ. In NLP it often does not. • In the absence of latent variables, the optimization problem reduces to the general Structured SVM formulation. Learning under semi-supervision Labeled dataset is hard to obtain We generally have a small labeled dataset and a large unlabeled data-set Naïve Algorithm [A kind of EM] Train on labeled data set [Initialization] Make Inference on the unlabeled set [Expectation] Include them in your training [Maximization] Repeat Can we do better ? Indirect supervision Constraints Binary decision problems Constraint Driven Learning Proposed by Chang et al [2007] Uses constraints obtained by domain-knowledge as to streamline semi-supervision Constraints are pretty general Incorporates soft constraints Why are constraints useful ? [AUTHOR Lars Ole Anderson . ] [TITLE Program Analysis and specification for the C programming language . ] [ TECH-REPORT PhD thesis , ] [INSTITUTION DIKU , University of Copenhagen , ][DATE May 1994 .] HMM trained on 30 data sets produces [AUTHOR Lars Ole Anderson . Program Analysis and ] [ TITLE specification for the ] [ EDITOR C ] BOOKTITLE programming language . ] [ TECHREPORT PhD thesis , ] [INSTITUTION DIKU , University of Copenhagen , May ][DATE 1994 .] Leads to noisy predictions. Simple constraint that state transition occurs only on punctuation marks produces the correct output CoDL Framework Notations = (XL , YL ) is the labeled dataset U = (X U , YU ) is the unlabeled dataset , represents a feature vector Structured Learning Task L Learn w such that Yi = . ( , ) 1 , … , are the set of constraints where each ∶ × → {0,1} CoDL Objective If the constraints are hard – ∈1 If constraints are soft they define a notion of violation by a distance function d such that , , = . ( , ) min (, ′) ′ ∈1 The objective in this “soft” formulation is given by . , − , , =1 Learning Algorithm Divided into Four Steps Initialization = () Expectation For all ∈ , 1 … , =∪ = − − , , , , 1 … , − − generates the best K “valid” assignments to Y using Beam – Search techniques Can be thought of as assigning a uniform distribution over the above K in the posterior and 0 everywhere else Learning Algorithm (cntd.) Maximization = 0 + 1 − ∗ () is a smoothing parameter that does not let the model drift too much from the supervised model Repeat Posterior Regularization [Ganchev et al ‘09] Hard vs Soft EM Imposes constraints in Expectation over the Posterior Distribution of the Latent Variables Two components of the objective function log-likelihood – l = log( (, )) The deviation from the predicted posterior and the one Posterior Distribution of the satisfying constraints latent variables min (|| (|)) The Set of all posterior distributions () = 1 Constraint specified in terms of expectation over q The PR Algorithm Initialization Estimate parameters from the labeled data set Expectation Step Compute the closest satisfying distribution = min (|| (|)) () = 1 Maximization Step +1 = [()] Repeat Indirect Supervision - Motivation Paraphrase Identification S1: Druce will face murder charges, Conte said. S2: Conte said Druce will be charged with murder. There exists some Latent Structure H between S1 and S2 H acts as a justification for the binary decision. Can be used as an intermediate step in learning the model Supervision through Binary Problems Now we ask the previous question in the reverse direction Given answers to the binary problem, can we improve our latent structure identification Structured Prediction Problem Example – Field • Companion Binary Problem • Labeled dataset – easy to obtain Identification in advertisements (size,rent etc.) Whether the text is a well formed advertisement The Model [Chang et al 2010] Notations – = (XL , YL ) is the labeled dataset = + ∪ − B = (X B , YB ) is the binary ( ∈ {1, −1}) labeled dataset. , represents a feature vector Structured Learning Task L Learn w such that F , , = min Additionally we require ∀ , −1 ∈ − , ∀ , ∀ , +1 ∈ + , ∃ , The weight vector scores some structure well 2 2 + 1 ∈ , , The weight vector scores all structures badly . , ≤ . , > Loss Function The previous “constraint” can be captured by the following loss function , , = (1 − max( . ( , ))) Now we wish to optimize the following objective , , + , , Structured Prediction over the labeled dataset Indirect Supervision Model Specification Setup: , =1 Fully-labeled training data: = Binary-labeled training data: = + ∪ − = , + =+1 where ∈ −1, +1 Two Conditions Imposed on the Weight Vector: ∀ , −1 ∈ − , ∀ ∈ ℋ , ′ Φ , ≤ 0 (i.e. there is no good predicted structure for the negative examples) ∀ , +1 ∈ + , ∃ ∈ ℋ , ′ Φ , ≥ 0 (i.e. there is at least one good predicted structure for the positive examples) So the optimization problem becomes: min 2 2 + 1 , , + 2 − , , + 2 ∈− ∈ Where: ′ , , = max Δ , − Φ , − Φ , , , = 1 − max ′ ℎ∈ℋ() Φ , ( ) is a common loss function such as the hinge loss is a normalization constant + , , ∈+ This term is non-convex and must be optimized by setting = argmax ′ Φ , and ℎ∈ℋ solving the first two terms, then repeating (CCCP-like). Latent Variables in NLP Overview of Three Methods Method 2-Second Description Latent Variable EM Analogue Key Advantage Structural SVM1 Structured SVM with latent variables & EMlike training Separate and independent from the output variable Hard EM, latent value found by argmax ′ Φ , , ℎ Enables Structured SVM learned with latent variable ℎ∈ℋ CoDL2 Train on labeled data, generate K best structures of unlabeled data and train on that. Average the two. Output variable for unlabeled training examples Soft-EM with Uniform Distribution on top-K predicted outputs. Efficient semisupervised learning when constraints are difficult to guarantee for predictions but easy to evaluate Indirect Supervision3 Get small number of labeled & many where we know if label exists or not. Train a model on both at the same time. 1. Companion binary-decision variable 2. Output structure on positive, unlabeled examples Hard EM where label is applied only to examples where binary classifier is positive Combines information gain from indirect supervision (on lots of data) with direct supervision 1Learning Structural SVMs with Latent Variables, Chun-Nam John Yu and T. Joachims, ICML, 2009. Semi-Supervision with Constraint-Driven Learning, M. Chang, L. Ratinov and D. Roth, ACL 2007 3Structured Output Learning with Indirect Supervision, M. Chang, V. Srikumar, D. Goldwasser and D. Roth, ICML 2010. 2Guiding