Modeling Worlds in Text

Prithviraj Ammanabrolu, Mark O. Riedl

Abstract

We provide a dataset that enables the creation of learning agents that can build knowledge graph-based world models of interactive narratives. Interactive narratives -- or text-adventure games -- are partially observable environments structured as long puzzles or quests in which an agent perceives and interacts with the world purely through textual natural language. Each individual game typically contains hundreds of locations, characters, and objects -- each with their own unique descriptions -- providing an opportunity to study the problem of giving language-based agents the structured memory necessary to operate in such worlds. Our dataset provides 24198 mappings between rich natural language observations and: (1) knowledge graphs that reflect the world state in the form of a map; (2) natural language actions that are guaranteed to cause a change in that particular world state. The training data is collected across 27 games in multiple genres and contains a further 7836 heldout instances over 9 additional games in the test set. We further provide baseline models using rules-based, question-answering, and sequence learning approaches in addition to an analysis of the data and corresponding learning tasks.

Introduction: The Challenge of Textual Worlds

Interactive narratives, such as the classic game Zork, present a unique challenge for artificial intelligence. Unlike environments with full observability like Chess or Go, these games are partially observable; agents only perceive what is in their immediate vicinity through natural language descriptions. Navigating these worlds effectively requires building a "mental map" or knowledge graph (KG) to track locations, objects, and characters. This task, termed Textual-SLAM, involves simultaneously localizing the agent and mapping the environment using only text.

To play these games effectively, a human player naturally builds a mental model: "The kitchen is east of the living room," or "I need the key from the cellar to open this chest." AI agents struggle with this "structured memory." While previous research used Knowledge Graphs to help agents, there was no large-scale dataset that mapped raw game text to the actual, underlying "ground truth" state of the world. This paper fills that gap with the introduction of JerichoWorld.

The JerichoWorld Dataset

The primary contribution of this work is a massive new dataset designed to help agents move beyond simple pattern matching toward true world modeling. JerichoWorld consists of 24,198 training instances across 27 different games and 7,836 held-out instances across 9 new games for zero-shot evaluation. Each instance includes a natural language observation, the ground-truth Knowledge Graph (triples), and a list of all contextually relevant "valid" actions.

Table 1: Statistics for training and testing games in the JerichoWorld dataset, showing the diversity in vocabulary size, observation length, and graph complexity across various titles.

Methods: Modeling the World

The researchers developed an automated "oracle" agent to collect data and evaluated three baseline architectures for the task of world modeling:

  1. Rules-based: Uses OpenIE (Information Extraction) and hand-authored rules to turn sentences into graph triples (e.g., [player, has, lantern]).
  2. Question-Answering (QA): Based on the Q*BERT architecture, this model uses an ALBERT-based transformer to answer specific questions about the state to populate the graph.
  3. Seq2Seq (Sequence-to-Sequence): A generative approach using a BART-inspired encoder-decoder. It takes the text observation and current graph state as input and attempts to generate the updated linearized knowledge graph and valid actions.
Figure 1: The Seq2Seq architecture for world modeling, where a bidirectional encoder and autoregressive decoder map current observations and graphs to updated world states.

Key Insights and Results

The study revealed a fascinating trade-off between extraction and inference. QA models were excellent at extracting information explicitly mentioned in the text, achieving a graph-level F1 score of 35.48%. In contrast, Seq2Seq models were better at inferring hidden facts—for example, predicting that a "locked chest" contains an item before it is opened—but struggled with the rigid structure of graphs, achieving a lower F1 of 15.54%.

Predicting "valid actions" proved to be a significant bottleneck. Models often default to common commands like "go north" because they appear frequently across all games, struggling to predict game-specific actions like "hit monster with sword." The Seq2Seq model achieved an overall Exact Match (EM) score of 18.10% for action prediction, with lower performance on games with higher action complexity.

Conclusion and Future Work

JerichoWorld provides a benchmark for agents to develop structured memory and commonsense reasoning. Future work will focus on adding structural constraints to the decoding process to prevent hallucinations and addressing the label imbalance in action spaces. The authors note that while this dataset is a breakthrough for text worlds, it requires significant adaptation for tasks requiring direct physical interaction, such as robotics.

Summary updated

BibTeX
@inproceedings{ammanabrolu2021modeling,
  author = {Prithviraj Ammanabrolu and Mark O. Riedl},
  title = {{Modeling Worlds in Text}},
  booktitle = {CSKB @ AKBC},
  year = {2021},
  url = {https://openreview.net/forum?id=jsuynAVoMzn},
}
Figure