Upgrade to Pro — share decks privately, control downloads, hide ads and more …

MLDM Monday Apr. 15 by Chu-Cheng

Avatar for as1986 as1986
April 15, 2013

MLDM Monday Apr. 15 by Chu-Cheng

Avatar for as1986

as1986

April 15, 2013

Other Decks in Technology

Transcript

  1. • Imagine we have the following sentences in our corpus

    • 我 喜歡 吃 菠蘿油 • 學校 對⾯面 的 茶餐廳 的 菠蘿油 很 好吃 • 我 吃 完 菠蘿油 就 來 學校 上課 了 • 我 上課 最 喜歡 睡覺 了 • 睡覺 的 時候 我 夢到 菠蘿油 和 絲襪 奶茶 13年4月15⽇日星期⼀一
  2. • 我 喜歡 吃 菠蘿油 • 學校 對⾯面 的 茶餐廳

    的 菠蘿油 很 好吃 • 我 吃 完 菠蘿油 就 來 上 課 了 • 我 上課 最 喜歡 睡覺 了 • 睡覺 的 時候 我 夢到 菠 蘿油 和 絲襪 奶茶 What is Topic Modeling? • how does a machine understand these sentences? • not an easy problem! • but at least we can try to guess the discussed topics • what are topics? 13年4月15⽇日星期⼀一
  3. • if we have a very big corpus, we may

    see frequent co- occurrence of some words • “菠蘿油”, “茶餐廳” • “上課”, “睡覺” • “睡覺”, “夢到” • ... • these co-occurrence suggest some underlying link between the words • we call the underlying links topics What are Topics? 13年4月15⽇日星期⼀一
  4. What are Topics? (cont) • we may imagine the co-occurrence

    are not merely between two words • “茶餐廳”, “菠蘿包” • “茶餐廳”, “多⼠士” • “茶餐廳”, “凍檸茶” • “菠蘿包”, “多⼠士” • ... • arbitrarily pick words and make them the same topic • “茶餐廳”: 30, “菠蘿包”: 20, ... 13年4月15⽇日星期⼀一
  5. What are Topics? (cont) • if we normalize these weighted

    topics, we get probability distribution over all words e.g. • P(“凍檸茶”) = 0.2 • P(“筷⼦子”) = 0.01 • P(“⼩小籠包”) = 2 x 10-4 • ... 13年4月15⽇日星期⼀一
  6. back to the sentences • 我 喜歡 吃 菠蘿油 •

    學校 對⾯面 的 茶餐廳 的 菠蘿油 很 好吃 • 我 吃 完 菠蘿油 就 來 上 課 了 • 我 上課 最 喜歡 睡覺 了 • 睡覺 的 時候 我 夢到 菠 蘿油 和 絲襪 奶茶 • say we know each word’s topic, we want to know sentences’ topic coverage • S1: 1 yellow, 1 blue, 2 reds • S5: 3 yellows, 3 blues, 3 reds • and again we normalize • S1: (0.25, 0.25, 0.5) 13年4月15⽇日星期⼀一
  7. so that is topic modeling • in topic modeling jargon,

    we have documents, topics, and words • documents • sentences in our example • bag-of-words assumption; do not care about word order • seen as distributions over topics 13年4月15⽇日星期⼀一
  8. • topics • distributions over all possible words • words

    • ... are words 13年4月15⽇日星期⼀一
  9. so... • how do we automatically find these topics? •

    later • what can we do with these topics? • roughly figure out what a document is talking about • find similar documents • similar distribution over topics 13年4月15⽇日星期⼀一
  10. • resolve polysemy • information from underlying topic • “絲襪”,

    “奶茶”, “菠蘿包”, ... • “絲襪”, “襪⼦子”, “尼⻯⿓龍”, ... • visualization and exploration of a corpus 13年4月15⽇日星期⼀一
  11. models • many topic models nowadays are based on the

    model LDA (Latent Dirichlet Allocation) • D. Blei, A. Ng, and M. Jordan. Latent Dirichlet allocation. JMLR, 3:993–1022, January 2003. • i will try to give a brief overview 13年4月15⽇日星期⼀一
  12. defining our problem • given a corpus, we want to

    know each underlying topic of each word 13年4月15⽇日星期⼀一
  13. • 我 喜歡 吃 菠蘿油 • 學校 對⾯面 的 茶餐廳

    的 菠蘿油 很 好吃 • 我 吃 完 菠蘿油 就 來 上課 了 • 我 上課 最 喜歡 睡覺 了 • 睡覺 的 時候 我 夢到 菠蘿油 和 絲襪 奶茶 13年4月15⽇日星期⼀一
  14. • 我 喜歡 吃 菠蘿油 • 學校 對⾯面 的 茶餐廳

    的 菠蘿油 很 好吃 • 我 吃 完 菠蘿油 就 來 上課 了 • 我 上課 最 喜歡 睡覺 了 • 睡覺 的 時候 我 夢到 菠蘿油 和 絲襪 奶茶 13年4月15⽇日星期⼀一
  15. • suppose we have 1. each document’s distribution over topics

    (αs) 2. each topic’s distribution over words (βs) 3. each document’s length 4. number of topics (2 in our example) 5. a finite vocabulary (“菠蘿包”, “多⼠士”, “凍檸茶”, “公仔 麵”, “豬扒包”) • can we compute the probability of generating a document? • yes of course! the problem somewhat modified 13年4月15⽇日星期⼀一
  16. document generation • the two topics: distributions over words •

    β1: β1,菠蘿包 = 0.5, β1,多⼠士 = 0.2, β1,凍檸茶 = 0.3, otherwise β1,i=0 (0.5, 0.3, 0.2, 0, 0) • β2: β2,公仔麵 = 0.3, β2,菠蘿包 = 0.1, β2,豬扒包 = 0.6, otherwise β2,i=0 (0.1, 0, 0, 0.3, 0.6) • documents’ coverage of topics • α1: α1,t1 = 0.2, α1,t2 = 0.8 • α2: α2,t1 = 0.4, α2,t2 = 0.6 • length(D1) = 3 13年4月15⽇日星期⼀一
  17. document generation • P(D1= “菠蘿包t1, 菠蘿包t2, 多⼠士t1”|α1, β1, β2) =

    α1,t1 x β1,菠蘿包 x α1,t2 x β2,菠蘿包 x α1,t1 x β1,多⼠士 = 3.2 x 10-4 (actually we don't care about the number; just want to show that we can compute this...) 13年4月15⽇日星期⼀一
  18. so how does that relate to our problem? • we

    know that we can compute P(D|α, β) • since documents are actually given, we can directly search for α, β that maximize P(D|α, β) • known as pLSI • but this gave poor results :( • values of α, β can go crazy • LDA uses priors to constrain them • the priors are Dirichlet distribution (hence the name) 13年4月15⽇日星期⼀一
  19. • suppose we still have two topics t1, t2 and

    the same vocabulary • now instead of arbitrarily setting α1, α2, β1, β2, we draw them from their respective priors • α1, α2 ~ Dirichlet(A) • say α1 = (0.2, 0.8) and α2 = (0.3, 0.7) • β1, β2 ~ Dirichlet(B) • say β1 = (0.1, 0.2, 0.3, 0.2, 0.2) 13年4月15⽇日星期⼀一
  20. • recall we can already compute P(D|α, β) • now

    we can also compute P(α), P(β) • we have P(D|α, β)P(α)P(β) = P(D, α, β) = P(α, β|D)P(D) • since P(D) is constant for a particular corpus, we have P(α, β|D) = kP(D|α, β)P(α)P(β) • use Monte Carlo techniques to sample from this distribution i.e. to find plausible α, β 13年4月15⽇日星期⼀一
  21. in practice... • we seldom need the posterior P(α, β|D)

    • suffers from the label-switching problem • swap label of two topics and P(α, β) will stay the same! • a common practice is to run the MCMC sampler for some time and use the last sample 13年4月15⽇日星期⼀一
  22. off-the-shelf packages? • GibbsLDA++ • implemented in C++ as the

    name implies • gensim • python interface • no demo this time... 13年4月15⽇日星期⼀一
  23. demo • a lot of LDA demos online! • Palin’s

    emails • arXiv papers in 2006 13年4月15⽇日星期⼀一
  24. Reference • D. Blei, Probabilistic topic models. Communications of the

    ACM 55.4 (2012): 77-84. • G. Heinrich, Parameter estimation for text analysis, Technical report, Fraunhofer IGD, 15 September 2009. • highly recommended if you want to design your own model 13年4月15⽇日星期⼀一