
Tree-of-thoughts beam search (Kamath Ch 4)
Source:R/kamath_llm2_native.R
morie_kamath_tree_of_thoughts.RdBeam search over model-scored thoughts; path scores accumulate.
Examples
morie_kamath_tree_of_thoughts("root", 2, 2, function(s, b) list(list(paste0(s,
"a"), 1), list(paste0(s, "b"), 2)), beam = 1)
#> $best_state
#> [1] "rootbb"
#>
#> $best_path
#> $best_path[[1]]
#> [1] "rootb"
#>
#> $best_path[[2]]
#> [1] "rootbb"
#>
#>
#> $best_score
#> [1] 4
#>
#> $frontier
#> $frontier[[1]]
#> $frontier[[1]][[1]]
#> [1] "rootbb"
#>
#> $frontier[[1]][[2]]
#> [1] 4
#>
#>
#>
#> $n_expanded
#> [1] 2
#>
#> $n_dead_ends
#> [1] 0
#>
#> $depth
#> [1] 2
#>
#> $beam
#> [1] 1
#>
#> $branch_factor
#> [1] 2
#>
#> $estimate
#> [1] 4
#>
#> $n
#> [1] 1
#>
#> $method
#> [1] "Tree-of-thoughts beam search over scored thoughts"
#>