Skip to contents

Every 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.

Usage

morie_geron_beam_search_decoder(
  scores,
  beam_width,
  max_len = NULL,
  length_penalty = 0
)

Arguments

scores

Matrix (T, V) of log-scale scores.

beam_width

Hypotheses kept.

max_len

Steps, defaults to T.

length_penalty

GNMT exponent for the final ranking.

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"
#>