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:

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());