RandomSampler

class opennmt.utils.RandomSampler(from_top_k=None, temperature=None)[source]

Randomly samples from model outputs.

Inherits from: opennmt.utils.Sampler

__init__(from_top_k=None, temperature=None)[source]

Initializes the random sampler.

Parameters
  • from_top_k – Sample from the top K predictions instead of the full distribution.

  • temperature – Divide logits by this value. High temperatures generate more random samples.