For parsing algorithms in computer science, the inside–outside algorithm is a way of re-estimating production probabilities in a probabilistic context-free grammar. It was introduced by James K. Baker in 1979 as a generalization of the forward–backward algorithm for parameter estimation on hidden Markov models to stochastic context-free grammars. It is used to compute expectations, for example as part of the expectation–maximization algorithm (an unsupervised learning algorithm).
The inside probability
\betaj(p,q)
wp … wq
Nj
G
\betaj(p,q)=P(wpq
j | |
|N | |
pq |
,G)
The outside probability
\alphaj(p,q)
N1
j | |
N | |
pq |
wp … wq
G
\alphaj(p,q)=P(w1(p-1),
j | |
N | |
pq |
,w(q+1)m|G)
Base Case:
\betaj(p,p)=P(wp|Nj,G)
General case:
Suppose there is a rule
Nj → NrNs
wp … wq
Nj
k=q-1 | |
\sum | |
k=p |
P(Nj → NrNs)\betar(p,k)\betas(k+1,q)
The inside probability
\betaj(p,q)
\betaj(p,q)=
\sum | |
Nr,Ns |
k=q-1 | |
\sum | |
k=p |
P(Nj → NrNs)\betar(p,k)\betas(k+1,q)
Base Case:
\alphaj(1,n)=\begin{cases} 1&ifj=1\\ 0&otherwise \end{cases}
Here the start symbol is
N1
General case:
Suppose there is a rule
Nr → NjNs
Nj
\alphaj(p,q)
k=n | |
\sum | |
k=q+1 |
P(Nr → NjNs)\alphar(p,k)\betas(q+1,k)
Now suppose there is a rule
Nr → NsNj
\alphaj(p,q)
k=p-1 | |
\sum | |
k=1 |
P(Nr → NsNj)\alphar(k,q)\betas(k,p-1)
The outside probability
\alphaj(p,q)
\alphaj(p,q)
= \sum | |
Nr,Ns |
k=n | |
\sum | |
k=q+1 |
P(Nr → NjNs)\alphar(p,k)\betas(q+1,k) + \sum
Nr,Ns |
k=p-1 | |
\sum | |
k=1 |
P(Nr → NsNj)\alphar(k,q)\betas(k,p-1)