Commit 4d3401b0 authored by Qing Sun's avatar Qing Sun Committed by Facebook Github Bot
Browse files

Enable sampling (#571)

Summary:
Pull Request resolved: https://github.com/pytorch/fairseq/pull/571

Enable sampling from Fairseq

Reviewed By: akinh

Differential Revision: D13981666

fbshipit-source-id: 2af1bd67701a73a2c76a9255bd8381d6a7518876
parent 860010e9
......@@ -183,7 +183,7 @@ class Sampling(Search):
lprobs = lprobs[:, ::beam_size, :].contiguous()
# we exclude the first two vocab items, one of which is pad
assert self.pad == 1, 'sampling assumes the first two symbols can be ignored'
assert self.pad <= 1, 'sampling assumes the first two symbols can be ignored'
lprobs_nopad = lprobs[:, :, 2:]
# only sample from top-k candidates
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment