Skip to contents

Beam search over model-scored thoughts; path scores accumulate.

Usage

morie_kamath_tree_of_thoughts(
  problem,
  branch_factor,
  max_depth,
  model,
  beam = 1
)

Arguments

problem

Root state.

branch_factor

Children per node.

max_depth

Depth.

model

Function (state, b) -> list of list(thought, score).

beam

Beam width.

Value

List with best_state, best_path, best_score, frontier.

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