Package com.tnsai.reasoning
Class TreeOfThoughtsExecutor
java.lang.Object
com.tnsai.reasoning.TreeOfThoughtsExecutor
Tree of Thoughts (ToT) executor for complex problem solving.
ToT explores multiple reasoning paths by:
- Generating candidate thoughts at each step
- Evaluating thoughts for promise
- Pruning low-quality branches
- 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());
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classBuilder for TreeOfThoughtsExecutor. -
Method Summary
Modifier and TypeMethodDescriptionbuilder()Creates a new builder for TreeOfThoughtsExecutor.Explores the problem space using Tree of Thoughts.
-
Method Details
-
builder
Creates a new builder for TreeOfThoughtsExecutor. -
explore
Explores the problem space using Tree of Thoughts.- Parameters:
problem- The problem to solve- Returns:
- The exploration result with best path
-