Implement temperature + top-kk + top-pp sampling from a logits vector in numpy

Inference & Serving1 / 5

Chapter 241 / 5

Inference & Serving

Implement temperature + top-kk + top-pp sampling from a logits vector in numpy

Easy
Target interface
sample(logits, temperature=1.0, top_k=0, top_p=1.0, rng=None)

Implement the function/class skeleton in the editor. Any correct approach is accepted.

Hints0 / 2
Reference solution
Your own code stays in the editor.