Official Repo for ToolGrad: Efficient Tool-use Dataset Generation with Textual “Gradients”
Project description
ToolGrad: Efficient Tool-use Dataset Generation with Textual "Gradients"
This is an official repo for <ToolGrad: Efficient Tool-use Dataset Generation with Textual “Gradients”>.
Get Started: A Quick Demo
Step 0: Install packages
conda env create -f environment.yml
conda activate toolgrad
Step 1: launch your first ToolGrad framework on a MCP service
export PYTHONPATH=./
python examples/mcp_filesystem.py
Reproduction of Dataset Generation
Step 0: ToolBench API Key
You need to first obtain a ToolBench API key by following their instruction:
Note: The API key is necessary for the following procedures.
Step 1: ToolBench Setups
export TOOLBENCH_KEY=YOURTOOLBENCHKEY
You also need to setup the ToolBench API database:
- Unzip
tools.zip(Google Drive) and it will show atools/folder. - add this path to the environ as follow
export TOOLBENCH_LIBRARY_ROOT=YOUR_PATH/TO/TOOLS
Step 2: Generate your first ToolGrad sample on the ToolBench API database
export PYTHONPATH=./
python examples/toolbench.py
You will then find a new json file under examples/outputs/. examples/example_outputs/seed=123__iter=5__num_apis=50.json is an example that we generated.
ToolGrad-5K is composed of 5k data generation sessions with different seed. It takes ~250 USD to generate the full 5K dataset, using gpt-4.1-mini.
Evaluation
First download the dataset from Google Drive and unzip it. You should be able see a folder structure as follows:
ToolGrad-5k
├── data
├── metadata
├── prediction
└── sft_data
The prediction folder stores the prediction of three ToolGrad models on the test set. You can run the following command to perform evaluation with LLM judges:
python src/eval.py --pred_model toolgrad-1b --dataset ~/YOUR_DATASET_STORAGE_DIR/ToolGrad-5k/
You should see the following messages in CMD.
judge model: gpt-4.1
100%|████████████████████████████████████████████████████████████████████████████| 500/500 [00:00<00:00, 1384.60it/s]
Recall Success Rate QoR
Model
toolgrad-1b 0.987917 0.955482 93.702
This is an exact reproduction of our results.
If you wish to run the LLM judge again, run the following command (note this introduces costs on your OpenAI API):
python src/eval.py --pred_model toolgrad-1b \
--dataset ~/YOUR_DATASET_STORAGE_DIR/ToolGrad-5k/ \
--overwrite \
--num_process 16
You should be able to see a new result with similar values of ours. Note that you can adjust the num_process dependent on your OpenAI API RPM.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file toolgrad-0.1.0.tar.gz.
File metadata
- Download URL: toolgrad-0.1.0.tar.gz
- Upload date:
- Size: 439.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e182730132e088ad606752e2c04f88abd09206de018f8f1886f8a86a2eba406d
|
|
| MD5 |
5eb378c88c2b64e081e9e712346a87a0
|
|
| BLAKE2b-256 |
326dd92d9dcda98e8b4c0cc10497c4c9a53d4b0716d8cf900bc879606e0a68af
|
File details
Details for the file toolgrad-0.1.0-py3-none-any.whl.
File metadata
- Download URL: toolgrad-0.1.0-py3-none-any.whl
- Upload date:
- Size: 451.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c8f660837c0b693228d4a231b61394fc0700c1c30f7913d4e270ebe5ec4e0a2e
|
|
| MD5 |
24d9c30fd6e582832dc0a1ca7769873a
|
|
| BLAKE2b-256 |
9bc99acdb6129966a559d130c52a6305db2c2386cee3b0c9cc47b9302f32d215
|