Back to Annotated Deep Learning Paper Implementations

Greedy Sampling

docs/sampling/greedy.html

latest691 B
Original Source

homesampling

View code on Github

#

Greedy Sampling

Here we sample the most likely token from the distribution of logits.

Here's an experiment that uses these sampling techniques.

14importtorch1516fromlabml\_nn.samplingimportSampler

#

19classGreedySampler(Sampler):

#

Sample the most likely token from the distribution of logits

20def\_\_call\_\_(self,logits:torch.Tensor):

#

24returnlogits.argmax(dim=-1)

labml.ai