programlibs/Sample/demos/next.xtl

Choosing the next word from a model's scores over six words: the greedy choice, the probabilities at three temperatures, top-2, and twenty draws (r_oll!, seeded). Run with "just demo-lib Sample next".

source · imports sm: libs/Sample/src/Sample.xtl

s : Float

value · line 9

Scores for: cat dog fox bird the runs

s ← 2.0 1.6 0.4 0.2 -1.0 -2.0

ᵘr̲ound : Float -> Float

function · line 11
ᵘr̲ound ← { a → (f̲loat f̲loor 0.5 + 100.0 × a) ÷ 100.0 }

u : Float

value · line 19

Twenty draws at temperature 1 (the uniform numbers from r_oll!).

u ← (f̲loat r̲oll! 20 r̲eshape 1000) ÷ 1000.0