Home

Awesome

Tool-Planner: Dynamic Solution Tree Planning for Large Language Model with Tool Clustering

<p align="center"> <img src='https://img.shields.io/badge/Code%20License-Apache_2.0-green.svg'></a> <img src="https://img.shields.io/badge/python-3.11-blue.svg" alt="Python Version 3.11"> <img src='https://img.shields.io/badge/Data%20License-CC%20By%20NC%204.0-red.svg'> <a href="https://github.com/OceannTwT/Tool-Planner/stargazers"><img src="https://img.shields.io/github/stars/OceannTwT/Tool-Planner" alt="GitHub Stars"></a> </p>

This is the official repository of the paper: Tool-Planner: Dynamic Solution Tree Planning for Large Language Model with Tool Clustering

Framework of Tool-Planner.

🎯Installation Enviorment

Update your environment for the required dependency.

conda create --name tool-planner python=3.11 -y
conda activate tool-planner
pip install -r requirement.txt

Collect ToolBench Util

Use the following link to download the Toolbench dataset. It will be used to extract the tool calling methods and descriptions from RapidAPI, and to complete the subsequent setup of the Toolkit.

Google Drive or Tsinghua Cloud

mv your_path/datas Tool-Planner

Download SimCSE

Downloading SimCSE model to your local directory.

mv your_path/sup-simcse-roberta-base Tool-Planner/model

Or Upload it from HuggingFace.

tokenizer = AutoTokenizer.from_pretrained("princeton-nlp/sup-simcse-roberta-base")
model = AutoModel.from_pretrained("princeton-nlp/sup-simcse-roberta-base")

Inference Tool-Planner

Use your ChatGPT API and Toolbench API, replace the API key in run.sh, and run the following script.

bash script/run.sh

To obtain the corresponding result information for your query, change the number of toolkits and adjust the file location of the input query.

export TOOLBENCH_KEY=""
export OPENAI_KEY=""
export PYTHONPATH=./

python main.py \
    --toolkit_dir src/toolkits \
    --tool_api_dir datas/toolenv/tools/ \
    --backbone_model gpt_3.5 \
    --toolkit_num 20 \
    --openai_key $OPENAI_KEY \
    --tool_env datas/toolenv/tools/ \
    --tool_output_file tool_lib/my_tool_library.json \
    --toolkit_output_file tool_lib/my_toolkit_library.json \
    --input_query_file data/instruction/G3_query.json \
    --output_answer_file data/instruction/tool_result.json \
    --simcse_file model_lib/sup-simcse-roberta-base \
    --toolbench_key $TOOLBENCH_KEY

In the tool_lib, we provide a example of the toolkit, corresponding to the generated toolkit contents, change your output tool and toolkit file on --toolkit_output_file and --tool_output_file.

Main Results

Main Result of Tool-Planner

Evaluations

Time and Performance Evaluation

🛠️Update logs

[24/06/09] 🔥 We have released the version 1.0.0 for Tool-Planner.

🔗Citation

If you use this codebase or Tool-Planner inspires your work, we would greatly appreciate it if you could star the repository and cite it using the following BibTeX entry:


@article{liu2024tool,
  title={Tool-Planner: Dynamic Solution Tree Planning for Large Language Model with Tool Clustering},
  author={Liu, Yanming and Peng, Xinyue and Zhang, Yuwei and Cao, Jiannan and Zhang, Xuhong and Cheng, Sheng and Wang, Xun and Yin, Jianwei and Du, Tianyu},
  journal={arXiv preprint arXiv:2406.03807},
  year={2024}
}

Acknowledgement

We thank the ZJU TRAIL Lab assistance for extending Tool-Planner!