TreeOfThoughtsRetriever<T>

Models & Types · AiDotNet.RetrievalAugmentedGeneration.AdvancedPatterns

Tree-of-Thoughts retriever that explores multiple reasoning paths in a tree structure.

Inheritance: RetrieverBase<T> → TreeOfThoughtsRetriever<T>

For Beginners

Think of this like a chess player considering multiple moves.

Chain-of-Thought (linear):

  • Question: “Impact of AI on healthcare?”
  • Path: AI → Diagnosis → Treatment → Outcomes

Tree-of-Thoughts (branching):

  • Question: “Impact of AI on healthcare?”
  • Level 1: [AI in Diagnosis, AI in Treatment, AI in Research]
  • Level 2 (from Diagnosis): [Image Analysis, Patient Records, Early Detection]
  • Level 2 (from Treatment): [Drug Discovery, Personalized Medicine, Surgery Assistance]
  • Explores all promising paths and selects best documents

This is especially useful when:

  • Multiple valid reasoning approaches exist
  • The problem requires exploring alternatives
  • You want comprehensive coverage of a topic

How It Works

This advanced retrieval pattern builds upon Chain-of-Thought by creating a tree of possible reasoning paths. Instead of following a single linear chain, it explores multiple branches of reasoning at each step, evaluates them, and can backtrack to explore alternative paths. This enables more comprehensive exploration of complex problem spaces.

Example Usage:

Constructors

Constructor Summary
TreeOfThoughtsRetriever(IGenerator<T> generator, RetrieverBase<T> baseRetriever, int maxDepth, int branchingFactor, TreeSearchStrategy searchStrategy, int defaultTopK) Initializes a new instance of the TreeOfThoughtsRetriever class.