Inside–outside algorithm explained

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).

Inside and outside probabilities

The inside probability

\betaj(p,q)

is the total probability of generating words

wpwq

, given the root nonterminal

Nj

and a grammar

G

:[1]

\betaj(p,q)=P(wpq

j
|N
pq

,G)

The outside probability

\alphaj(p,q)

is the total probability of beginning with the start symbol

N1

and generating the nonterminal
j
N
pq
and all the words outside

wpwq

, given a grammar

G

:[1]

\alphaj(p,q)=P(w1(p-1),

j
N
pq

,w(q+1)m|G)

Computing inside probabilities

Base Case:

\betaj(p,p)=P(wp|Nj,G)

General case:

Suppose there is a rule

NjNrNs

in the grammar, then the probability of generating

wpwq

starting with a subtree rooted at

Nj

is:
k=q-1
\sum
k=p

P(NjNrNs)\betar(p,k)\betas(k+1,q)

The inside probability

\betaj(p,q)

is just the sum over all such possible rules:

\betaj(p,q)=

\sum
Nr,Ns
k=q-1
\sum
k=p

P(NjNrNs)\betar(p,k)\betas(k+1,q)

Computing outside probabilities

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

NrNjNs

in the grammar that generates

Nj

.Then the left contribution of that rule to the outside probability

\alphaj(p,q)

is:
k=n
\sum
k=q+1

P(NrNjNs)\alphar(p,k)\betas(q+1,k)

Now suppose there is a rule

NrNsNj

in the grammar. Then the rightcontribution of that rule to the outside probability

\alphaj(p,q)

is:
k=p-1
\sum
k=1

P(NrNsNj)\alphar(k,q)\betas(k,p-1)

The outside probability

\alphaj(p,q)

is the sum of the left and rightcontributions over all such rules:

\alphaj(p,q)

= \sum
Nr,Ns
k=n
\sum
k=q+1

P(NrNjNs)\alphar(p,k)\betas(q+1,k) + \sum

Nr,Ns
k=p-1
\sum
k=1

P(NrNsNj)\alphar(k,q)\betas(k,p-1)

References

External links

Notes and References

  1. Book: Manning, Christopher D. . Hinrich Schütze . Foundations of Statistical Natural Language Processing . limited . MIT Press . Cambridge, MA, USA . 1999 . 0-262-13360-1 . 388–402.