Code World Model: Building World Models for Computation – Jacob Kahn, FAIR Meta
Jacob Kahn from FAIR, Meta, introduces the Code World Model (CWM), a new paradigm for AI models that learn from program execution rather than just code syntax. By training on detailed execution traces, CWM builds an internal world model of computation, enabling it to predict a program's behavior. This talk explores CWM's architecture, its highly scalable and asynchronous reinforcement learning setup, and groundbreaking applications like a 'neural debugger' that understands user intent from code structure and the potential to approximate undecidable problems like the halting problem.
The Code World Model (CWM) aims to build models that can reason, plan, and make decisions, using code as a constrained sandbox for this exploration. The core idea is to move beyond modeling code as mere syntax—sequences of tokens in an editor—and instead model the dynamics of program execution. This approach seeks to predict future observations given past observations and actions, creating a world model specifically for computation.
Modeling Beyond Syntax: From Code to Execution
Traditional token-based models only see the static syntax of a program. CWM proposes a paradigm shift by learning from execution traces. This involves creating a structured, systematic representation of what happens when code runs, which a neural model can ingest and learn to predict.
- Execution Tracing: The model is trained on detailed execution traces that capture the program’s state at each step. These traces explicitly list local variables, memory states, and other runtime information, linking each line of the trace to a corresponding line in the source code. This concept scales from simple functions to entire repositories and even distributed systems.
- Transition Function: At its heart, CWM learns to predict a transition function (
State+Action→Next State), where an action is the execution of the next line of code. Large Language Models (LLMs) can autogressively generate these state transitions, effectively learning an internal simulator for the code.
The Agentic World Model Framework
Instead of a reactive loop where an agent must interact with a real environment to get feedback, a world model allows the agent to simulate actions in an