Skip to contents

Temperature-scaled softmax truncated to the smallest set with cumulative mass >= p, then renormalised. kept is 0-BASED.

Usage

morie_kamath_nucleus_sampling(logits, p, T = 1)

Arguments

logits

Logits.

p

Nucleus mass in (0, 1].

T

Temperature.

Value

List with probabilities, kept, n_kept, kept_mass.

Examples

morie_kamath_nucleus_sampling(logits = c(1, 2, 3, 4, 5, 6, 7, 8), p = 0.5)
#> $probabilities
#> [1] 0 0 0 0 0 0 0 1
#> 
#> $kept
#> [1] 7
#> 
#> $n_kept
#> [1] 1
#> 
#> $kept_mass
#> [1] 0.6323327
#> 
#> $estimate
#> [1] 1
#> 
#> $p
#> [1] 0.5
#> 
#> $temperature
#> [1] 1
#> 
#> $n
#> [1] 8
#> 
#> $method
#> [1] "Nucleus (top-p) truncation"
#>