Graph of Thoughts (GoT): A Journey into Solving Complex Problems with AI
The Graph of Thoughts (GoT) project introduces a groundbreaking framework designed to tackle intricate problems by transforming them into a "Graph of Operations" (GoO). This approach harnesses the power of Large Language Models (LLMs) as the computational backbone, enabling users to solve complex tasks that traditional methods find challenging. What sets this framework apart is its flexibility and extensibility, allowing users not only to employ the new GoT methodologies but also to integrate traditional problem-solving techniques similar to Chain of Thought (CoT) or Tree of Thought (ToT) approaches.
Setup Guide
To embark on your journey with the GoT framework, ensure you have Python 3.8 or newer installed on your system.
Installing GoT
Depending on your role—user or developer—you have two installation paths:
-
For Users: Simply install the package from PyPI.
pip install graph_of_thoughts
-
For Developers: Clone the repository and install it in editable mode to modify the codebase.
git clone https://github.com/spcl/graph-of-thoughts.git cd graph-of-thoughts pip install -e .
Configuring the LLM
Access to a Large Language Model is essential for utilizing the GoT framework. Setup requires following instructions from the provided Controller README to configure your chosen LLM properly.
Quick Start: Example of Sorting Numbers
The GoT framework can be used to solve a variety of problems, even those we traditionally consider simple, like sorting a list of numbers. Below is a basic example using a CoT-like method:
from examples.sorting.sorting_032 import SortingPrompter, SortingParser, utils
from graph_of_thoughts import controller, language_models, operations
# Problem input
to_be_sorted = "[0, 2, 6, 3, 8, 7, 1, 1, 6, ...]
# Create the Graph of Operations
gop = operations.GraphOfOperations()
gop.append_operation(operations.Generate())
gop.append_operation(operations.Score(scoring_function=utils.num_errors))
gop.append_operation(operations.GroundTruth(utils.test_sorting))
# Configure the Language Model
lm = language_models.ChatGPT("config.json", model_name="chatgpt")
# Create the Controller
ctrl = controller.Controller(
lm,
gop,
SortingPrompter(),
SortingParser(),
{"original": to_be_sorted, "current": "", "method": "cot"}
)
# Run the Controller
ctrl.run()
ctrl.output_graph("output_cot.json")
For a more sophisticated version using the GoT approach, the following code snippet demonstrates advanced capabilities:
from examples.sorting.sorting_032 import SortingPrompter, SortingParser, got, utils
from graph_of_thoughts import controller, language_models, operations
# Problem input
to_be_sorted = "[0, 2, 6, 3, 8, 7, 1, 1, 6, ...]
# Retrieve the Graph of Operations
gop = got()
# Configure the Language Model
lm = language_models.ChatGPT("config.json", model_name="chatgpt")
# Create the Controller
ctrl = controller.Controller(
lm,
gop,
SortingPrompter(),
SortingParser(),
{"original": to_be_sorted, "current": "", "phase": 0, "method": "got"}
)
# Run the Controller
ctrl.run()
ctrl.output_graph("output_got.json")
You can inspect the results in the output files output_cot.json
and output_got.json
. These files illustrate the effectiveness of the CoT-like and GoT methods in reducing sorting errors.
Documentation and Learning Resources
To gain deeper insights into the framework, reviewing the detailed documentation is crucial. Begin by exploring the Controller and Operations modules. These resources provide foundational knowledge needed to fully utilize and expand the framework's capabilities.
Example Use Cases
In the examples directory, a range of problem-solving scenarios showcase the versatility of the GoT framework. These examples not only replicate cases presented in the research paper but serve as a hands-on tutorial, complete with detailed instructions and full code documentation.
Try running one of these examples:
python -m examples.sorting.sorting_032
python -m examples.keyword_counting.keyword_counting
Discovering More
Explore further by examining paper results through the paper directory or share feedback and queries via email to [email protected]. For academic referencing or if you derive value from this project, kindly use the provided citation to acknowledge the team's work.
With Graph of Thoughts, the boundaries of problem-solving expand, inviting users to innovate and explore the potential of AI-driven solutions.