一个节点所有相邻的节点被称为它的
马尔可夫毯(Markov Blanket)。给定马尔可夫毯时,该节点与图中其他节点条件独立。
\begin{eqnarray*}
&&\mathrm{Pr}(B\mid A,C,D)=\frac{\mathcal{Pr}(A,B,C,D)}{_{}\mathcal{Pr}(A,C,D)}\\
&&\hspace{2em}=\frac{\phi_{AB}(A,B)\phi_{BC}(B,C)\phi_{CD}(C,D)\phi_{AD}(A,D)}{\phi_{CD}(C,D)\phi_{AD}(A,D)\sum_{B}\phi_{AB}(A,B)\phi_{BC}(B,C)}\\
&&\hspace{2em}=\frac{\phi_{AB}(A,B)\phi_{BC}(B,C)}{\sum_{B}\phi_{AB}(A,B)\phi_{BC}(B,C)}\\
&&\hspace{2em}=\mathrm{Pr}(B\mid A,C)
\end{eqnarray*}
用逻辑来表达概率
公式 \(\varphi\) 为真的概率至少为 \(\frac{1}{2}\)
\[w(\varphi)\geq\frac{1}{2}\]
用逻辑来表达概率
公式 \(\varphi_1\) 为真的概率至少为 \(\varphi_2\) 的两倍
\[w(\varphi_1)\geq2w(\varphi_2)\]
用逻辑来表达概率
\[M\models a_1 w(\varphi_1)+\ldots +a_k w(\varphi_k)\geq c\]
概率空间
概率空间是一个三元组 \((\Omega, \mathcal{F}, \mathrm{Pr})\),其中:
- \(\Omega\) 是一个非空集,被称为样本空间
- \(\mathcal{F}\subseteq 2^\Omega\) 是一个 \(\sigma\)-代数,代表可能事件
- \(\mathrm{Pr}:\mathcal{F}\mapsto[0,1]\) 是概率测度函数
- \(\mathrm{Pr}(\Omega)=1\)
- 它可数可加:若 \(\{A_i\}^\infty_{i=1}\subseteq\mathcal{F}\) 两两不相交,则
\[\mathrm{Pr}(\cup^\infty_{i=1}A_i)=\sum^\infty_{i=1}\mathrm{Pr}(A_i)\]
概率逻辑语言
我们仍然有一个自由代数,它包含一系列基本符号:
- \(\Phi=\{p_1, p_2, \ldots\}\) 为所有的原子命题
- 实数符号
- \(\neg\) 与 \(\vee\) 为逻辑连词
- \(w(\varphi)\) 是一个权重函数,\(\varphi\) 为以上符号构成的公式
- 算数符号
- 大小于符号
概率逻辑结构
四元组 \(M=(\Omega, \mathcal{F}, \mathrm{Pr}, \pi)\) 是一个概率逻辑结构(probabilistic logic structure),其中:
- \((\Omega, \mathcal{F}, \mathrm{Pr})\) 是一个概率空间
- \(\Omega\) 是关于 \(\Phi\) 的所有可能世界
- \(\mathcal{F}\subseteq 2^\Omega\) 是一个 \(\sigma\)-代数
- \(\mathrm{Pr}:\mathcal{F}\mapsto[0,1]\) 是概率测度函数
- \(\pi\) 为真值指派函数,例如:
- 原子命题 \(p\in\Phi\) 在可能世界 \(s\in\Omega\) 中的真值 \(\pi(s)(p)\in\{True,False\}\)
概率逻辑结构的语义
定义:对于 \(p\in\Phi\) 和它们组成的公式 \(\varphi\):
- \(p^M=\{s\in\Omega\mid\pi(s)(p)=True\}\)
- \(\varphi^M=\{s\in\Omega\mid\pi(s)(\varphi)=True\}\)
- \(w^M(p)=\mu(p^M)\)
- \(w^M(\varphi)=\mu(\varphi^M)\)
概率逻辑结构的语义
\[
M\models a_1 w(\varphi_1)+\ldots +a_k w(\varphi_k)\geq c
\]
当且仅当
\[
a_1 w^M(\varphi_1)+\ldots +a_k w^M(\varphi_k)\geq c
\]
基于可能世界的推理
考虑一个逻辑理论的 Herbrand universe:
- 每个具体事实可看作一个随机变量;
- 对它们的真值指派可看作一个可能世界(Possible world);
- 每个可能世界中均能够进行纯逻辑推理;
- 对问句(query)求它在所有可能世界中为真的期望;
- 概率分布只需定义在该 Herbrand universe 上即可
这种概率逻辑语义被称为“分布语义”(Distribution Semantics)
分布语义的公理系统
分布语义涵盖了命题逻辑与概率论公理,具体包含了:
- 命题逻辑公理
- 关于线性不等式的一切重言式
- 关于概率论的公理:
- \(0\leq w(\varphi)\leq 1\)
- \(w(True)=1\)
- \(w(\varphi\wedge\psi)+w(\varphi\wedge\neg \psi)=w(\varphi)\)
- \(w(\varphi)=w(\psi)\) 仅当 \(\varphi\equiv\psi\) 是一个命题逻辑中的重言式
概率逻辑程序的例子
%% Probabilistic facts:
0.5::heads1.
0.6::heads2.
%% Rules:
twoHeads :- heads1, heads2.
someHeads :- heads1.
someHeads :- heads2.
%% Queries:
query(twoHeads).
query(someHeads).
prob(twoHeads, 0.3).
prob(someHeads, 0.8).
概率逻辑程序的例子
%% Probabilistic rules:
0.3::stress(X) :- person(X).
0.2::influences(X,Y) :- person(X), person(Y).
0.4::cancer(X) :- smokes(X).
%% Non-probabilistic rules:
smokes(X) :- stress(X).
smokes(X) :- friend(X,Y), influences(Y,X), smokes(Y).
%% Facts
person(angelika).
person(joris).
person(jonas).
person(dimitar).
friend(joris,jonas).
friend(joris,angelika).
friend(joris,dimitar).
friend(angelika,jonas).
%% Query
query(cancer(X)).
%% Output
prob(cancer(angelika), 0.1368).
prob(cancer(dimitar), 0.12).
prob(cancer(jonas), 0.12).
prob(cancer(joris), 0.16920518).
统计关系模型
Startistical Relational AI (StaRAI) 的本质是将 ground rules 转换为布尔随机变量构成的概率图模型(Probabilistic Graphical Model, PGM)。
PGM 中的推理
统计推断(Statistical Inference):
- \(\mathrm{Pr}(x=1\mid y=4, z=3)\) 的概率是多少?
- \(\mathrm{Pr}(x, y)\) 联合概率分布中最可能出现的 \((X,Y)\) 是什么?
- 联合概率分布 \(\mathrm{Pr}(x,y,z)\) 的熵是多少?
- 明天大盘下跌的概率是多少?
消元法
计算如下边际概率:
\begin{eqnarray*}
&\mathrm{Pr}({\color{var(--zenburn-red)}{f}})=\sum_{{\color{var(--zenburn-blue)}{a,b,c,d,e,g}}}\mathrm{Pr}({\color{var(--zenburn-blue)}{a,b,c,d,e}},{\color{var(--zenburn-red)}{f}},{\color{var(--zenburn-blue)}{g}})\\
&\hspace{1em}= \sum_{a,b,c,d,e,g}\mathrm{Pr}(f\mid d)\mathrm{Pr}(g\mid d,e)\mathrm{Pr}(c\mid a)\mathrm{Pr}(d\mid a,b)\mathrm{Pr}(a)\mathrm{Pr}(b)\mathrm{Pr}(e)
\end{eqnarray*}
消息传递
将边际概率看作“消息传递”(message passing)。考虑如下布尔马尔可夫链:
其联合概率分布的分解形式为:\(\mathrm{Pr}(a,b,c,d)=\mathrm{Pr}(a\mid b)\mathrm{Pr}(b\mid c)\mathrm{Pr}(c\mid d)\mathrm{Pr}(d)\)
计算 \(\mathrm{Pr}(a=0)=?\):
- 第一种方式:直接计算 \(\mathrm{Pr}(a=0)=\sum_{b,c,d}\mathrm{Pr}(a=0\mid b)\mathrm{Pr}(b\mid c)\mathrm{Pr}(c\mid d)\mathrm{Pr}(d)\)
- 第二种方式:将求和操作分解
- 先将 \(d\) 推进去:
\[\mathrm{Pr}(a=0)=\sum_{b,c}\mathrm{Pr}(a=0\mid b)\mathrm{Pr}(b\mid c)\underbrace{\color{var(--zenburn-blue)}{\sum_d {\mathrm{Pr}(c\mid d) \mathrm{Pr}(d)}}}_{\gamma_d(c)}\]
- 对于 \(\gamma_d(c)\) 需要计算 \(2\) 次求和。
消息传递
- 先将 \(\sum_d\) 推进去:
\[\mathrm{Pr}(a=0)=\sum_{b,c}\mathrm{Pr}(a=0\mid b)\mathrm{Pr}(b\mid c)\underbrace{\color{var(--zenburn-blue)}{\sum_d {\mathrm{Pr}(c\mid d) \mathrm{Pr}(d)}}}_{\gamma_d(c)}\]
- 对于 \(\gamma_d(c)\) 需要计算 \(2\) 次求和。
- 再将 \(\sum_c\) 推进去:
\[\mathrm{Pr}(a=0)=\sum_{b}\mathrm{Pr}(a=0\mid b)\underbrace{\color{var(--zenburn-blue)}{\sum_c {\mathrm{Pr}(b\mid c)\gamma_d(c)}}}_{\gamma_c(b)}\]
- 对于 \(\gamma_c(b)\) 需要计算 \(2\) 次求和。
- 最后将 \(\sum_b\) 推进去:
\[\mathrm{Pr}(a=0)=\underbrace{\color{var(--zenburn-blue)}{\sum_b {_{}\mathrm{Pr}(a=0\mid b)\gamma_c(b)}}}_{\gamma_b(a)}\]
- 对于 \(\gamma_b(a)\) 需要计算 \(1\) 次求和。
消息传递
\begin{equation*}
\mathrm{Pr}(a=0)=\underbrace{\sum_{b}\mathrm{Pr}(a=0\mid b)\underbrace{\sum_c \mathrm{Pr}(b\mid c)\underbrace{\sum_d {\mathrm{Pr}(c\mid d) \mathrm{Pr}(d)}}_{\gamma_d(c)}}_{\gamma_c(b)}}_{\gamma_b(a)}
\end{equation*}
因子图
图模型中用方形节点表示其相邻节点随机变量构成的因子(factor),它是一个非负函数。
左边因子图表示是 \(4\) 个因子的乘积:
\[f(a,b,c,d,e)=f_1(a,b)f_2(b,c,d)f_3(c,e)f_4(d,e)\]
马尔可夫网的因子图
- (a) 的势函数因子:\(\phi(a,b,c)\)
- (b) 的势函数因子:\(\phi_1(a,b)\phi_2(b,c)\phi_3(a,c)\)
- (a) 和 (b) 有着相同的马尔可夫网结构 (c)
- 但 (b) 表达了更多关于势函数的约束(例如逻辑规则)
信念传播
Belief Propagation:
因子图中一个节点只有在完全收集到邻居传来的“信息”时才可以将自己的“信息”传递出去。
\[\mathrm{Pr}(a,b,c,d,e)\propto f_1(a,b)f_2(b,c,d)f_3(c)f_4(d,e)f_5(d)\]
信念传播・Sum-Product
随机变量到因子节点
\[{\color{var(--zenburn-red)}{\mu_ {v\rightarrow f}(v)}}=\prod_{f_i \sim v\backslash f}{\color{var(--zenburn-blue)}{ \mu_{f_i \rightarrow v}(v)}}\]
边界变量(无输入邻居因子)的信息为 \(1\)。
因子节点到随机变量
\[{\color{var(--zenburn-red)}{\mu_{f\rightarrow v}(v)}}=\sum _{\{v_i\}}f(v,\{v_i\})\prod_{v_i \sim f\backslash v}{\color{var(--zenburn-blue)}{ \mu_{v_i \rightarrow f}(v_i)}}\]
边界因子(无输入邻居变量)的信息为其本身。
知识编译
Knowledge Compilation: 将逻辑表达式编译为一个电路(circuit)以进行高效运算
知识编译
贝叶斯网可以编码为如下布尔表达式:
\[
\{(\theta_A \wedge A)\wedge ((\theta_{B\mid A}\wedge B)\vee(\theta_{\neg B\mid A}\wedge\neg B))\}\vee\{(\theta_{\neg A}\wedge A)\wedge((\theta_{B\mid \neg A}\wedge B)\vee(\theta_{\neg B\mid \neg A}\wedge \neg B))\}
\]
\(A\):
\begin{eqnarray*}
A&\Leftrightarrow&\theta_A\\
\neg A&\Leftrightarrow&\theta_{\neg A}
\end{eqnarray*}
\(A\rightarrow B\):
\begin{eqnarray*}
A\wedge B&\Leftrightarrow&\theta_ {B\mid A}\\
A\wedge \neg B&\Leftrightarrow&\theta_ {\neg B\mid A}\\
\neg A\wedge B&\Leftrightarrow&\theta_ {B\mid \neg A}\\
\neg A\wedge \neg B&\Leftrightarrow&\theta_ {\neg B\mid \neg A}
\end{eqnarray*}
知识编译
\begin{eqnarray*}
(\theta_A \wedge A)\wedge ((\theta_{B\mid A}\wedge B)\vee(\theta_{\neg B\mid A}\wedge\neg B))\vee\\
(\theta_{\neg A}\wedge A)\wedge((\theta_{B\mid \neg A}\wedge B)\vee(\theta_{\neg B\mid \neg A}\wedge \neg B))
\end{eqnarray*}
对应着:
\begin{eqnarray*}
(\mathrm{Pr}(A=true)\cdot A)\cdot((\mathrm{Pr}(B=true\mid A=true)\cdot B)+(\mathrm{Pr}(B=false\mid A=true)\cdot \neg B))+\\
(\mathrm{Pr}(A=false)\cdot \neg A)\cdot((\mathrm{Pr}(B=true\mid \neg A=true)\cdot B)+(\mathrm{Pr}(B=false\mid A=false)\cdot \neg B))
\end{eqnarray*}
当我们将 \(A, B, \neg A, \neg B\in \{0,1\}\) 代入时,即可获得欲求得的概率值。
例如,令 \(A=1, B=1\) 可得:
\begin{eqnarray*}
&&(\mathrm{Pr}(A=true)\cdot A)\cdot(\mathrm{Pr}(B=true\mid A=true)\cdot B)\\
&&=\mathrm{Pr}(A=true)\cdot\mathrm{Pr}(B=true\mid A=true)
\end{eqnarray*}
转化为算数电路
将 and 和 or 分别换成 \(\times\) 和 \(+\),可将贝叶斯网转化为一个多项式:
\begin{eqnarray*}
&&\theta_A A(\theta_{B\mid A}B+\theta_{\neg B\mid A}\neg B)+\theta_{\neg A} \neg A(\theta_{B\mid \neg A}B+\theta_{\neg B\mid \neg A}\neg B)\\
&=&\theta_A A\theta_{B\mid A}B+\theta_A A\theta_{\neg B\mid A}\neg B+\theta_{\neg A} \neg A\theta_{B\mid \neg A}B+\theta_{\neg A} \neg A\theta_{\neg B\mid \neg A}\neg B
\end{eqnarray*}
可以看到,这里的 \(A,B,\neg A,\neg B\) 均为布尔表达式 \(\theta_x\) 的权重!
转化为算数电路
\begin{equation*}
\theta_A A\theta_{B\mid A}B+\theta_A A\theta_{\neg B\mid A}\neg B+\theta_{\neg A} \neg A\theta_{B\mid \neg A}B+\theta_{\neg A} \neg A\theta_{\neg B\mid \neg A}\neg B
\end{equation*}
计算 \(\mathrm{Pr}(A=false)\) 时,只需令权重 \(A=0,\neg A=1, B=1, \neg B=1\)
\begin{eqnarray*}
&&\mathrm{Pr}(A=false)=0+0+\theta_{\neg A} \neg A\theta_{B\mid \neg A}B+\theta_{\neg A} \neg A\theta_{\neg B\mid \neg A}\neg B\\
&=&0+0+\theta_{\neg A} \theta_{B\mid \neg A}+\theta_{\neg A} \theta_{\neg B\mid \neg A}=\theta_{\neg A}
\end{eqnarray*}
Max-Product
当需要计算 MPE(most-probable explanation)时,可编译一个 max-product 电路:
将 and 和 or 分别换成 \(\times\) 和 \(\max\):
\[
\max(\theta_A A\cdot \max(\theta_{B\mid A}B,\theta_{\neg B\mid A}\neg B),\theta_{\neg A} \neg A\cdot\max(\theta_{B\mid \neg A}B,\theta_{\neg B\mid \neg A}\neg B))
\]
计算 \(\mathop{\arg\max}\limits_b \mathrm{Pr}(A=false, B=b)\) 时,只需令权重 \(A=0,\neg A=1, B=1, \neg B=1\) 并计算上式。
算数电路中的概率推断
- 计算观测变量(或称为证据,evidence)\(\mathrm{Pr}(evidence)\) 的概率只需要重新设置权重:
- 若 \(e=true\) 则令权重 \(e=1\) 且 \(\neg e=0\),反之亦然
- 若 \(v\) 不是观测变量,则令 \(v=1\) 且 \(\neg v=1\)
- 对于所有条件概率表中的条目:令 \(\neg\theta_x=1\) 且 \(\theta_x=CPT(x)\)
- 因为权重可以重新设置,算数电路可被用于多次重复运算
- 仅需要编译一次(花费较高),但以后每次推断速度都很快
- 可类比于信念传播,完成传播后可获得所有变量的边际分布
- 如何保证算数电路能够计算出正确的结果?
- sd-DNNF (smooth, deterministic, Decomposable Negation Normal Form)
参数学习
\[
\underbrace{\mathrm{Pr}(\theta\mid \mathcal{D})}_{\text{posterior}}=\frac{\overbrace{\mathrm{Pr}(\mathcal{D}\mid \theta)}^{\text{likelihood}}\cdot\overbrace{\mathrm{Pr}(\theta)}^{\text{prior}}}{\underbrace{\mathrm{Pr}(\mathcal{D})}_{\text{evidence}}}
\]
- \(\theta\):参数,即概率事实、概率规则的权重
- \(\mathcal{D}\):训练数据,\(\{X=x\}^n_{i=1}\)
参数学习
考虑模型 \(M\):
\[
\mathrm{Pr}(\theta\mid\mathcal{D},M)=\frac{\mathrm{Pr}(\mathcal{D}\mid \theta,M)\cdot\mathrm{Pr}(\theta\mid M)}{\underbrace{\mathrm{Pr}(\mathcal{D}\mid M)}_{\text{marginal likelihood}}}
\]
- 最大似然(ML)
\[\theta^*=\mathop{\arg\max}\limits_\theta \mathrm{Pr}(\mathcal{D}\mid\theta,M)\]
- 最大后验概率(MAP)
\[\theta^*=\mathop{\arg\max}\limits_\theta \mathrm{Pr}(\theta\mid\mathcal{D},M)\]
- 若 \(\mathrm{Pr}(\theta\mid M)=\text{const.}\),那么 MAP=ML
\[\theta^*=\mathop{\arg\max}\limits_\theta \mathrm{Pr}(\theta\mid\mathcal{D},M)=\mathop{\arg\max}\limits_\theta \frac{\mathrm{Pr}(\mathcal{D}\mid\theta,M)\mathrm{Pr}(\theta\mid M)}{\mathrm{Pr}(\mathcal{D}\mid\theta)}=\mathop{\arg\max}\limits_\theta \mathrm{Pr}(\mathcal{D}\mid\theta,M)\]
马尔可夫逻辑的参数估计
\[
\mathrm{Pr}_w(\mathbf{X})=\frac{1}{Z}\prod_i \phi_i (\mathbf{X})=\frac{1}{Z}\exp\left(\sum_i {\color{var(--zenburn-red)}{w_i}} {\color{var(--zenburn-blue)}{n_i }}(\mathbf{X})\right)
\]
马尔可夫逻辑的参数估计
判别式学习:预测条件似然 \(\mathrm{Pr}(y\mid x)\)
\[
\mathrm{Pr}(y\mid x)=\frac{1}{Z_x}\exp\left(\sum_{i\in F_Y}w_i n_i (x,y)\right)
\]
- \(\color{var(--zenburn-red)}{w_i}\):第 \(i\) 个子句的权重
- \(Z_x\):取值 \(X=x\) 的所有 possible world 权重之和(条件配分函数)
- \(F_Y\):包含问句原子 \(Y\) 的所有子句(马尔可夫毯)
- \(n_i(x,y)\):当变量取值为 \((X,Y)=(x,y)\) 时,第 \(i\) 个子句中为真的原子个数
参数 \(w_i\) 关于对数似然函数的梯度
\begin{eqnarray*}
\frac{\partial}{\partial w_i}\log\mathrm{Pr}_w(y\mid x)&=&n_i(x,y) -\sum_{y'}\mathrm{Pr}_w(y'\mid x)n_i(x,y')\\
&=&n_i(x,y)-E_w \left[n_i(x,y)\right]
\end{eqnarray*}
马尔可夫逻辑的参数估计
生成式学习:预测联合概率似然 \(\mathrm{Pr}(x)\)
\[
\mathrm{Pr}_w(X=x)=\frac{1}{Z}\exp\left(\sum_{i\in F} w_i n_i (x)\right)
\]
参数 \(w_i\) 关于对数似然函数的梯度
\[
\frac{\partial}{\partial w_i}\log\mathrm{Pr}_w(X=x) = n_i(x) - \sum_{x'}\mathrm{P}_w(X=x')n_i(x')
\]
配分函数和 model 的概率分布计算是 intractable 的:
马尔可夫逻辑的参数估计
对于含递归规则的一阶概率逻辑问题来说
基于 MCMC (如 Gibbs 采样)的推理基本很难在短时间内收敛
伪似然函数
\[
\mathrm{Pr}^*_w(X=x)=\prod_{l=1}^n \mathrm{Pr}(X_l=x_l \mid MB_x(X_l))
\]
- \(X_l, l\in\{1,\ldots,n\}\):Markov 网中的所有随机变量(groundings)
- \(MB_x(X_l)\):变量 \(X_l\) 的马尔可夫毯在 \(X=x\) 时的取值
伪似然函数
参数 \(w_i\) 关于对数伪似然函数的梯度
\begin{eqnarray*}
\frac{\partial}{\partial w_i}\log\mathrm{Pr}^*_w(X=x) = \sum_{l=1}^n \left[n_i(x) - \mathrm{P}_w(X_l=0\mid MB_x(X_l))n_i(x_{[X_l=0]})\\
- \mathrm{P}_w(X_l=1\mid MB_x(X_l))n_i(x_{[X_l=1]})\right]
\end{eqnarray*}
- \(n_i(x_{[X_l=0]})\):在第 \(i\) 个子句中令 \(X=x\) 并强行设置 \(X_l=0\) 时真原子的个数
- 不再需要用 WMC 对全局模型进行推理,速度极快
- 只关心每个 grounding 的局部信息
- 当推理链较长、依赖关系复杂时,准确率非常差
Max-margin Learning
对于判别式学习,除了之间最大化条件对数似然函数,还可以最大化如下“margin”:
\[
\frac{\mathrm{Pr}_\mathbf{w}(y|x)}{\mathrm{Pr}_\mathbf{w}(\hat{y}|x)}
\]
- 其中 \(\hat{y}\) 是参数 \(\mathbf{w}\) 下随机变量 \(Y\) 除了 \(y\) 以外最可能的赋值:
\[\hat{y}=\mathop{\arg\max}\limits_{\bar{y}\in Y\backslash y}\mathrm{Pr}_\mathbf{w}(\bar{y}\mid x)\]
借助 structural SVM,可以将上面的目标表达为如下优化问题:
\begin{eqnarray*}
\min_{\mathbf{w},\xi\geq 0}&&\frac{1}{2}\mathbf{w}^T \mathbf{w}+C\xi\\
s.t. &&\forall \bar{y}\in Y: \mathbf{w}^T[\mathbf{n}(x,y)-\mathbf{n}(x,\hat{y})]\geq\Delta(y,\bar{y})-\xi
\end{eqnarray*}
ProbLog 中的参数学习
一阶 ProbLog 的概率分布函数:
\[
\mathrm{Pr}(L\mid\mathcal{T})=\prod_{f_n \theta_{n,k}\in L} p_n \prod_{f_n \theta_{n,k}\in L_\mathcal{T}\backslash L} (1-p_n)
\]
其中
- \(\{\theta_{n,1},\ldots, \theta_{n,K}\}\) 是第 \(n\) 个一阶概率原子的所有可能变量替换
- \(\mathcal{T}=\mathcal{F}\cup\mathcal{BK}=\{p_1::f_1,\ldots p_N::f_N\}\cup \mathcal{BK}\) 为 ProbLog 程序,其中 \(p_i::f_i\) 为概率原子公式,\(BK\) 是一阶逻辑程序
- 概率原子公式及它们的变量替换定义了一个在其 Herbrand Universe \(L_\mathcal{T}=\{f_1 \theta_{1,1},\ldots, f_1 \theta_{1,K_1},\ldots,f_N \theta_{N,1},\ldots, f_N \theta_{N,K_N}\}\) 上的分布语义
ProbLog 中的参数学习
概率事实 \(\mathcal{F}\)
0.1::burglary.
0.2::earthquake.
0.7::heard(X).
一阶知识库 \(\mathcal{BK}\)
person(mary).
person(john).
alarm :- burglary; earthquake.
calls(X) :- person(X), alarm, heard(X).
\(\mathcal{F}\) 构成的Herbrand Universe 为:
heard(mary), heard(john), burglary, earthquake
ProbLog 中的“解释”
0.1::burglary.
0.2::earthquake.
0.7::heard(X).
person(mary).
person(john).
alarm :- burglary; earthquake.
calls(X) :- person(X), alarm, heard(X).
部分解释(partial interpretation)
\begin{eqnarray}
&&I^+=\{person(mary), person(john),{\color{var(--zenburn-blue)}{burglary}}, alarm, {\color{var(--zenburn-blue)}{heard(john)}}, calls(john)\}\\
&&I^-=\{calls(mary), {\color{var(--zenburn-blue)}{heard(mary)}}\}
\end{eqnarray}
\[
\mathrm{Pr}_w((I^+, I^-))=0.1\times 0.7\times(1-0.7)\times\underbrace{(0.2+(1-0.2))}_{\text{earthquake}}
\]
LFI-Problog
Learning from Interpretation:
- 从部分或完整观测数据(即证据包含部分/全部 groundings)中学习。
本质上,LFI 是一种最大似然估计:
\begin{equation*}
\hat{\theta}=\mathop{\arg\max}_\theta \mathrm{Pr}(\mathcal{D}\mid\mathcal{T}_\theta)=\mathop{\arg\max}_\theta \prod_{m=1}^M \mathrm{Pr}(I_m \mid\mathcal{T}_\theta)
\end{equation*}
其中,
- 训练数据 \(\mathcal{D}=\{I_1, \ldots, I_M\}\) 所有 Interpretation 的集合
- \(\theta=\{p_1, p_2, \ldots, p_n\}\) 为所有概率事实的权重
LFI-Problog
当 \(\mathcal{D}\) 中的训练数据均为“
完整解释”时:
- 每个 \(I_m\) 中均包含了所有概率事实的真值
- 第 \(n\) 个概率事实 \(p_n::f_n\) 的参数 \(p_n\) 的估计可通过数数来完成
\begin{equation*}
\hat{p}_n=\frac{1}{Z_n}\sum_{m=1}^M \sum_{k=1}^{K^m_n} \delta^m_{n,k}
\end{equation*}
其中,
\begin{equation*}
\delta^m_{n,k}=\begin{cases}
1, &\text{if }f_n \theta^m_{n,k}\in I_m\\
0,&\text{else}
\end{cases}
\end{equation*}
- \(m\) 代表第 \(m\) 个解释:\(f_n \theta^m_{n,k}\) 是 \(f_n\) 在 \(I_m\) 中利用第 \(k\) 个替换得到的 grounding
- \(Z_n=\sum_{m=1}^M K_n^m\) 是 \(f_n\) 在所有解释中的 grounding 个数
LFI-Problog
当 \(\mathcal{D}\) 中的训练数据为“
部分解释”时:
- \(I_m\) 中包含隐变量(无真值指派的 groundings)
- 通过 EM 算法求解
\begin{equation*}
\hat{p}_n^{(i+1)}=\frac{1}{Z_n}\sum_{m=1}^M \sum_{k=1}^{K^m_n} \mathrm{Pr}_ {\mathcal{T}_\hat{\mathbf{p}}^{(i)}}\left[f_{n,k}\mid I_m \right]
\end{equation*}
其中计算期望的步中需要将 \(I_m\) 编译为 d-DNNF 来推理隐变量的边际概率。
LFI-Problog