이것은 큰 언어 모델로 정교한 문제를 해결하는 생각의 그래프의 공식적인 구현입니다.
이 프레임 워크를 사용하면 엔진으로 LLM (Lange Language Model)으로 자동으로 실행되는 GOO (Graph of Operation)로 모델링하여 복잡한 문제를 해결할 수 있습니다.
이 프레임 워크는 유연하고 확장 가능하도록 설계되었으므로 새로운 GOT 접근법을 사용하여 문제를 해결할뿐만 아니라 COT 또는 TOT와 같은 이전 접근 방식과 유사한 Goos를 구현할 수 있습니다.
이 프레임 워크를 사용하려면 Python 3.8 또는 최신의 작업을 설치해야합니다.
다음 두 설치 방법 중 하나를 실행하기 전에 파이썬 환경 (있는 경우)을 미리 활성화하십시오.
사용자이고 graph_of_thoughts 사용하려면 pypi에서 직접 설치할 수 있습니다.
pip install graph_of_thoughts개발자이고 코드를 수정하려면 소스에서 편집 가능한 모드로 코드를 설치할 수 있습니다.
git clone https://github.com/spcl/graph-of-thoughts.git
cd graph-of-thoughts
pip install -e .프레임 워크를 사용하려면 LLM에 액세스해야합니다. 선택한 LLM을 구성하려면 컨트롤러 readme의 지침을 따르십시오.
다음 코드 스 니펫은 프레임 워크를 사용하여 COT와 같은 접근 방식을 사용하여 32 개의 숫자 목록에 대한 분류 문제를 해결하는 방법을 보여줍니다.
코드를 실행하기 전에 설정 가이드를 따랐는지 확인하십시오.
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, 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 = language_models . 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" )보다 정교한 GOT 접근 방식을 실행하려면 다음 코드 스 니펫을 사용할 수 있습니다.
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, 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 = language_models . 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" ) 출력 그래프 output_cot.json 및 output_got.json 을 검사하여 두 결과를 비교할 수 있습니다.
최종 사고 상태의 점수는 정렬 된 목록의 오류 수를 나타냅니다.
이 논문은 프레임 워크와 그 구성 요소에 대한 높은 수준의 개요를 제공합니다.
프레임 워크를보다 자세하게 이해하려면 개별 모듈의 문서를 읽을 수 있습니다.
특히 컨트롤러 및 작업 모듈은 프레임 워크를 최대한 활용하는 방법을 이해하는 데 중요합니다.
우리는 코드를 완전히 문서화하기 위해 추가주의를 기울여서 코드가 어떻게 작동하는지 쉽게 이해할 수 있으며 확장 방법을 쉽게 이해할 수 있습니다.
예제 디렉토리에는 논문에 제시된 문제를 포함하여 프레임 워크를 사용하여 해결할 수있는 몇 가지 문제가 포함되어 있습니다.
프레임 워크를 사용하여 실제 문제를 해결하는 방법을 배우기위한 훌륭한 출발점입니다.
각 예제에는 README.md 파일이 포함되어 있으며 실행 방법에 대한 지침이 포함되어 있습니다. 코드는 완전히 문서화되어 있으며 따라갈 수 있어야합니다. 메인 디렉토리에서 바로 예제를 실행할 수도 있습니다. 결과는 각각의 예제 하위 디렉토리에 저장됩니다.
예를 들어 시도하십시오 :
python -m examples.sorting.sorting_032
python -m examples.keyword_counting.keyword_counting 예제 디렉토리의 지침을 따라 논문에서 실험을 실행할 수 있습니다.
그러나 결과를 검사하고 회복하려면 종이 디렉토리를 사용할 수 있습니다.
이 저장소가 가치있는 것을 찾으면 별을 줘!
질문이나 피드백이 있습니까? [email protected]에 자유롭게 연락하거나 문제를여십시오.
당신의 작품에서 이것을 사용하십니까? 제공된 인용을 사용하여 우리를 참조하십시오.
@article { besta2024got ,
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 = 2024 ,
month = { Mar } ,
journal = { Proceedings of the AAAI Conference on Artificial Intelligence } ,
volume = 38 ,
number = 16 ,
pages = { 17682-17690 } ,
publisher = { AAAI Press } ,
doi = { 10.1609/aaai.v38i16.29720 } ,
url = { https://ojs.aaai.org/index.php/AAAI/article/view/29720 }
}