Class: Informers::Utils::GreedySampler
- Defined in:
- lib/informers/utils/generation.rb
Instance Method Summary collapse
Methods inherited from Sampler
#call, #get_logits, get_sampler, #initialize
Constructor Details
This class inherits a constructor from Informers::Utils::Sampler
Instance Method Details
#sample(logits, index = -1)) ⇒ Object
120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/informers/utils/generation.rb', line 120 def sample(logits, index = -1) # NOTE: no need to do log_softmax here since we only take the maximum logs = get_logits(logits, index) argmax = Utils.max(logs)[1] # Note: score is meaningless in this context, since we are performing # greedy search (p = 1 => log(p) = 0) [ [argmax, 0] ] end |