35
Topic Models, LDA and all that DLMU-ITREC April 21, 2011 (DLMU-ITREC) Topic Models, LDA and all that April 21, 2011 1 / 35

Topic Models, LDA and all that

Embed Size (px)

DESCRIPTION

For you who wants to download this, please follow this link: http://sdrv.ms/SkymHg A simpler version of my previous seminar slide, but provides a clearer explanation to the LDA.

Citation preview

Page 1: Topic Models, LDA and all that

Topic Models, LDA and all that

肖智博

DLMU-ITREC

April 21, 2011

肖智博 (DLMU-ITREC) Topic Models, LDA and all that April 21, 2011 1 / 35

Page 2: Topic Models, LDA and all that

目录

1 Introduction

2 Latent Dirichlet Allocation

3 后验概率逼近方法

4 图像领域的主题模型

5 参考文献

肖智博 (DLMU-ITREC) Topic Models, LDA and all that April 21, 2011 2 / 35

Page 3: Topic Models, LDA and all that

Introduction

肖智博 (DLMU-ITREC) Topic Models, LDA and all that April 21, 2011 3 / 35

Page 4: Topic Models, LDA and all that

主题模型(topic model)

∙ LDA(Latent Dirichlet Allocation)是最简单的主题模型。

∙ 主题模型为自动组织、理解、检索大量电子问题提供了一种可行的方法。

LDA的作用:

1 发掘语料库中隐藏的主题模式;

2 根据主题对文档进行标注;

3 利用标注对文档进行组织、整理、归纳和检索。

肖智博 (DLMU-ITREC) Topic Models, LDA and all that April 21, 2011 4 / 35

Page 5: Topic Models, LDA and all that

什么是主主主题题题(topic)

∙ 从词汇的角度讲:∙ 是一篇文章或者几篇文章共同的代表∙ 隐含语义∙ 共同出现词语的一种模式∙ 共同出现词语的一种聚类∙ 一种弱的分类类表

∙ 从概率分布的角度讲:∙ 每个主题都是对所有词的一个概率分布;∙ 主题对同时出现的词赋予较高的概率;∙ 同时出现的词互相之间有某种关联性

肖智博 (DLMU-ITREC) Topic Models, LDA and all that April 21, 2011 5 / 35

Page 6: Topic Models, LDA and all that

主题模型

从机器学习的角度来讲,主题模型是将层次贝叶斯网络应用到数据(文档或者图像)的典型应用。

∙ 每篇文档包括多个主题;∙ 隐含变量起到表示文档间主题结构的作用;∙ 主题模型基于bag-of-word或者bag-of-feature假设;

∙ 所以,词的顺序是没有意义的。

肖智博 (DLMU-ITREC) Topic Models, LDA and all that April 21, 2011 6 / 35

Page 7: Topic Models, LDA and all that

主题模型的例子

∙ 每个文档都是所有主题的一个随机混合(random mixture)

∙ 每个词都是从一个主题中产生

肖智博 (DLMU-ITREC) Topic Models, LDA and all that April 21, 2011 7 / 35

Page 8: Topic Models, LDA and all that

主题模型的例子

∙ 现实中,观测数据仅仅是文档∙ 目的是推推推断断断潜在的主题结构

肖智博 (DLMU-ITREC) Topic Models, LDA and all that April 21, 2011 8 / 35

Page 9: Topic Models, LDA and all that

Latent Dirichlet Allocation

肖智博 (DLMU-ITREC) Topic Models, LDA and all that April 21, 2011 9 / 35

Page 10: Topic Models, LDA and all that

Latent Dirichlet Allocation

肖智博 (DLMU-ITREC) Topic Models, LDA and all that April 21, 2011 10 / 35

Page 11: Topic Models, LDA and all that

Why Latent?

贝叶斯网络通过如下几个方面描述变量之间的关系:

∙ 连接结点的边和边的指向;∙ 结点的概率分布――先验分布和后验分布。

对于无法准确描述的变量关系通过引入隐隐隐含含含结结结点点点来解决。LDA中,通过隐含结点的后后后验验验概概概率率率来描述词的共现现象,并且对其赋予较高的概率。

肖智博 (DLMU-ITREC) Topic Models, LDA and all that April 21, 2011 11 / 35

Page 12: Topic Models, LDA and all that

主题模型:前人工作

有效的找到语料库中大量文档的简短描述,同时保留其内部的统计特征,为分类、文摘、异常点检测和相似性检验提供基础。

∙ 1983年— tf-idf统计词频,无法捕捉到文档内部和文档间的统计特征;

∙ 1990年— LSI(Latent Semantic Indexing)在词与文档(term-by-document)矩阵上使用SVD,tf-idf的线性组合,能捕捉到一些语法特征;

∙ 1999年— pLSI(aka Aspect Model 内容模型)参数随着语料库的容量增长,容易过拟合,在文档层面没有一个统计模型,无法对文档指定概率;

∙ 2003年— LDAbag-of-word假设,同时考虑词和文档交换性的混合模型

肖智博 (DLMU-ITREC) Topic Models, LDA and all that April 21, 2011 12 / 35

Page 13: Topic Models, LDA and all that

Graphical Model

∙ 结点代表变量,边代表可能的依赖关系∙ 隐含结点为空心,观测结点为实心∙ 盒子表示重复结构

P(y , x1, . . . , xn) = P(y)N∏︁

n=1

P(xn|y)

肖智博 (DLMU-ITREC) Topic Models, LDA and all that April 21, 2011 13 / 35

Page 14: Topic Models, LDA and all that

LDA in graphical model

肖智博 (DLMU-ITREC) Topic Models, LDA and all that April 21, 2011 14 / 35

Page 15: Topic Models, LDA and all that

LDA过程

对于语料库𝒟中的每个文档w ,LDA是如下的变参数层次贝叶斯网络:

1 选择单词的个数N ∼ Poission(𝜉)

2 选择文档中话题比率𝜃 ∼ Dir(𝛼)

3 对于每个单词wn

1 选择话题zn ∼ Multi(𝜃)2 从分布p(wn|zn, 𝛽)中选择单词wn

肖智博 (DLMU-ITREC) Topic Models, LDA and all that April 21, 2011 15 / 35

Page 16: Topic Models, LDA and all that

The “Actual” LDA过程

1 将语料库中的每个文档表示成词汇计数的向量模型

2 建立LDA模型

3 通过逼近方法计算这个模型

4 评价模型

5 模型应用

肖智博 (DLMU-ITREC) Topic Models, LDA and all that April 21, 2011 16 / 35

Page 17: Topic Models, LDA and all that

Topic Model解释

肖智博 (DLMU-ITREC) Topic Models, LDA and all that April 21, 2011 17 / 35

Page 18: Topic Models, LDA and all that

Topic Model主题指定示意

肖智博 (DLMU-ITREC) Topic Models, LDA and all that April 21, 2011 18 / 35

Page 19: Topic Models, LDA and all that

Latent Dirichlet Allocation

∙ Dirichlet起到了“平滑”的作用∙ 𝜃 ∼ Dir(𝛼)保证了每个文档中都包含了所有话题∙ 𝛽 ∼ Dir(𝜂)保证了每个话题包含所有词汇

∙ Dirichelt和Multinomial是共轭的

∙ 𝛼控制着𝜃的均值和稀疏度

肖智博 (DLMU-ITREC) Topic Models, LDA and all that April 21, 2011 19 / 35

Page 20: Topic Models, LDA and all that

Dirichlet Distribution — 𝛼

∙∑︀

𝛼i控制分布的聚集程度

∙ 当𝛼 < 1的时候,越来越稀疏

肖智博 (DLMU-ITREC) Topic Models, LDA and all that April 21, 2011 20 / 35

Page 21: Topic Models, LDA and all that

Dirichlet Distribution — samples

肖智博 (DLMU-ITREC) Topic Models, LDA and all that April 21, 2011 21 / 35

Page 22: Topic Models, LDA and all that

LDA — 后验概率估计方法

利用后验概率来估计参数

∙ Mean field Variational Inference

∙ Collapse Gibbs sampling

肖智博 (DLMU-ITREC) Topic Models, LDA and all that April 21, 2011 22 / 35

Page 23: Topic Models, LDA and all that

LDA — 结果

肖智博 (DLMU-ITREC) Topic Models, LDA and all that April 21, 2011 23 / 35

Page 24: Topic Models, LDA and all that

LDA — 结果

肖智博 (DLMU-ITREC) Topic Models, LDA and all that April 21, 2011 24 / 35

Page 25: Topic Models, LDA and all that

主题模型的后续改进以及演化

∙ LDA可以嵌嵌嵌入入入到到到其其其他他他更更更复复复杂杂杂的的的模模模型型型中中中,反应数据间的结构

∙ 可以根据来源不同,产产产生生生数数数据据据的的的概概概率率率分分分布布布也不同∙ 根据应用的不同,后后后验验验分分分布布布可以应用于各种场合

∙ 主题的演化与跟踪(Dynamic TM, Temporal TM)

∙ 相关主题间的发现(Correlated TM)

∙ 将TM应用于信息检索、分类、推荐等

肖智博 (DLMU-ITREC) Topic Models, LDA and all that April 21, 2011 25 / 35

Page 26: Topic Models, LDA and all that

Why does LDA ”work”?

为什么LDA的后验分布可以将属于一个主题的词放在一起?

∙ LDA中,作为先验分布的Dirichlet在一定程度上鼓励话题的“稀疏性”

∙ 多数文章中,每篇文章的确仅有几个主题∙ 由于主题数目≪词汇数目,所以词汇会产生类似聚类的“共同出现”效应

∙ 贝叶斯网络模型的条件独立性

肖智博 (DLMU-ITREC) Topic Models, LDA and all that April 21, 2011 26 / 35

Page 27: Topic Models, LDA and all that

Approximation Inference for LDA

肖智博 (DLMU-ITREC) Topic Models, LDA and all that April 21, 2011 27 / 35

Page 28: Topic Models, LDA and all that

如何得到LDA中的参数— 推断

LDA模型中最重要的计算任务是计算隐含变量的后验概率

p(𝜃, z |w , 𝛼, 𝛽) =p(𝜃, z ,w |𝛼, 𝛽)p(w |𝛼, 𝛽)

近似推断方法有两种:

∙ 变分法(Variational Inference)

∙ 抽样法(Gibbs Sampling)

肖智博 (DLMU-ITREC) Topic Models, LDA and all that April 21, 2011 28 / 35

Page 29: Topic Models, LDA and all that

推断方法

∙ 判定方法(变分、优化)∙ Mean Field, Belief Propagation∙ Variational Bayes, Expectation Propagation∙ 计算量小,不精确,可以给出边界

∙ 随机方法(抽样)∙ Metropolis-Hasting, Gibbs, MCMC, etc∙ 计算量大,但相对精确

肖智博 (DLMU-ITREC) Topic Models, LDA and all that April 21, 2011 29 / 35

Page 30: Topic Models, LDA and all that

LDA in Vision

肖智博 (DLMU-ITREC) Topic Models, LDA and all that April 21, 2011 30 / 35

Page 31: Topic Models, LDA and all that

Main difficulties

要解决的问题:

∙ 什么作为词?∙ 什么是文档?∙ 什么作为主题?

解决方案:

∙ 简单做法:每副图像作为一个文档,图像块(image patches)作为codebook当做词

∙ Spatial Latent Dirichlet Allocation

肖智博 (DLMU-ITREC) Topic Models, LDA and all that April 21, 2011 31 / 35

Page 32: Topic Models, LDA and all that

将LDA直接应用到图像领域

将图像做为文档,将图像中的部分视为词汇。具体处理过程如下:

1 抽取局部特征

2 利用局部特征构建codebook,通常采用简单的聚类方法将相似特征聚类

3 在bag-of-feature假设下,利用codebook将图像分割

肖智博 (DLMU-ITREC) Topic Models, LDA and all that April 21, 2011 32 / 35

Page 33: Topic Models, LDA and all that

Spatial LDA

∙ bag-of-word假设无法反应图像中的空间位置信息

∙ 被LDA训练出来的模型通常会将共同出现的词赋予相同主题,但是,图像领域这样假设不恰当(汽车和天空经常同时出现)

∙ 在LDA中小概率的词语通常会被指定到高概率的主题中,在图像中,小块的图像极有可能被指定到大块图像的主题中

肖智博 (DLMU-ITREC) Topic Models, LDA and all that April 21, 2011 33 / 35

Page 34: Topic Models, LDA and all that

Spatial LDASLDA通过将文档作为隐含变量达到将空间信息和时间信息引入模型的目的:

ci ∼ Normal(cd , 𝜃); cdj = (gd

j , xdj , y

dj )

gdj 是文档j所在图像的索引,(xdj , y

dj )是文档的位置

Figure: 将空间信息加入文档的方法。(a): 将图像分割成不重叠的区域,每个区域当成一个文档。每个区域中的图像块被指定到对应文档。(b): 一个图像块被多个区域重叠覆盖。(c): 每个图像对应一个点。如果一个图像块举例一个文档近,则有较高概率被指定到该文档。

肖智博 (DLMU-ITREC) Topic Models, LDA and all that April 21, 2011 34 / 35

Page 35: Topic Models, LDA and all that

部分参考文献

∙ D. Blei, A. Ng, and M. Jordan. Latent Dirichlet allocation. Journal ofMachine Learning Research, 3:993-1022, January 2003.

∙ D. Blei and M. Jordan. Variational inference for Dirichlet processmixtures. Journal of Bayesian Analysis, 1:121-144, 2006.

∙ M. Steyvers and T. Griffiths. Probabilistic Topic Models. In LatentSemantic Analysis: A Road to Meaning, T. Landauer, Mcnamara, S.Dennis, and W. Kintsch eds. Laurence Erlbaum, 2006.

∙ Y. Teh, M. Jordan, M. Beal, and D. Blei. Hierarchical Dirichletprocesses. Journal of the American Statistical Association,101:1566-1581, 2006.

∙ J. Zhu, A. Ahmed and E. P. Xing. MedLDA: Maximum MarginSupervised Topic Models for Regression and Classification. The 26thInternational Conference on Machine Learning, 2009.

∙ D. Blei and J. Lafferty. Dynamic topic models. In InternationalConference on Machine Learning, 2006.

肖智博 (DLMU-ITREC) Topic Models, LDA and all that April 21, 2011 35 / 35