Abstract
We are interested in learning how to update Knowledge Graphs (KG) from text. In this preliminary work, we propose a novel Sequence-to-Sequence (Seq2Seq) architecture to generate elementary KG operations. Furthermore, we introduce a new dataset for KG extraction built upon text-based game transitions (over 300k data points). We conduct experiments and discuss the results.
Introduction
In the realm of interactive fiction and text-based games, agents operate in partially observable environments where the world state is described entirely through natural language. To succeed, an agent must maintain a robust internal representation of the world—a "mental map" that tracks its location, discovered objects, and their relationships.
While Knowledge Graphs (KGs) are a natural fit for this structured memory, existing approaches often rely on static graphs or hand-coded rules for updates. This research addresses the problem of dynamic KG maintenance, proposing a model that learns to automatically update its internal graph based on text observations and actions.
Methodology
The proposed architecture treats world-state tracking as a sequence-to-sequence translation problem. The model processes a text observation and the agent's previous action to generate a set of update commands for the KG.
Architecture Overview
The system consists of four primary components:
- Text Encoder: A Transformer-based module that encodes the current text observation and the preceding action.
- Graph Encoder: This module encodes the agent's existing "belief graph." The authors utilize Relational Graph Convolutional Networks (R-GCNs) to effectively model diverse relationship types, such as spatial directions ("north_of") or object states ("is_closed").
- Representation Aggregator: An attention mechanism that fuses information from both the text and graph encoders.
- Command Generator: A decoder that produces a sequence of update operations in plain text, such as
add(player, shed, at)ordelete(player, backyard, at).
The TextWorld KG Dataset
To support this research, the authors introduced the TextWorld KG dataset. Built using the TextWorld framework, it contains over 300,000 data points representing game transitions. Each entry includes the prior KG state, the action taken, the resulting text, and the ground-truth updated KG represented as Resource Description Framework (RDF) triples. The dataset focuses on a "hungry agent" scenario, requiring navigation, object interaction, and multi-step tasks like cooking.
Key Insights and Experimental Results
The models were evaluated on their ability to predict the correct graph updates in two settings: Teacher-force (TF), where the model receives the perfect previous graph at each step, and Free-run (FR), where the model must maintain the graph independently over an entire game.
Performance Comparison
The experiments demonstrated that the R-GCN with Relational Embeddings significantly outperformed other architectures.
- R-GCN + Relational Embeddings: Achieved a 0.962 TF-F1 and a 0.697 FR-F1.
- Vanilla Transformer: Without an explicit graph encoder, performance dropped sharply in the Free-run setting (0.434 F1), proving that an explicit graph-based memory is vital for long-term consistency.
Analysis of World Logic
The study revealed several critical insights into how agents perceive game worlds:
- Navigation and Deletion: Error analysis showed that models without graph memory failed on movement actions. When an agent moves from a "backyard" to a "shed," the text describes the shed but rarely mentions leaving the backyard. The KG allows the model to remember the previous state and correctly issue a
deletecommand for the old location. - The Complexity of "Prepare": All models struggled with complex actions like "prepare" (cooking). This action often consumes multiple ingredients simultaneously, requiring the model to reason about and delete multiple disparate entities from its memory based on a single text prompt.
Conclusion and Future Work
This research provides a foundation for learning dynamic world models from text. By generating discrete graph operations, the proposed Seq2Seq architecture offers a flexible and interpretable way to maintain agent memory. While error accumulation remains a challenge in long-duration "Free-run" scenarios, the integration of R-GCNs and relational embeddings provides a path forward. Future work will involve integrating this dynamic KG module into Reinforcement Learning agents, allowing them to use their self-maintained mental maps to guide exploration and decision-making.
Summary updated