sample: add numerical stability to temperature/softmax transform (#9631)

This commit is contained in:
Parth Sareen
2025-03-10 14:43:53 -07:00
committed by GitHub
parent fe776293f7
commit 7e34f4fbfa
3 changed files with 28 additions and 42 deletions

View File

@@ -90,8 +90,9 @@ func (s *Sampler) sample(tokens []token) (token, error) {
sortLogits(tokens)
}
// token logit values are updated to probabilities
tokens = temperature(tokens, s.temperature)
tokens = softmax(tokens)
tokens = topP(tokens, s.topP)
tokens = minP(tokens, s.minP)