Code for our paper TInR: Exploring Tool-Internalized Reasoning in Large Language Models.
Install dependencies:
cd TInR
pip install -r requirements.txt
If you only need the basic training pipeline (without web / retrieval tools), most experiments will work with the core dependencies section of requirements.txt.
Tool definitions (names, descriptions, parameters, and virtual tokens) are stored in:
dataset/tools.jsonThis file is used both for:
training/test.py and verl/interactions).This repository assumes preprocessed datasets in the following locations:
dataset/token_call_token/ – raw JSON / parquet data for token-level tool calls.training/dataset/token_call_token/ – processed JSONs for model training (e.g. train_memorization_use.json, train_memorization_recall_use.json, train_think.json).If you need to regenerate processed datasets from tools.json and external raw data, you can write your own preprocessing script following the format of files in training/dataset/token_call_token/.
Usage:
cd TInR
bash scripts/train_memorization_recall_use.sh
This script:
training/dataset/token_call_token/train_memorization_use.json (and related data) to:
Key hyperparameters and paths can be edited directly in scripts/train_memorization_recall_use.sh.
Script:
scripts/train_think.shUsage:
cd TInR
bash scripts/train_think.sh
This script:
checkpoints/qwen-2.5-7b-memorization-recall-token-call-token-5e-5training/dataset/token_call_token/train_think.json<think>...</think> reasoning traces before tool calls.You can change:
model_name_or_path – to point to your own Stage-1 checkpoint.datasets – to another think-style dataset in the same format.Usage:
cd TInR
bash scripts/train_grpo.sh
This script:
examples/sglang_multiturn/run_rlla_multiturn_w_interaction.shDATA_DIR="dataset/token_call_token"EXPERIMENT_NAME under saves/BASE_MODELTo adapt to your environment:
BASE_MODEL to a Stage-2 checkpoint saved under checkpoints/.DATA_DIR to your own tool-use dataset directory under dataset/.CUDA_VISIBLE_DEVICES, N_GPUS, and batch-size parameters as needed.Usage:
cd TInR
bash scripts/test.sh
You can override default paths with environment variables:
MODEL_PATH=checkpoints/your_model \
EVAL_FILE=dataset/token_call_token/eval.json \
VIRTUAL_TOKENS_FILE=training/src/configs/virtual_tokens.txt \
TOOL_FILE=dataset/tools.json \
bash scripts/test.sh
3 commits
Python
99.8%
Code for our paper TInR: Exploring Tool-Internalized Reasoning in Large Language Models.
Install dependencies:
cd TInR
pip install -r requirements.txt
If you only need the basic training pipeline (without web / retrieval tools), most experiments will work with the core dependencies section of requirements.txt.
Tool definitions (names, descriptions, parameters, and virtual tokens) are stored in:
dataset/tools.jsonThis file is used both for:
training/test.py and verl/interactions).This repository assumes preprocessed datasets in the following locations:
dataset/token_call_token/ – raw JSON / parquet data for token-level tool calls.training/dataset/token_call_token/ – processed JSONs for model training (e.g. train_memorization_use.json, train_memorization_recall_use.json, train_think.json).If you need to regenerate processed datasets from tools.json and external raw data, you can write your own preprocessing script following the format of files in training/dataset/token_call_token/.
Usage:
cd TInR
bash scripts/train_memorization_recall_use.sh
This script:
training/dataset/token_call_token/train_memorization_use.json (and related data) to:
Key hyperparameters and paths can be edited directly in scripts/train_memorization_recall_use.sh.
Script:
scripts/train_think.shUsage:
cd TInR
bash scripts/train_think.sh
This script:
checkpoints/qwen-2.5-7b-memorization-recall-token-call-token-5e-5training/dataset/token_call_token/train_think.json<think>...</think> reasoning traces before tool calls.You can change:
model_name_or_path – to point to your own Stage-1 checkpoint.datasets – to another think-style dataset in the same format.Usage:
cd TInR
bash scripts/train_grpo.sh
This script:
examples/sglang_multiturn/run_rlla_multiturn_w_interaction.shDATA_DIR="dataset/token_call_token"EXPERIMENT_NAME under saves/BASE_MODELTo adapt to your environment:
BASE_MODEL to a Stage-2 checkpoint saved under checkpoints/.DATA_DIR to your own tool-use dataset directory under dataset/.CUDA_VISIBLE_DEVICES, N_GPUS, and batch-size parameters as needed.Usage:
cd TInR
bash scripts/test.sh
You can override default paths with environment variables:
MODEL_PATH=checkpoints/your_model \
EVAL_FILE=dataset/token_call_token/eval.json \
VIRTUAL_TOKENS_FILE=training/src/configs/virtual_tokens.txt \
TOOL_FILE=dataset/tools.json \
bash scripts/test.sh
3 commits
Python
99.8%