Sophie

Sophie

distrib > Fedora > 14 > x86_64 > media > updates > by-pkgid > 0e54ba0ee564ce6063a5e83aa86060c5 > files > 619

festival-speechtools-devel-1.2.96-18.fc14.i686.rpm

  <sect1 id='ngram-test-manual'>
	<title><command>ngram_test</command> <emphasis> Test n-gram language model </emphasis></title>

    <toc depth='1'></toc>
    <para>
    </para>
    <sect2>
      <title>Synopsis</title>
      <para>
      </para>
        <!-- /amd/projects/festival/versions/v_mpiro/speech_tools_linux/bin/ngram_test -sgml_synopsis -->
        <para>
<cmdsynopsis><command>ngram_test</command>[input file0] [input file1] ...<arg>-w <replaceable>ifile</replaceable></arg>
<arg>-S <replaceable>ifile</replaceable></arg>
<arg>-raw_stats </arg>
<arg>-brief </arg>
<arg>-f </arg>
<arg>-input_format <replaceable>string</replaceable></arg>
<arg>-prev_tag <replaceable>string</replaceable></arg>
<arg>-prev_prev_tag <replaceable>string</replaceable></arg>
<arg>-last_tag <replaceable>string</replaceable></arg>
<arg>-default_tags </arg>
</cmdsynopsis>
        </para>
        <!-- DONE /amd/projects/festival/versions/v_mpiro/speech_tools_linux/bin/ngram_test -sgml_synopsis -->
      <para>

ngram_test is for testing ngram models generated from
<link linkend=ngram-build-manual>ngram_build</link>.
<formalpara> <para> <title> How do we test an ngram model ?  </title>
</para>
<para> ngram_test will compute the entropy (or perplexity, see below)
of some test data, given an ngram model. The entropy gives a measure
of how likely the ngram model is to have generated the test
data. Entropy is defined (for a sliding-window type ngram) as:
\[H = -\frac{1}{Q} \sum_{i=1}^{Q} log P(w_i | w_{i-1}, w_{i-2},... w_{i-N+1}) \]
where \(Q\) is the number of words of test data and \(N\) is the order
of the ngram model. Perplexity is a more intuitive mease, defined as:
\[B = 2^H \]
The perplexity of an ngram model with vocabulary size V will be
between 1 and V. Low perplexity indicates a more predictable language,
and in speech recognition, a models with low perplexity on test data
(i.e. data NOT used to estimate the model in the first place)
typically give better accuracy recognition than models with higher 
perplexity (this is not guaranteed, however).
test_ngram works with non-sliding-window type models when the input
format is <parameter>ngram_per_line</parameter>.
</para>
</formalpara>
<formalpara>
<para><title>Input data format</title></para>
<para> The data input format options are the same as
<link linkend=ngram-build-manual>ngram_build</link>, as is the treatment of sentence start/end using
special tags. 
</para>
<para>
Note: To get meaningful entropy/perplexity figures, it is recommended that
you use the same data input format in both
<link linkend=ngram-build-manual>ngram_build</link> and <link linkend=ngram-test-manual>ngram_test</link>, and the treatment of
sentence start/end should be the same.
</para>
</formalpara>
      </para>
        <formalpara>
          <title>See also</title><para>
          <itemizedlist>
          <listitem><para>ngram_build </para></listitem>
          </itemizedlist>
        </para></formalpara>
    </sect2>
    <sect2>
      <title>OPTIONS</title>
      <para>
      </para>
        <!-- /amd/projects/festival/versions/v_mpiro/speech_tools_linux/bin/ngram_test -sgml_options -->
        <para>
<variablelist>
<varlistentry><term>-g</term>
<LISTITEM><PARA>
<replaceable>ifile</replaceable>

grammar file (required) 
</PARA></LISTITEM>
</varlistentry>

<varlistentry><term>-w</term>
<LISTITEM><PARA>
<replaceable>ifile</replaceable>

filename containing word list (required for some grammar formats) 
</PARA></LISTITEM>
</varlistentry>

<varlistentry><term>-S</term>
<LISTITEM><PARA>
<replaceable>ifile</replaceable>

script file 
</PARA></LISTITEM>
</varlistentry>

<varlistentry><term>-raw_stats</term>
<LISTITEM><PARA>

print unnormalised entropy and sample count 
</PARA></LISTITEM>
</varlistentry>

<varlistentry><term>-brief</term>
<LISTITEM><PARA>

print results in brief format 
</PARA></LISTITEM>
</varlistentry>

<varlistentry><term>-f</term>
<LISTITEM><PARA>

print stats for each file 
</PARA></LISTITEM>
</varlistentry>

<varlistentry><term>-input_format</term>
<LISTITEM><PARA>
<replaceable>string</replaceable>

format of input data (default sentence_per_line) 
may also be sentence_per_file, or ngram_per_line. 
Pseudo-words : 
</PARA></LISTITEM>
</varlistentry>

<varlistentry><term>-prev_tag</term>
<LISTITEM><PARA>
<replaceable>string</replaceable>

tag before sentence start 
</PARA></LISTITEM>
</varlistentry>

<varlistentry><term>-prev_prev_tag</term>
<LISTITEM><PARA>
<replaceable>string</replaceable>

all words before 'prev_tag' 
</PARA></LISTITEM>
</varlistentry>

<varlistentry><term>-last_tag</term>
<LISTITEM><PARA>
<replaceable>string</replaceable>

after sentence end 
</PARA></LISTITEM>
</varlistentry>

<varlistentry><term>-default_tags</term>
<LISTITEM><PARA>

use default tags of !ENTER,!EXIT and !EXIT 
respectively </PARA></LISTITEM>
</varlistentry>
</variablelist>
        </para>
        <!-- DONE /amd/projects/festival/versions/v_mpiro/speech_tools_linux/bin/ngram_test -sgml_options -->
    </sect2>
    <sect2>
      <title>Hints</title>
      <para>
<title>I got a perplexity of Infinity - what went wrong ?</title>
A perplexity of Infinity means that at least one of the ngrams in your
test data had a probility of zero. Possible reasons for this include:
<itemizedlist>
<listitem><para>The training data had no examples of this ngram, and
you did not specify a floor for zero frequency ngrams in
\Ref{build_ngram} </para></listitem>
<listitem><para>You used differing input formats for \Ref{ngram_build}
and \Ref{ngram_test}. </para></listitem>
<listitem><para>You used differing sentence start/end treatments in
\Ref{ngram_build} and \Ref{ngram_test}. </para></listitem>
</itemizedlist>
      </para>
    </sect2>
  </sect1>