Package com.tnsai.reasoning
package com.tnsai.reasoning
Large Reasoning Model (LRM) patterns for advanced reasoning capabilities.
This package provides executors and utilities for advanced reasoning patterns that go beyond basic prompting, including:
SelfConsistencyExecutor- Multiple reasoning paths with majority votingTreeOfThoughtsExecutor- Branching exploration with evaluationReasoningVerifier- Post-hoc verification of reasoning chainsReasoningRouter- Route to reasoning-specialized modelsExtendedThinkingClient- Anthropic extended thinking mode
Research References
- Self-Consistency (Wang et al., 2022)
- Tree of Thoughts (Yao et al., 2023)
- ROMA Framework (Sentient AGI)
Usage
// Self-Consistency for math problems
SelfConsistencyExecutor sc = SelfConsistencyExecutor.builder()
.llm(client)
.numPaths(5)
.aggregation(Aggregation.MAJORITY_VOTE)
.build();
ConsistencyResult result = sc.reason("What is 17 * 23?");
if (result.isConfident(0.8)) {
System.out.println(result.getConsensusAnswer());
}
// Tree of Thoughts for complex planning
TreeOfThoughtsExecutor tot = TreeOfThoughtsExecutor.builder()
.llm(client)
.evaluator(new LLMBranchEvaluator(client))
.pruning(PruningStrategy.BEAM_SEARCH)
.beamWidth(3)
.maxDepth(5)
.build();
ToTResult result = tot.explore("Design a REST API for...");
System.out.println(result.getBestPath());
-
ClassDescriptionAggregation strategies for combining multiple reasoning paths.Evaluates branches in Tree of Thoughts exploration.Result of a self-consistency reasoning execution.Builder for ConsistencyResult.Contract for thought nodes that can be evaluated by a
BranchEvaluator.Extended thinking mode client for deep reasoning tasks.Builder for ExtendedThinkingClient.Utility for parsing structured content from LLM responses.Pruning strategies for Tree of Thoughts exploration.Represents a single reasoning path in self-consistency or tree-of-thoughts execution.Builder for ReasoningPath.Routes queries to reasoning-specialized models based on task complexity.Builder for ReasoningRouter.Verifies reasoning chains for logical consistency and factual accuracy.Self-Consistency reasoning executor.Builder for SelfConsistencyExecutor.Result from extended thinking mode execution.Builder for ThinkingResult.Represents a node in a Tree of Thoughts exploration.Builder for ThoughtNode.Rough token count estimator for text content.Result of a Tree of Thoughts exploration.Builder for ToTResult.Tree of Thoughts (ToT) executor for complex problem solving.Builder for TreeOfThoughtsExecutor.Result of reasoning verification.Builder for VerificationResult.