viterbi Combine n-gram model and likelihoods to estimate posterior probabilities

Table of Contents


viterbi [observations file] -o [output file] [-ngram string] [-given string] [-vocab string] [-ob_type string] [-lm_floor float] [-lm_scale float] [-ob_floor float] [-ob_scale float] [-prev_tag string] [-prev_prev_tag string] [-last_tag string] [-default_tags ] [-observes2 string] [-ob_floor2 float] [-ob_scale2 float] [-ob_prune float] [-n_prune int] [-prune float] [-trace ]

viterbi is a simple time-synchronous Viterbi decoder. It finds the most likely sequence of items drawn from a fixed vocabulary, given frame-by-frame observation probabilites for each item in that vocabulary, and a ngram grammar. Possible uses include:

  • Simple speech recogniser back end

viterbi can optionally use two sets of frame-by-frame observation probabilites in a weighted-sum fashion. Also, the ngram language model is not restricted to the conventional sliding window type in which the previous n-1 items are the ngram context. Items in the ngram context at each frame may be given. In this case, the user must provide a file containing the ngram context: one (n-1) tuple per line. To include items from the partial Viterbi path so far (i.e. found at recognition time, not given) the special notation <-N> is used where N indicates the distance back to the item required. For example <-1> would indicate the item on the partial Viterbi path at the last frame. See \Ref{Examples}.


Three types of pruning are available to reduce the size of the search space and therefore speed up the search:

  • Observation pruning

  • Top-N pruning at each frame

  • Fixed width beam pruning



string Grammar file, required


string ngram left contexts, per frame


string File with names of vocabulary, this must be same number as width of observations, required


string Observation type : likelihood .... and change doc"probs" or "logs" (default is "logs") Floor values and scaling (scaling is applied after floor value)


float LM floor probability


float LM scale factor factor (applied to log prob)


float Observations floor probability


float Observation scale factor (applied to prob or log prob, depending on -ob_type)


string tag before sentence start


string all words before 'prev_tag'


string after sentence end


use default tags of !ENTER,!EXIT and !EXIT respectively


string second observations (overlays first, ob_type must be same)






float observation pruning beam width (log) probability


int top-n pruning of observations


float pruning beam width (log) probability


show details of search as it proceeds


Example 'given' file (items f and g are in the vocabulary), the ngram is a 4-gram.

<-2> g g <-1> g f <-1> f g <-2> g g <-3> g g <-1> g f