Can Language Models Serve as Text-Based World Simulators? (2024)

Abstract: Virtual environments play a key role in benchmarking advances in complex planning and decision-making tasks but are expensive and complicated to build by hand. Can current language models themselves serve as world simulators, correctly predicting how actions change different world states, thus bypassing the need for extensive manual coding? Our goal is to answer this question in the context of text-based simulators. Our approach is to build and use a new benchmark, called ByteSized32-State-Prediction, containing a dataset of text game state transitions and accompanying game tasks. We use this to directly quantify, for the first time, how well LLMs can serve as text-based world simulators. We test GPT-4 on this dataset and find that, despite its impressive performance, it is still an unreliable world simulator without further innovations. This work thus contributes both new insights into current LLM’s capabilities and weaknesses, as well as a novel benchmark to track future progress as new models appear.

## introduction and related work simulating the world is crucial for studying and understanding it. in many cases, however, the breadth and depth of available simulations are limited by the fact that their implementation requires extensive work from a team of human experts over weeks or months. recent advances in large language models (llms) have pointed towards an alternate approach by leveraging the huge amount of knowledge contained in their pre-training datasets. but are they ready to be used directly as simulators? we examine this question in the domain of textbased games, which naturally express the environment and its dynamics in natural language and have long been used as part of advances in decision making processes @xcite @xcite @xcite @xcite [{ "name": "sink", "properties": {"ison": true, ...}, "contains": ["cup"] },{ "name": "cup", "properties": {"iscontainer": true, ...}, "contains": ["water"] },{ "name": "water", "properties": {…}, "contains": [] },{ "name": "stove", "properties": {"iscontainer": true, ...}, "contains": [] }, … ] ## methodology we examine the abilities of llms to serve as world simulators in text-based virtual environments, in which an agent receives observations and proposes actions in natural language in order to complete certain objectives. each text environment can be formally represented as a goalconditioned partially observable markov decision process (pomdp) @xcite with the 7-tuple (s, a, t , o, r, c, d), where s denotes the state space, a denotes the action space, t : s × @xmath0, o denotes the observation function, r : s × @xmath1, c denotes a natural language "context message" that describes the goal and action semantics, and d : s × @xmath2, 1} denotes the binary completion indicator function. ## results predicting static transitions is easier than dynamic transitions: unsurprisingly, modeling a static transition is substantially easier than a dynamic transition across most conditions. while the llm needs to determine whether a given initial state and action will result in a state change in either case, dynamic transitions also require simulating the dynamics in exactly the same way as the underlying game engine by leveraging the information in the context message. predicting full game states is easier for dynamic states, whereas predicting state difference is easier for static states: predicting the state difference for dynamic state significantly improves the performance (>10%) of simulating static transitions, while decreases the performance when simulating dynamic transitions. this may be because state difference prediction is aimed at reducing potential format errors. however, gpt-4 is able to get the response format correct in most cases, while introducing the state difference increases the complexity of the output format of the task. game rules matter, and llms are able to generate good enough game rules: performance of gpt-4 on all three simulation tasks drops in most conditions when game rules are not provided in the context message. however, we fail to find obvious performance differences between game rules generated by human experts and by llms themselves. gpt-4 can predict game progress in most cases: humans outperform gpt-4 on the llm-sim task: we provide a preliminary human study on the llm-sim task. in particular, we take the 5 games from the bytesized32-sp dataset in which gpt-4 produced the worst accuracy at modeling f act . for each game, we randomly sample 20 games with the aim of having 10 transitions where gpt-4 succeeded and 10 transitions where gpt-4 failed (note that this is not always possible because on some games gpt-4 fails/succeeds on most transitions). in addition, we balance each set of 10 transitions to have 5 dynamic transitions and 5 static transitions. we instruct four human annotators (4 authors of this paper) to model as f act using the humangenerated rules as context in a full game state prediction setting. results are reported in gpt-4 is more likely to make an error when arithmetic, common-sense, or scientific knowledge is needed: because most errors occur in modeling dynamic transitions, we conduct an additional analysis to better understand failure modes. we use the setting with the best performance on dynamic transitions (gpt-4, human-written context, full state prediction) and further break down the results according to the specific object properties that are changed during the transition. figure 2 shows, for the whole state transitions, action-driven transitions, and environment-driven transitions, the proportion of predictions that are either correct, set the property to an incorrect value, or fail to change the property value (empty columns means the property is not changed in its corresponding condition). we observe that gpt-4 is able to handle most simple boolean value properties well. the errors are concentrated on non-trivial properties that requires arithmetic (e.g., temperature, timeabovemaxtemp), common-sense (e.g., current_aperture, current_focus), or scientific knowledge (e.g., on). we also observe that when predicting the action-driven and environment-driven transitions in a single step, gpt-4 tends to focus more on action-driven transitions, resulting in more unaltered value errors on states that it can predict correctly when solely simulating environment-driven transitions. ## conclusion we propose bytesized32-state-prediction, a benchmark of 76,369 virtual text environment state transitions for testing llms as simulators. we evaluate gpt-4 on this world modeling task. across models and conditions, the best recorded performance is 59.9% on accurately simulating state transitions that involve non-trivial changes. because simulation errors accumulate across steps, a simulator with modest single-step accuracy has limited utility in practice -for example, after 10 steps, average simulation accuracy would reduce to 0.599 10 , or less than 1%. our results indicate that llms are not yet able to reliably act as text world simulators. further error analysis shows that while llms are better at simulating the results of user actions, it is difficult for llms to handle environment-driven transitions and transitions that require arithmetic, common sense, or scientific knowledge.