Class TreeOfThoughtsExecutor

java.lang.Object
com.tnsai.reasoning.TreeOfThoughtsExecutor

public final class TreeOfThoughtsExecutor extends Object
Tree of Thoughts (ToT) executor for complex problem solving.

ToT explores multiple reasoning paths by:

  1. Generating candidate thoughts at each step
  2. Evaluating thoughts for promise
  3. Pruning low-quality branches
  4. Continuing exploration on promising paths

Research Reference

Based on "Tree of Thoughts: Deliberate Problem Solving with Large Language Models" (Yao et al., 2023)

Usage


 TreeOfThoughtsExecutor tot = TreeOfThoughtsExecutor.builder()
     .llm(client)
     .evaluator(BranchEvaluator.llm(evalClient))
     .pruning(PruningStrategy.BEAM_SEARCH)
     .beamWidth(3)
     .maxDepth(5)
     .build();

 ToTResult result = tot.explore("Design a REST API for a todo app");
 System.out.println(result.getBestPath());
 
  • Method Details

    • builder

      public static TreeOfThoughtsExecutor.Builder builder()
      Creates a new builder for TreeOfThoughtsExecutor.
    • explore

      public ToTResult explore(String problem)
      Explores the problem space using Tree of Thoughts.
      Parameters:
      problem - The problem to solve
      Returns:
      The exploration result with best path