NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Improving Large Language Models Function Calling and Interpretability via Guided-Structured Templates

Hy Dang, Tianyi Liu, Zhuofeng Wu, Jingfeng Yang, Haoming Jiang, Tao Yang, Pei Chen, Zhengyang Wang, Helen Wang, Huasheng Li, Bing Yin, Meng JiangarXiv 2025 · DOI

TL;DR

Large Language Models (LLMs) often struggle with accurate function calling due to issues like incorrect parameterization or poor tool selection. This paper introduces a "guided-structured template" approach that uses explicit reasoning steps to significantly improve LLM function calling accuracy and interpretability, outperforming existing methods like Chain-of-Thought (CoT).

What Problem Does This Paper Address?

LLMs have become adept at reasoning and using tools, but they frequently falter when it comes to practical applications requiring precise function calls. This can manifest as:

  • Incorrect Parameterization: Providing the wrong values or types for function arguments.
  • Poor Tool Selection: Choosing an inappropriate tool for the task.
  • Misinterpretation of User Intent: Failing to understand what the user actually wants the tool to do.

These failures often stem from LLMs not fully grasping the user's goal or the intricacies of tool documentation. While Chain-of-Thought (CoT) prompting has been a step forward for general reasoning, the authors found it can be insufficient or even detrimental for structured tasks like function calling, where a rigid, step-by-step process is crucial. The core problem is enabling LLMs to reliably and transparently interact with external tools, which is critical for building trustworthy AI assistants.

Methods

The paper proposes a structured, template-based reasoning framework to improve LLM function calling. This framework has two main components:

  1. Prompting Strategies: They introduce "Template-Based Curricula Prompting," which embeds a structured reasoning template directly into the LLM's prompt. This template guides the LLM through specific steps:
  2. Identifying relevant functions.
  3. Deciding on the best function(s) for the query.
  4. Examining function documentation.
  5. Extracting and validating parameters.
  6. Converting parameter types if needed.
  7. Drafting the function call.
  8. Revalidating the final function call.
  9. Fine-Tuning Strategies: To internalize this structured reasoning, they construct a high-quality dataset called ToolGT (Guided-Template structured reasoning dataset). This dataset is created by:
  10. Using existing tool-use datasets (like ToolACE) and converting them into single-turn samples.
  11. Leveraging advanced LLMs (like GPT-4o-mini) guided by their structured template to generate reasoning chains.
  12. Using these reasoning chains to generate function calls.
  13. Rigorous filtering (using exact match, AST checks, and LLM-based verification) to ensure the quality of the generated data.
  14. Fine-tuning open-source LLMs on this ToolGT dataset.

Datasets

  • ToolACE: Used as an initial source for constructing the ToolGT dataset.
  • BFCLv2: A benchmark used for evaluating function calling performance. The authors excluded executable test cases due to rate limit issues.
  • Nexus: Another benchmark used for evaluating function calling performance.
  • ToolGT (newly introduced): A synthetic dataset specifically constructed by the authors to teach LLMs structured reasoning for function calling. It contains structured reasoning chains and corresponding function calls.

Key Insights and Ideas

  • Free-form CoT is Insufficient for Structured Tasks: The authors' analysis shows that while CoT helps general reasoning, it can be counterproductive for structured tasks like function calling, where a predefined, logical flow is essential.
  • Structured Templates are Key: Explicitly guiding LLMs through a step-by-step reasoning process using templates significantly improves their ability to make correct function calls.
  • Fine-tuning Internalizes Reasoning: While prompting helps, fine-tuning models on a dataset that explicitly encodes structured reasoning (like ToolGT) leads to more robust and consistent performance, especially for smaller models.
  • Template Complexity Matters: Different levels of template detail were tested, with more detailed templates generally yielding better results, suggesting that providing comprehensive guidance is beneficial.
  • Smaller Models Benefit Greatly from Training: Smaller LLMs, which often struggle with instruction following, show substantial improvements when fine-tuned with structured reasoning data, bridging the gap between their capabilities and the demands of complex tool use.

Key Results

  • Improved Accuracy: The proposed template-based prompting and fine-tuning methods achieved relative improvements of 3-12% over strong baselines across diverse model series and benchmarks (BFCLv2 and Nexus).
  • Outperforming Baselines: Template prompting consistently outperformed "No Thought" and "CoT Prompting" on both BFCLv2 and Nexus benchmarks for most models.
  • Fine-tuning Gains: Template-based fine-tuning (Template-Training) consistently yielded the highest performance across benchmarks for all evaluated open-source models, demonstrating the effectiveness of internalizing structured reasoning.
  • Robustness and Interpretability: The framework enhances the robustness, interpretability, and transparency of tool-using agents.

Limitations and Future Work

  • Dataset Coverage: The current study used a subset of ToolACE. Future work aims to augment this with more complex, nested function-calling scenarios to create a more rigorous training corpus.
  • Adaptive Templates: The study suggests that different templates might be advantageous for specific scenarios. Future research could explore models that adaptively select or adjust templates based on context.
  • Multi-Turn Scenarios: The current framework is primarily for single-turn function calling. Extending it to multi-turn scenarios is a key direction for future work.
  • Template Complexity Trade-off: While detailed templates performed well, there might be a trade-off between specificity and simplicity. Future work could investigate adaptive strategies that dynamically adjust reasoning depth based on task characteristics.
  • Nested/Compositional Reasoning: The paper notes performance degradation on complex, nested scenarios, suggesting a need for datasets specifically targeting such reasoning.

Summary updated

BibTeX
@misc{dang2025improving,
  author = {Hy Dang and Tianyi Liu and Zhuofeng Wu and Jingfeng Yang and Haoming Jiang and Tao Yang and Pei Chen and Zhengyang Wang and Helen Wang and Huasheng Li and Bing Yin and Meng Jiang},
  title = {{Improving Large Language Models Function Calling and Interpretability via Guided-Structured Templates}},
  year = {2025},
  eprint = {2509.18076},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2509.18076},
}
Figure