onmt.Beam

Class for managing the internals of the beam search process.

hyp1---hyp1---hyp1 -hyp1
    \             /
hyp2 \-hyp2 /-hyp2--hyp2
           /      \
hyp3---hyp3---hyp3 -hyp3
========================

Takes care of beams, back pointers, and scores.

[src]

onmt.Beam(size, numFeatures)

Constructor

Parameters:

  • size : The beam K.
  • numFeatures : Number of features, (optional)

[src]

onmt.Beam:getCurrentState()

Get the outputs for the current timestep.

[src]

onmt.Beam:getCurrentOrigin()

Get the backpointers for the current timestep.

[src]

onmt.Beam:advance(wordLk, featsLk, attnOut)

Given prob over words for every last beam wordLk and attention attnOut. Compute and update the beam search.

Parameters:

  • wordLk- probs of advancing from the last step (K x words)
  • featsLk- probs of features at the last step (K x numfeatures x featsize)
  • attnOut- attention at the last step

Returns: true if beam search is complete.

[src]

onmt.Beam:getBest()

Get the score of the best in the beam.

[src]

onmt.Beam:getHyp(k)

Walk back to construct the full hypothesis.

Parameters:

  • k - the position in the beam to construct.

Returns:

  1. The hypothesis
  2. The attention at each time step.

Undocumented methods

* onmt.Beam:sortBest()