• Stars
    star
    2,059
  • Rank 22,313 (Top 0.5 %)
  • Language
    Python
  • License
    Other
  • Created about 1 year ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Official Implementation of "Graph of Thoughts: Solving Elaborate Problems with Large Language Models"

Graph of Thoughts (GoT)

This is the official implementation of Graph of Thoughts: Solving Elaborate Problems with Large Language Models.
This framework gives you the ability to solve complex problems by modeling them as a Graph of Operations (GoO), which is automatically executed with a Large Language Model (LLM) as the engine.
This framework is designed to be flexible and extensible, allowing you to not only solve problems using the new GoT approach, but also to implement GoOs resembling previous approaches like CoT or ToT.

Setup Guide

In order to use this framework, you need to have a working installation of Python 3.8 or newer.

Installing GoT

Before running either of the following two installation methods, make sure to activate your Python environment (if any) beforehand.
If you are a user and you just want to use graph_of_thoughts, you can install it directly from PyPI:

pip install graph_of_thoughts

If you are a developer and you want to modify the code, you can install it in editable mode from source:

git clone https://github.com/spcl/graph-of-thoughts.git
cd graph-of-thoughts
pip install -e .

Configuring the LLM

In order to use the framework, you need to have access to an LLM. Please follow the instructions in the Controller README to configure the LLM of your choice.

Quick Start

The following code snippet shows how to use the framework to solve the sorting problem for a list of 32 numbers using a CoT-like approach.
Make sure you have followed the Setup Guide before running the code.

from examples.sorting.sorting_032 import SortingPrompter, SortingParser, utils
from graph_of_thoughts import controller, operations

# Problem input

to_be_sorted = "[0, 2, 6, 3, 8, 7, 1, 1, 6, 7, 7, 7, 7, 9, 3, 0, 1, 7, 9, 1, 3, 5, 1, 3, 6, 4, 5, 4, 7, 3, 5, 7]"

# 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 (Assumes config.json is in the current directory with OpenAI API key)
lm = controller.ChatGPT("config.json", model_name="chatgpt")

# Create the Controller
ctrl = controller.Controller(
  lm, 
  gop, 
  SortingPrompter(), 
  SortingParser(),
  # The following dictionary is used to configure the initial thought state
  {
    "original": to_be_sorted,
    "current": "",
    "method": "cot"
  }
)

# Run the Controller and generate the output graph
ctrl.run()
ctrl.output_graph("output_cot.json")

To run the more sophisticated GoT approach, you can use the following code snippet.

from examples.sorting.sorting_032 import SortingPrompter, SortingParser, got, utils
from graph_of_thoughts import controller, operations

# Problem input

to_be_sorted = "[0, 2, 6, 3, 8, 7, 1, 1, 6, 7, 7, 7, 7, 9, 3, 0, 1, 7, 9, 1, 3, 5, 1, 3, 6, 4, 5, 4, 7, 3, 5, 7]"

# Retrieve the Graph of Operations
gop = got()

# Configure the Language Model (Assumes config.json is in the current directory with OpenAI API key)
lm = controller.ChatGPT("config.json", model_name="chatgpt")

# Create the Controller
ctrl = controller.Controller(
  lm, 
  gop, 
  SortingPrompter(), 
  SortingParser(),
  # The following dictionary is used to configure the initial thought state
  {
    "original": to_be_sorted,
    "current": "",
    "phase": 0,
    "method": "got"
  }
)

# Run the Controller and generate the output graph
ctrl.run()
ctrl.output_graph("output_got.json")

You can compare the two results by inspecting the output graphs output_cot.json and output_got.json.
The final thought states' scores indicate the number of errors in the sorted list.

Documentation

The paper gives a high-level overview of the framework and its components.
In order to understand the framework in more detail, you can read the documentation of the individual modules.
Especially the Controller and Operations modules are important for understanding how to make the most out of the framework.
We took extra care to fully document the code, so that you can easily understand how it works and how to extend it.

Examples

The examples directory contains several examples of problems that can be solved using the framework, including the ones presented in the paper.
It is a great starting point for learning how to use the framework to solve real problems.
Each example contains a README.md file with instructions on how to run it and play with it. The code is fully documented and should be easy to follow.

Paper Results

You can run the experiments from the paper by following the instructions in the examples directory.
However, if you just want to inspect and replot the results, you can use the paper directory.

Citations

If you find this repository valuable, please give it a star!
Got any questions or feedback? Feel free to reach out to [email protected] or open an issue.
Using this in your work? Please reference us using the provided citation:

@misc{besta2023got,
  title = {{Graph of Thoughts: Solving Elaborate Problems with Large Language Models}},
  author = {Besta, Maciej and Blach, Nils and Kubicek, Ales and Gerstenberger, Robert and Gianinazzi, Lukas and Gajda, Joanna and Lehmann, Tomasz and Podstawski, Micha{\l} and Niewiadomski, Hubert and Nyczyk, Piotr and Hoefler, Torsten},
  year = 2023,
  eprinttype = {arXiv},
  eprint = {2308.09687}
}

More Repositories

1

dace

DaCe - Data Centric Parallel Programming
Python
487
star
2

gemm_hls

Scalable systolic array-based matrix-matrix multiplication implemented in Vivado HLS for Xilinx FPGAs.
C++
297
star
3

QuaRot

Code for QuaRot, an end-to-end 4-bit inference of large language models.
Python
247
star
4

pymlir

Python interface for MLIR - the Multi-Level Intermediate Representation
Python
210
star
5

ncc

Neural Code Comprehension: A Learnable Representation of Code Semantics
Python
206
star
6

hls_tutorial_examples

Examples shown as part of the tutorial "Productive parallel programming on FPGA with high-level synthesis".
C++
188
star
7

MRAG

Official Implementation of "Multi-Head RAG: Solving Multi-Aspect Problems with LLMs"
Python
151
star
8

serverless-benchmarks

SeBS: serverless benchmarking suite for automatic performance analysis of FaaS platforms.
Python
142
star
9

substation

Research and development for optimizing transformers
Python
121
star
10

pspin

PsPIN: A RISC-V in-network accelerator for flexible high-performance low-power packet processing
SystemVerilog
95
star
11

deep-weather

Deep Learning for Post-Processing Ensemble Weather Forecasts
Jupyter Notebook
85
star
12

daceml

A Data-Centric Compiler for Machine Learning
Python
81
star
13

FBLAS

BLAS implementation for Intel FPGA
C++
75
star
14

open-earth-compiler

development repository for the open earth compiler
MLIR
74
star
15

npbench

NPBench - A Benchmarking Suite for High-Performance NumPy
Python
73
star
16

ucudnn

Accelerating DNN Convolutional Layers with Micro-batches
C++
64
star
17

rFaaS

rFaaS: a high-performance FaaS platform with RDMA acceleration for low-latency invocations.
C++
48
star
18

haystack

Haystack is an analytical cache model that given a program computes the number of cache misses.
C++
42
star
19

sparsity-in-deep-learning

Bibtex for Sparsity in Deep Learning paper (https://arxiv.org/abs/2102.00554) - open for pull requests
TeX
40
star
20

mlir-dace

Data-Centric MLIR dialect
C++
37
star
21

redmark

ReDMArk: Bypassing RDMA Security Mechanisms.
C++
37
star
22

apfp

FPGA acceleration of arbitrary precision floating point computations.
C++
34
star
23

NoPFS

Near-optimal Prefetching System
32
star
24

sten

Sparsity support for PyTorch
Python
31
star
25

rapidchiplet

A toolchain for rapid design space exploration of chiplet architectures
C++
27
star
26

ens10

Scripts and examples for the ENS-10 Ensemble Prediction System machine learning dataset
Python
25
star
27

gms

GraphMineSuite (GMS): a benchmarking suite for graph mining algorithms such as graph pattern matching or graph learning
C++
25
star
28

sage

Python
24
star
29

liblsb

Rebol
23
star
30

smoe

Spatial Mixture-of-Experts
Python
19
star
31

CoRM

CoRM: Compactable Remote Memory over RDMA
C++
19
star
32

dace-vscode

Rich editor for SDFGs with included profiling and debugging, static analysis, and interactive optimization.
TypeScript
18
star
33

kafkadirect

RDMA-enabled Apache Kafka
Java
17
star
34

faaskeeper

A fully serverless implementation of the ZooKeeper coordination protocol.
Python
17
star
35

fmi

Function Message Interface (FMI): library for message-passing and collective communication for serverless functions.
C++
15
star
36

SMI

Streaming Message Interface: High-Performance Distributed Memory Programming on Reconfigurable Hardware
C++
15
star
37

stencilflow

Python
15
star
38

naos

Naos: Serialization-free RDMA networking in Java
Java
15
star
39

absinthe

Absinthe is an optimization framework to fuse and tile stencil codes in one shot
Python
14
star
40

NNCompression

Compressing weather and climate data into neural networks
Python
13
star
41

DNN-cpp-proxies

C++/MPI proxies for distributed training of deep neural networks.
C++
13
star
42

arrow-matrix

Arrow Matrix Decomposition - Communication-Efficient Distributed Sparse Matrix Multiplication
Python
13
star
43

CheckEmbed

Official Implementation of "CheckEmbed: Effective Verification of LLM Solutions to Open-Ended Tasks"
Python
12
star
44

.github

10
star
45

LogGOPSim

A LogGOPS (LogP, LogGP, LogGPS) Simulator and Simulation Framework
C
10
star
46

vldb19-distributed-locking

This repository hosts the code used for the following paper: Claude Barthels, Ingo MΓΌller, Konstantin Taranov, Torsten Hoefler, Gustavo Alonso. "Strong consistency is not hard to get: Two-Phase Locking and Two-Phase Commit on Thousands of Cores." In: PVLDB, 2020.
C++
10
star
47

SimFS

SimFS: A Virtualizing Simulation Data File System Interface
C++
8
star
48

CLaMPI

Caching Layer for MPI
C
8
star
49

FBACode

Python
8
star
50

nbody_hls

Implementation of the N^2-formulation of N-body simulation with Vivado HLS for SDAccel platforms.
C++
8
star
51

GDI-RMA

Official Implementation of "The Graph Database Interface: Scaling Online Transactional and Analytical Graph Workloads to Hundreds of Thousands of Cores"
C
8
star
52

DiffDA

Python
7
star
53

stencil_hls

Implementation of time and space-tiled stencil in Vivado HLS.
C++
7
star
54

open-earth-benchmarks

Open repository for climate and weather benchmark kernels
C++
7
star
55

cppless

C++
6
star
56

polybench-comparator

Regression and comparison tools for the Polybench benchmark
Shell
6
star
57

nevermore

The source code for the Nevermore paper at ACM CCS'22
C++
6
star
58

foMPI-NA

C
6
star
59

perf-taint

Taint-based program analysis framework for empirical performance modeling.
LLVM
5
star
60

streamingsched

Streaming Task Scheduling
Python
5
star
61

faaskeeper-python

Python client library for FaaSKeeper, the serverless ZooKeeeper.
Python
5
star
62

muliticast-based-allgather

C
4
star
63

libNBC

Shell
3
star
64

climetlab-maelstrom-ens10

MAELSTROM ENS10 dataset plugin for CliMetLab
Jupyter Notebook
3
star
65

dace-webclient

Web-based SDFG viewer for DaCe
JavaScript
3
star
66

libhear

C++
3
star
67

TCPunch

C++
3
star
68

LGSxNS3

Python
2
star
69

cppless-clang

2
star
70

c2dace

C
2
star
71

probgraph

Emacs Lisp
2
star
72

LogGOPSim2

C++
2
star
73

fflib

C
2
star
74

serverless-benchmarks-data

TeX
2
star
75

rivets

C
2
star
76

spatial-collectives

Optimized communication collectives for the Cerebras waferscale engine
Python
2
star
77

conflux

C++
1
star
78

fuzzyflow-artifact

Computational artifacts for the FuzzyFlow publication
Shell
1
star
79

SAILOR

Python
1
star
80

praas-benchmarks

Jupyter Notebook
1
star
81

HTSIM-old

C++
1
star
82

faas-profiler

Python
1
star
83

UPM

User-guided Page Merging: Memory Deduplication for Serverless
C
1
star
84

f2dace-artifact

Fortran
1
star
85

smat

Code for High Performance Unstructured SpMM Computation Using Tensor Cores
Emacs Lisp
1
star