Beginner
Softmax with temperature
Write softmax_t(logits, t) that returns a list of probabilities: divide each logit by t, subtract the largest value for stability, apply exp, and divide by the total.
If t is 0, behave like greedy decoding: return a list with 1.0 at the position of the largest logit (the first one on a tie) and 0.0 elsewhere.
What Check tests
- Probabilities add up to 1
- [2, 1, 0] at T=1 gives 0.6652, 0.2447, 0.09
- A lower temperature makes the top token more likely
- Temperature 0 is greedy
- Large logits do not overflow
Stuck? One hint at a time
The solution unlocks after your first Check. Try first: that is where the learning happens.
main.py
Sign in to run your code.
Output
Press Run to see what your program prints.