Temperature Sampling with Exponential Noise

Easy · Solved in PyTorch · Machine learning coding practice

Problem

Stochastic token selection as used in nano-vLLM. Sampling from \mathrm{softmax}(\mathrm{logits}_i / T_i) is equivalent to perturbing every score by exponential noise and taking the largest, so supplying the noise draws makes the result deterministic.

For each row i, return the smallest index j that maximizes

Topics: inference, vllm, pytorch

The full statement, worked examples, hints and the test suite are available once you sign in. You can then solve Temperature Sampling with Exponential Noise in the browser and run it against the tests.

Related problems