topic modeling lecture 9 october 9 2013
play

Topic Modeling Lecture 9: October 9, 2013 CS886 2 Natural Language - PDF document

2013 10 09 Topic Modeling Lecture 9: October 9, 2013 CS886 2 Natural Language Understanding University of Waterloo CS886 Lecture Slides (c) 2013 P. Poupart 1 Information Retrieval Example #1 CS886 Lecture Slides (c) 2013 P. Poupart 2


  1. 2013 ‐ 10 ‐ 09 Topic Modeling Lecture 9: October 9, 2013 CS886 ‐ 2 Natural Language Understanding University of Waterloo CS886 Lecture Slides (c) 2013 P. Poupart 1 Information Retrieval Example #1 CS886 Lecture Slides (c) 2013 P. Poupart 2 1

  2. 2013 ‐ 10 ‐ 09 Information Retrieval Example #1 CS886 Lecture Slides (c) 2013 P. Poupart 3 Information Retrieval Example #2 CS886 Lecture Slides (c) 2013 P. Poupart 4 2

  3. 2013 ‐ 10 ‐ 09 Information Retrieval Example #2 CS886 Lecture Slides (c) 2013 P. Poupart 5 Information Retrieval Example #3 CS886 Lecture Slides (c) 2013 P. Poupart 6 3

  4. 2013 ‐ 10 ‐ 09 Information Retrieval Example #3 CS886 Lecture Slides (c) 2013 P. Poupart 7 Latent Semantic Analysis • Idea: singular value decomposition – Infer latent space in which documents or words can be described more succinctly • Issues: – How do we interpret this latent space? – How many dimensions should it have? – How can we represent uncertainty/ambiguities? CS886 Lecture Slides (c) 2013 P. Poupart 8 4

  5. 2013 ‐ 10 ‐ 09 Latent Dirichlet Allocation • Idea: probabilistic generative model for documents – Latent variables often correspond to topics – Some machine learning techniques can automatically infer the # of topics – Probabilistic framework allows us to quantify uncertainty/ambiguities CS886 Lecture Slides (c) 2013 P. Poupart 9 Graphical Model • Picture CS886 Lecture Slides (c) 2013 P. Poupart 10 5

  6. 2013 ‐ 10 ‐ 09 Plate Model • Picture CS886 Lecture Slides (c) 2013 P. Poupart 11 Dirichlet • Definition ��� �; � � , � � � �� � � �� 1 � � � � �� • �: probability of head Dir(p; 1, 1) Dir(p; 2, 8) Dir(p; 20, 80) • � � � 1 : # of heads • � � � 1 : # of tails Pr(p) • Mean: � � /�� � � � � � 0 0.2 1 p CS886 Lecture Slides (c) 2013 P. Poupart 12 6

  7. 2013 ‐ 10 ‐ 09 Conjugate Prior • Bayesian learning – Prior: Pr � � ��� �; � � , � � – Posterior: Pr��|����� • Bayes theorem: Pr � ���� ∝ Pr � Pr ���� � � ��� �; � � , � � � � �1 � �� � �� � � ���� 1 � � � � ���� � �����; � � � 3, � � � 1� CS886 Lecture Slides (c) 2013 P. Poupart 13 Topic Modeling • Task – Infer topics and parameters: Pr �� �:� , �, �|� �:� � • Two common approaches – Gibbs sampling • Simple, but stochastic and slow – Variational Bayes (variant of EM) • Complex, but deterministic and fast CS886 Lecture Slides (c) 2013 P. Poupart 14 7

  8. 2013 ‐ 10 ‐ 09 Sampling Techniques • Direct sampling • Rejection sampling • Likelihood weighting • Importance sampling • Markov chain Monte Carlo (MCMC) – Gibbs Sampling – Metropolis ‐ Hastings • Sequential Monte Carlo sampling (a.k.a. particle filtering) CS886 Lecture Slides (c) 2013 P. Poupart 15 Approximate Inference by Sampling • Expectation: � � � � � � � � � � �� � – Approximate integral by sampling: � � � � � � � � ∑ ��� � � where � � ~���� ��� • Inference query: Pr��|�� � ∑ Pr ��, �|�� � – Approximate exponentially large sum by sampling: � � Pr � � � � ∑ Pr ��|� � , �� where � � ~���|�� ��� CS886 Lecture Slides (c) 2013 P. Poupart 16 8

  9. 2013 ‐ 10 ‐ 09 Direct Sampling (a.k.a. forward sampling) • Unconditional inference queries (i.e., Pr �� � �� ) • Bayesian networks only – Idea: sample each variable given the values of its parents according to the topological order of the graph. CS886 Lecture Slides (c) 2013 P. Poupart 17 Direct Sampling Algorithm Sort the variables by topological order For � � 1 to � do (sample � particles) For each variable � � do � ~ Pr � �� � Sample � � � � �� � � • Approximation: Pr � � � � � � ∑ ��� � ��� CS886 Lecture Slides (c) 2013 P. Poupart 18 9

  10. 2013 ‐ 10 ‐ 09 Example CS886 Lecture Slides (c) 2013 P. Poupart 19 Analysis • Complexity: ���|�|� where � � #variables • Accuracy � � � � � 2� ���� � – Absolute error � : P P � V � P V �� � • Sample size � � � �� � � � ∉ �1 � �, 1 � �� � � � 2� � �� � �� � � � – Relative error � : � � � �� � • Sample size � � � ������ � CS886 Lecture Slides (c) 2013 P. Poupart 20 10

  11. 2013 ‐ 10 ‐ 09 Markov Chain Monte Carlo • Iterative sampling technique that converges to the desired distribution in the limit • Idea: set up a Markov chain such that its stationary distribution is the desired distribution CS886 Lecture Slides (c) 2013 P. Poupart 21 Markov Chain • Definition: A Markov chain is a linear chain Bayesian network with a stationary conditional distribution known as the transition function � � � � � � � � … • Initial distribution: Pr �� � � • Transition distribution: Pr �� � |� ��� � CS886 Lecture Slides (c) 2013 P. Poupart 22 11

  12. 2013 ‐ 10 ‐ 09 Asymptotic Behaviour • Let Pr�� � � be the distribution at time step � Pr�� � � � ∑ Pr � �..� � �..��� � ∑ Pr�� ��� � Pr�� � |� ��� � � ��� • In the limit (i.e., when � → ∞ ), the Markov chain may converge to stationary distribution � � � Pr �� � � �� � � � Pr � � � � � ∑ Pr �� ��� � �′� Pr �� � � �|� ��� � �′� � ��� � � � Pr ��|� � � � ∑ �� CS886 Lecture Slides (c) 2013 P. Poupart 23 Stationary distribution ��|� � � be a matrix that represents the • Let � �|�� � Pr transition function • If we think of � as a column vector, then � is an eigenvector of � with eigenvalue 1 �� � � CS886 Lecture Slides (c) 2013 P. Poupart 24 12

  13. 2013 ‐ 10 ‐ 09 Ergodic Markov Chain • Definition: A Markov chain is ergodic when there is a non ‐ zero probability of reaching any state from any state in a finite number of steps • When the Markov chain is ergodic, there is a unique stationary distribution • Sufficient condition: detailed balance �� � |�� � � � � Pr ��|� � � � � Pr Detailed balance  ergodicity  unique stationary dist. CS886 Lecture Slides (c) 2013 P. Poupart 25 Markov Chain Monte Carlo • Idea: set up an ergodic Markov chain such that the unique stationary distribution is the desired distribution • Since the Markov chain is a linear chain Bayes net, we can use direct sampling (forward sampling) to obtain a sample of the stationary distribution CS886 Lecture Slides (c) 2013 P. Poupart 26 13

  14. 2013 ‐ 10 ‐ 09 Generic MCMC Algorithm Sample � � ~ Pr �� � � For � � 1 to � do (sample � particles) Sample � � ~ Pr � � � ��� � � • Approximation: � � � � ∑ ��� � � �� ��� • In practice, ignore the first � samples for a better estimate (burn ‐ in period): � � � � � ��� ∑ ��� � � �� ��� CS886 Lecture Slides (c) 2013 P. Poupart 27 Choosing a Markov Chain • Different Markov chains lead to different algorithms – Gibbs sampling – Metropolis Hastings CS886 Lecture Slides (c) 2013 P. Poupart 28 14

  15. 2013 ‐ 10 ‐ 09 Gibbs Sampling • Suppose Pr � defined by a graphical model (Bayes net or Markov net) • Inference query: Pr � � ? Where � ⊆ � • Idea: randomly assign values to all non ‐ evidence variables, then repeatedly sample each non ‐ evidence variable given the assigned values for all other variables CS886 Lecture Slides (c) 2013 P. Poupart 29 Gibbs Sampling Algorithm � to all non ‐ evidence variables � Randomly assign � � � For � � 1 to � do (sample � particles) For each non ‐ evidence variable � � do � ~ Pr � ��� , � Sample � � � � ~� � � �� � � �|� � � � � ∑ ��� � • Approximation: Pr � ��� CS886 Lecture Slides (c) 2013 P. Poupart 30 15

  16. 2013 ‐ 10 ‐ 09 Example CS886 Lecture Slides (c) 2013 P. Poupart 31 Practical Consideration • Burn ‐ in period: ignore first � samples: � 1 � � �� Pr � � � �|� � � � � � ��� � ��� � • Use most recent values to sample � � � ~ Pr � |� �…��� � ��� � � �� , � ���… � � � • Use conditional independence to restrict parent variables to the Markov blanket � ~ Pr � |� ∀���,�∈�� � � ��� � � �� , � ∀���,�∈�� � � � CS886 Lecture Slides (c) 2013 P. Poupart 32 16

  17. 2013 ‐ 10 ‐ 09 Convergence �� � |� ��� , �� be the transition function of • Let Pr the Markov chain associated with Gibbs sampling • Theorem: Gibbs sampling converges to Pr � � when all potentials are strictly positive. �� � |� ��� , �� satisfies detailed balance • Proof: Pr i.e. Pr � � Pr � � �, � � Pr � � � Pr ��|�′, �� CS886 Lecture Slides (c) 2013 P. Poupart 33 17

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend