Back to Annotated Deep Learning Paper Implementations

Sampling Techniques for Language Models

docs/sampling/index.html

latest813 B
Original Source

homesampling

[View code on Github](https://github.com/labmlai/annotated_deep_learning_paper_implementations/tree/master/labml_nn/sampling/ init.py)

#

Sampling Techniques for Language Models

Here's an experiment that uses these sampling techniques.

18importtorch

#

Sampler base class

21classSampler:

#

Sample from logits

  • logits are the logits of the distribution of shape [..., n_tokens]
25def\_\_call\_\_(self,logits:torch.Tensor)-\>torch.Tensor:

#

31raiseNotImplementedError()

labml.ai