Don't Fine-Tune, Decode: Syntax Error-Free Tool Use via Constrained Decoding

Kexun Zhang, Hongqiao Chen, Lei Li, William Wang
10/10/2023
cs.CLcs.AI

No official code found. Best implementation: chenhongqiao/ToolDec (31 stars, MIT, last commit 2024-01-28).

Abstract

Instruction-tuned large language models (LLMs) excel at many tasks but often fail to use external tools due to complicated and unfamiliar syntax constraints. While extensive fine-tuning and prompting can mitigate the issue, these approaches are expensive and hard to generalize. Furthermore, because syntax constraints are only learned implicitly during fine-tuning, models still make frequent syntax errors. Motivated by the fact that these constraints can be better satisfied explicitly with constrained decoding, we propose TOOLDEC, a decoding algorithm using finite state machines to force LLMs to follow tool syntax. Our experiments show that TOOLDEC eliminates all syntax errors, achieving significantly better performance on various base models and benchmarks. More surprisingly, when applied to generalist out-of-the-box LLMs such as Mistral-Instruct, TOOLDEC improves its accuracy in tool use from the initial 0% to an impressive 52%, matching the performance of specialized fine-tuned models such as ToolLLM.

View on arXivView PDF

Code Implementations(1)

MIT

Syntax Error-Free and Generalizable Tool Use for LLMs via Finite-State Decoding

312Shell, PythonOct 10, 20232 years agoMIT

Similar Papers

Cite this paper

@article{zhang2023dont,
  title  = {Don't Fine-Tune, Decode: Syntax Error-Free Tool Use via Constrained Decoding},
  author = {Kexun Zhang and Hongqiao Chen and Lei Li and William Wang},
  year   = {2023},
  eprint = {2310.07075},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2310.07075v3}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2310.07075.svg)](https://codeofpaper.com/paper/2310.07075)

Discussion