To collaborate safely and effectively with humans, artificial intelligence systems require a "Theory of Mind"—the ability to infer what someone else is thinking or planning to do next. Researchers have recently introduced ROTE (Representing Others’ Trajectories as Executables), a novel system that predicts human and AI behavior by treating it as computer code. By utilizing Large Language Models (LLMs) to synthesize behavioral scripts and Bayesian inference to refine them, ROTE achieves up to 50% better accuracy than traditional methods and matches human-level performance in predicting complex actions.
The Challenge of Modeling Human Behavior
Traditionally, researchers have relied on two primary approaches to model and predict agent behavior, both of which have significant limitations:
- Behavior Cloning (BC): This involves training neural networks to mimic observed actions. While efficient to run, it is incredibly data-hungry and often fails to generalize when placed in new environments.
- Inverse Planning: This approach assumes humans are perfectly rational agents and attempts to calculate their underlying goals based on their actions. While highly generalizable and interpretable, it is computationally expensive and often "over-thinks" simple, routine behaviors.
The authors argue that humans do not always act based on deep, complex desires calculated on the fly. Often, we follow "scripts"—socially learned, efficient routines like "wait for the green light, then walk." Current AI models struggle to capture these routine-based behaviors efficiently without either overfitting (like BC) or becoming too slow for real-time use (like Inverse Planning).
ROTE: Framing Action Understanding as Program Synthesis
To address these shortcomings, the authors introduce ROTE, which frames action understanding as a program synthesis problem. The system operates in two main stages:
- Program Synthesis: When the AI observes an agent, it prompts an LLM to generate several candidate Python programs (often structured as Finite State Machines) that could logically explain the observed behavior.
- Bayesian Refinement: ROTE then uses Sequential Monte Carlo—a probabilistic inference technique—to weight these candidate programs. As more actions are observed, the system "up-votes" the programs that accurately predicted those actions and "down-votes" the ones that failed.
By representing behavior as executable code, the AI can predict future actions simply by running the inferred program. This bypasses the need for heavy, continuous computations or generating new text for every single step.
Experimental Validation
The researchers evaluated ROTE across three distinct settings to test its robustness:
- Construction: A 2D gridworld where agents perform tasks like patrolling or moving colored blocks. The team used 10 handcrafted "scripted" agents to generate 50,000 state-action pairs.
- Partnr: A high-fidelity embodied robotics simulator (based on Habitat) where agents perform household chores, such as cleaning the kitchen, in realistic home environments.
- Human Gameplay Data: To test how well ROTE predicts real, messy human behavior, the authors recruited human participants to play the Construction game and analyzed their trajectories.
Key Insights and Results
The "Mind-as-Code" paradigm proved to be a powerful middle ground. Code is more flexible than rigid logic, yet far more interpretable and efficient than black-box neural networks.
- Superior Accuracy and Generalization: ROTE outperformed competitive baselines—including Behavior Cloning and specialized Theory of Mind models like AutoToM—by as much as 50% in out-of-sample generalization. Programs inferred in one environment could be moved to a completely different map and still predict the agent's behavior accurately without any retraining (zero-shot generalization).
- Human-Level Performance: In the human study, ROTE’s predictions were statistically indistinguishable from the predictions made by other humans watching the same gameplay.
- Execution vs. Generation Efficiency: Once ROTE infers a program, it can predict 100 steps into the future in milliseconds simply by executing the code. In contrast, standard LLM-based predictors must generate text for every step, scaling linearly and becoming prohibitively expensive for long-horizon predictions.
- Occam’s Razor: The authors found that shorter, simpler programs (lower Kolmogorov complexity) generally generalized better to new environments, aligning with classic theories of inductive inference.
Limitations and Future Directions
While ROTE represents a major step forward, the authors acknowledge several hurdles for real-world deployment. Currently, ROTE relies on text-based observations (like scene graphs). To operate in the physical world, it would need integration with Vision-Language Models (VLMs) to translate raw video into the descriptions the LLM needs to write code.
Furthermore, human behavior is often noisy and stochastic. Moving from standard Python to Probabilistic Programming Languages (PPLs) could help the model represent uncertainty directly within the code. Finally, for highly creative or non-routine tasks, a simple script might be too rigid. Future iterations of ROTE may need to dynamically switch between a fast "script-mode" and a deeper "planning-mode" depending on the complexity of the observed behavior.
Summary updated