Papers › LLMs in the Imaginarium: Tool Learning through Simulated Trial and Error

LLMs in the Imaginarium: Tool Learning through Simulated Trial and Error

7 Mar 2024arXiv:2403.04746archive 2025-07-28

Boshi Wang, Hao Fang, Jason Eisner, Benjamin Van Durme, Yu Su

Tools are essential for large language models (LLMs) to acquire up-to-date information and take consequential actions in external environments. Existing work on tool-augmented LLMs primarily focuses on the broad coverage of tools and the flexibility of adding new tools. However, a critical aspect that has surprisingly been understudied is simply how accurately an LLM uses tools for which it has been trained. We find that existing LLMs, including GPT-4 and open-source LLMs specifically fine-tuned for tool use, only reach a correctness rate in the range of 30% to 60%, far from reliable use in practice. We propose a biologically inspired method for tool-augmented LLMs, simulated trial and error (STE), that orchestrates three key mechanisms for successful tool use behaviors in the biological system: trial and error, imagination, and memory. Specifically, STE leverages an LLM's 'imagination' to simulate plausible scenarios for using a tool, after which the LLM interacts with the tool to learn from its execution feedback. Both short-term and long-term memory are employed to improve the depth and breadth of the exploration, respectively. Comprehensive experiments on ToolBench show that STE substantially improves tool learning for LLMs under both in-context learning and fine-tuning settings, bringing a boost of 46.7% to Mistral-Instruct-7B and enabling it to outperform GPT-4. We also show effective continual learning of tools via a simple experience replay strategy.

PaperPDFCodeCode Syntology ran

In Syntology Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

For agents, Syntology's MCP tool lists every function and class Syntology harvested from this paper and whether it ran (how to connect): get_harvested_code_for_paper(arxiv_id="2403.04746")

Code

Syntology Ran 6 of 13 code samples harvested from 1 repository linked to this paper; 7 have no recorded run. Of those that ran: 6 ran with no contract checked.

By repository: official repository: 13 samples from 1 repository, 6 ran. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

microsoft/simulated-trial-and-error officialmentioned in papermentioned on GitHubpytorchMIT report

Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.

Code Syntology ran Syntology

13 samples harvested; 6 ran; 0 honoured the contract we drafted; 7 have no recorded run. Read from Syntology's graph 2026-09-24; that is when this build read the record, not when the samples ran.

6ran
7unverified

Licence: 0 of the 13 samples are pointer only, meaning Syntology does not serve that copy's text. This page shows no code text for any sample; each one links to its file in the repository.

Harvested from microsoft/simulated-trial-and-error. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself; “our draft was wrong” and “fixture could not drive it” are failures of Syntology's instrument, not of the code.

Each sample ends with its code_sha256, Syntology's identity for that exact code. An agent fetches the stored sample with Syntology's MCP tool get_code(code_sha256="…") (how to connect); click an identity to copy that call.

Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted. community: Not in the archive's code links for this paper; a community repository Syntology harvested. Samples from a repository marked official are listed first. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of four reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; or the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar). Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.

find_reverse microsoft/simulated-trial-and-error/STE/utils.py official repository ran fingerprinted MIT (permissive) · d905a14ca2a7fd88 · report
format_tokens_split microsoft/simulated-trial-and-error/llama-recipes/ft_datasets/tool_dataset.py official repository ran MIT (permissive) · 42840b65b58c1a33 · report
load_model microsoft/simulated-trial-and-error/llama-recipes/inference/model_utils.py official repository ran MIT (permissive) · 86440eb9f495e01b · report
load_peft_model microsoft/simulated-trial-and-error/llama-recipes/inference/model_utils.py official repository ran MIT (permissive) · 6d5ba8546b6aad2c · report
random_choose microsoft/simulated-trial-and-error/STE/utils.py official repository ran fingerprinted MIT (permissive) · 35aa73ace7771e74 · report
strip_end microsoft/simulated-trial-and-error/STE/utils.py official repository ran fingerprinted MIT (permissive) · ddfcf16bfe34d155 · report
chat_my microsoft/simulated-trial-and-error/STE/my_llm.py official repository unverified MIT (permissive) · 8e1faaeb38a03d1c · report
format_tokens microsoft/simulated-trial-and-error/llama-recipes/ft_datasets/tool_dataset.py official repository unverified MIT (permissive) · 0a6c3afab42d36ec · report
format_tokens_single microsoft/simulated-trial-and-error/llama-recipes/ft_datasets/tool_dataset.py official repository unverified MIT (permissive) · 9c0d0d1ea3a973f6 · report
get_chat_completion_my microsoft/simulated-trial-and-error/STE/my_llm.py official repository unverified MIT (permissive) · 8808b039130caf65 · report
load_llama_from_config microsoft/simulated-trial-and-error/llama-recipes/inference/model_utils.py official repository unverified MIT (permissive) · 994fab6bf2f22a99 · report
prepare_tool_data microsoft/simulated-trial-and-error/llama-recipes/data_proc_format.py official repository unverified MIT (permissive) · 92809d0bd14c1523 · report
unwrap_model microsoft/simulated-trial-and-error/llama-recipes/model_checkpointing/checkpoint_handler.py official repository unverified MIT (permissive) · b530360e413bc3fd · report

Tasks

Continual LearningIn-Context Learning

Results from the paper archive 2025-07-28

No leaderboard rows for this paper in the archive.

Methods

Absolute Position EncodingsAdamAttentionBPEDense ConnectionsDropoutExperience ReplayGPT-4Label SmoothingLayer NormalizationLinear LayerMulti-Head AttentionPosition-Wise Feed-Forward LayerResidual ConnectionSoftmaxTransformer

Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections