
Beam search over a fixed per-step score table (Geron Ch 14, grbeam)
Source:R/geron_ml_native.R
morie_geron_beam_search_decoder.RdEvery step expands the whole vocabulary and keeps the top-k by cumulative log-probability. Prefix-independent scores make the beam exhaustive over the retained hypotheses. Tokens are 0-based.
Value
List with best_sequence, best_score, beams (list of
list(sequence, score)), normalised_scores, greedy_sequence.
Examples
morie_geron_beam_search_decoder(scores = c(1, 2, 3, 4, 5, 6, 7, 8), beam_width = 5L)
#> $best_sequence
#> [1] 0 0 0 0 0 0 0 0
#>
#> $best_score
#> [1] 36
#>
#> $beams
#> $beams[[1]]
#> $beams[[1]]$sequence
#> [1] 0 0 0 0 0 0 0 0
#>
#> $beams[[1]]$score
#> [1] 36
#>
#>
#>
#> $normalised_scores
#> [1] 36
#>
#> $greedy_sequence
#> [1] 0 0 0 0 0 0 0 0
#>
#> $beam_width
#> [1] 5
#>
#> $estimate
#> [1] 36
#>
#> $n
#> [1] 8
#>
#> $method
#> [1] "Beam search decoding"
#>