Abstract
Text-based games present a unique challenge for autonomous agents to operate in natural language and handle enormous action spaces. In this paper, we propose the Contextual Action Language Model (CALM) to generate a compact set of action candidates at each game state. Our key insight is to train language models on human gameplay, where people demonstrate linguistic priors and a general game sense for promising actions conditioned on game history. We combine CALM with a reinforcement learning agent which re-ranks the generated action candidates to maximize in-game rewards. We evaluate our approach using the Jericho benchmark, on games unseen by CALM during training. Our method obtains a 69% relative improvement in average game score over the previous state-of-the-art model. Surprisingly, on half of these games, CALM is competitive with or better than other models that have access to ground truth admissible actions.
Introduction
Text-based games, such as the classic Zork, represent a significant frontier for Reinforcement Learning (RL). Unlike environments with discrete, low-dimensional action spaces (like Atari or Chess), text games require agents to navigate a world using natural language. This leads to a "combinatorial explosion" of possible actions. For instance, a game with a modest vocabulary of 700 words can theoretically support billions of 4-word commands. Most of these commands are either syntactically invalid or semantically nonsensical in context.
To solve this, we introduce CALM (Contextual Action Language Model), which leverages the linguistic priors inherent in human gameplay to prune the action space down to a manageable set of "common sense" candidates.
The CALM Framework
CALM operates on a "generate-and-rank" principle. Instead of forcing an RL agent to explore the entire vocabulary, we use a fine-tuned language model to propose a small set of likely actions based on the current game state and history.
1. Action Generation (CALM)
We fine-tuned a GPT-2 model on ClubFloyd, a dataset consisting of 426 human gameplay transcripts across 590 games. By training on human data, CALM learns a distribution of actions that are not just "valid" (admissible by the game engine) but "promising" (likely to lead to progress). Given a context $c_t$ (the previous observation, action, and current observation), CALM generates the top-$k$ most probable actions.
2. Action Re-ranking (DRRN)
These candidates are then evaluated by a Deep Reinforcement Relevance Network (DRRN). The DRRN uses reinforcement learning to estimate the Q-value—the expected future reward—for each candidate action. This allows the agent to select the specific action that maximizes progress within the current game environment.
Experimental Results
We evaluated CALM on the Jericho benchmark, a suite of 28 interactive fiction games. Crucially, the evaluation games were held out from the training set to ensure the model learned generalizable linguistic priors rather than just memorizing specific game solutions.
Performance and Efficiency
CALM achieved a 69% relative improvement in average game scores over NAIL, the previous state-of-the-art agent that did not rely on internal game-state "handicaps." By narrowing the action space to just 30 candidates, the RL agent converged significantly faster than models attempting to explore the full vocabulary.
As shown in the recall analysis, the GPT-2 based CALM is highly effective at capturing the "gold" actions—those necessary for game progress—within a small number of candidates ($k$). This high recall is the foundation of the agent's success, as it ensures the RL ranker almost always has the correct move available in its candidate set.
Key Insights
- Pruning vs. Cheating: Many existing agents are given a "handicap" in the form of a ground-truth list of all admissible actions. CALM outperformed these "cheating" agents on 8 out of 28 games. This suggests that CALM’s ability to ignore "distractor" moves (valid but useless actions) is more valuable than simply knowing every possible valid command.
- Linguistic Priors: Human players bring a wealth of world knowledge to games. Training on human data allows CALM to understand that if a player sees a "locked case," the action "unlock case with key" is a high-probability candidate, even if the agent has never seen that specific case before.
Conclusion
CALM demonstrates that large-scale language models can serve as powerful search heuristics for RL agents in complex, natural language environments. By combining general linguistic knowledge with task-specific reinforcement learning, we can effectively navigate combinatorial action spaces that were previously intractable for autonomous agents.
Summary updated