Table of Contents
Fetching ...

ToolFlow: Boosting LLM Tool-Calling Through Natural and Coherent Dialogue Synthesis

Zezhong Wang, Xingshan Zeng, Weiwen Liu, Liangyou Li, Yasheng Wang, Lifeng Shang, Xin Jiang, Qun Liu, Kam-Fai Wong

TL;DR

ToolFlow tackles the mismatch between synthetic tool-calling data and real-world dialogue by introducing a graph-based sampling strategy to assemble coherent tool sets and a planned-generation strategy to craft multi-turn, coherent dialogues. The pipeline synthesizes 8,000 tool-calling dialogues via multi-agent interaction and uses GPT-4 for generation, followed by SFT on LLaMA-3.1-8B-Instruct, achieving tool-calling performance on par with GPT-4o and state-of-the-art results on dialogue benchmarks. The work also shows that data diversity and coherence positively influence model performance, and that the resulting model preserves broader capabilities. These findings suggest practical benefits for building robust, tool-aware LLMs without sacrificing general reasoning and conversational skills.

Abstract

Supervised fine-tuning (SFT) is a common method to enhance the tool calling capabilities of Large Language Models (LLMs), with the training data often being synthesized. The current data synthesis process generally involves sampling a set of tools, formulating a requirement based on these tools, and generating the call statements. However, tools sampled randomly lack relevance, making them difficult to combine and thus reducing the diversity of the data. Additionally, current work overlooks the coherence between turns of dialogues, leading to a gap between the synthesized data and real-world scenarios. To address these issues, we propose a Graph-based Sampling strategy to sample more relevant tool combinations, and a Planned-generation strategy to create plans that guide the synthesis of coherent dialogues. We integrate these two strategies and enable multiple agents to synthesize the dialogue data interactively, resulting in our tool-calling data synthesis pipeline ToolFlow. Data quality assessments demonstrate improvements in the naturalness and coherence of our synthesized dialogues. Finally, we apply SFT on LLaMA-3.1-8B using 8,000 synthetic dialogues generated with ToolFlow. Results show that the model achieves tool-calling performance comparable to or even surpassing GPT-4, while maintaining strong general capabilities.

ToolFlow: Boosting LLM Tool-Calling Through Natural and Coherent Dialogue Synthesis

TL;DR

ToolFlow tackles the mismatch between synthetic tool-calling data and real-world dialogue by introducing a graph-based sampling strategy to assemble coherent tool sets and a planned-generation strategy to craft multi-turn, coherent dialogues. The pipeline synthesizes 8,000 tool-calling dialogues via multi-agent interaction and uses GPT-4 for generation, followed by SFT on LLaMA-3.1-8B-Instruct, achieving tool-calling performance on par with GPT-4o and state-of-the-art results on dialogue benchmarks. The work also shows that data diversity and coherence positively influence model performance, and that the resulting model preserves broader capabilities. These findings suggest practical benefits for building robust, tool-aware LLMs without sacrificing general reasoning and conversational skills.

Abstract

Supervised fine-tuning (SFT) is a common method to enhance the tool calling capabilities of Large Language Models (LLMs), with the training data often being synthesized. The current data synthesis process generally involves sampling a set of tools, formulating a requirement based on these tools, and generating the call statements. However, tools sampled randomly lack relevance, making them difficult to combine and thus reducing the diversity of the data. Additionally, current work overlooks the coherence between turns of dialogues, leading to a gap between the synthesized data and real-world scenarios. To address these issues, we propose a Graph-based Sampling strategy to sample more relevant tool combinations, and a Planned-generation strategy to create plans that guide the synthesis of coherent dialogues. We integrate these two strategies and enable multiple agents to synthesize the dialogue data interactively, resulting in our tool-calling data synthesis pipeline ToolFlow. Data quality assessments demonstrate improvements in the naturalness and coherence of our synthesized dialogues. Finally, we apply SFT on LLaMA-3.1-8B using 8,000 synthetic dialogues generated with ToolFlow. Results show that the model achieves tool-calling performance comparable to or even surpassing GPT-4, while maintaining strong general capabilities.

Paper Structure

This paper contains 31 sections, 2 equations, 2 figures, 18 tables, 1 algorithm.

Figures (2)

  • Figure 1: The pipeline of dialogue synthesis. The left side shows the Tool Graph with blue boxes representing tools and purple boxes representing parameters or return values. In the middle is the dialogue synthesis plan generated according to sampled tools. On the right is an example of data synthesis by the User, Assistant, and Tool agents.
  • Figure 2: Example tool in JSON format.