@@ -202,12 +202,15 @@ After training the model, we can use it to generate sequences. A common practice
* use :code:`GeneratedInput` for trg_embedding. :code:`GeneratedInput` computes the embedding of the generated token at the last time step for the input at the current time step.
* use :code:`beam_search` function. This function needs to set:
- :code:`id_input`: the integer ID of the data, used to identify the corresponding output in the generated files.
- :code:`dict_file`: the dictionary file for converting word id to word.
- :code:`bos_id`: the start token. Every sentence starts with the start token.
- :code:`eos_id`: the end token. Every sentence ends with the end token.
- :code:`beam_size`: the beam size used in beam search.
- :code:`max_length`: the maximum length of the generated sentences.
* use :code:`seqtext_printer_evaluator` to print text according to index matrix and dictionary. This function needs to set:
- :code:`id_input`: the integer ID of the data, used to identify the corresponding output in the generated files.
- :code:`dict_file`: the dictionary file for converting word id to word.
- :code:`result_file`: the path of the generation result file.
<li>use <codeclass="code docutils literal"><spanclass="pre">GeneratedInput</span></code> for trg_embedding. <codeclass="code docutils literal"><spanclass="pre">GeneratedInput</span></code> computes the embedding of the generated token at the last time step for the input at the current time step.</li>
<li>use <codeclass="code docutils literal"><spanclass="pre">beam_search</span></code> function. This function needs to set:<ul>
<li><codeclass="code docutils literal"><spanclass="pre">id_input</span></code>: the integer ID of the data, used to identify the corresponding output in the generated files.</li>
<li><codeclass="code docutils literal"><spanclass="pre">dict_file</span></code>: the dictionary file for converting word id to word.</li>
<li><codeclass="code docutils literal"><spanclass="pre">bos_id</span></code>: the start token. Every sentence starts with the start token.</li>
<li><codeclass="code docutils literal"><spanclass="pre">eos_id</span></code>: the end token. Every sentence ends with the end token.</li>
<li><codeclass="code docutils literal"><spanclass="pre">beam_size</span></code>: the beam size used in beam search.</li>
<li><codeclass="code docutils literal"><spanclass="pre">max_length</span></code>: the maximum length of the generated sentences.</li>
</ul>
</li>
<li>use <codeclass="code docutils literal"><spanclass="pre">seqtext_printer_evaluator</span></code> to print text according to index matrix and dictionary. This function needs to set:<ul>
<li><codeclass="code docutils literal"><spanclass="pre">id_input</span></code>: the integer ID of the data, used to identify the corresponding output in the generated files.</li>
<li><codeclass="code docutils literal"><spanclass="pre">dict_file</span></code>: the dictionary file for converting word id to word.</li>
<li><codeclass="code docutils literal"><spanclass="pre">result_file</span></code>: the path of the generation result file.</li>
<trclass="field-even field"><thclass="field-name">Returns:</th><tdclass="field-body"><pclass="first">The seq_text_printer that prints the generated sequence to a file.</p>
<p>Please see the following demo for more details:</p>
...
...
@@ -1015,25 +1014,16 @@ algorithm. To maintain tractability, every iteration only
only stores a predetermined number, called the beam_size,
of the most promising next words. The greater the beam
size, the fewer candidate words are pruned.</li>
<li><strong>result_file</strong> (<em>basestring</em>) – Path of the file to store the generated results.</li>
<li><strong>dict_file</strong> (<em>basestring</em>) – Path of dictionary. This is an optional parameter.
Every line is a word in the dictionary with
(line number - 1) as the word index.
If this parameter is set to None, or to an empty string,
only word index are printed in the generated results.</li>
<li><strong>num_results_per_sample</strong> (<em>int</em>) – Number of the generated results per input
sequence. This number must always be less than
beam size.</li>
<li><strong>id_input</strong> (<em>LayerOutput</em>) – Index of the input sequence, and the specified index will
be prited in the gereated results. This an optional
parameter.</li>
</ul>
</td>
</tr>
<trclass="field-even field"><thclass="field-name">Returns:</th><tdclass="field-body"><pclass="first">The seq_text_printer that prints the generated sequence to a file.</p>
<trclass="field-even field"><thclass="field-name">Returns:</th><tdclass="field-body"><pclass="first">The generated word index.</p>