Deep Reinforcement Learning with an Action Space Defined by Natural Language

Ji He, Jianshu Chen, Xiaodong He, Jianfeng Gao, Lihong Li, Li Deng, Mari OstendorfarXiv 2015

Abstract In this paper, we propose the deep reinforcement relevance network (DRRN), a novel deep architecture, to design a model for handling an action space characterized using natural language with applications to text-based games. For a particular class of games, a user must choose among a number of actions described by text, with the goal of maximizing long-term reward. In these games, the best action is typically what fits the current situation best (modeled as a state in the DRRN), also described by text. Because of the exponential complexity of natural language with respect to sentence length, there is typically an unbounded set of unique actions. Even with a constrained vocabulary, the action space is very large and sparse, posing challenges for learning. To address this challenge, the DRRN extracts separate high-level embedding vectors from the texts that describe states and actions, respectively, using a general interaction function, such as inner product, bilinear, and DNN interaction, between these embedding vectors to approximate the Q-function. We evaluate the DRRN on two popular text games, showing superior performance over other deep Q-learning architectures.

Introduction

Traditional Deep Reinforcement Learning (DRL), such as the Deep Q-Network (DQN) used for Atari games, typically relies on a fixed, discrete action space. However, in text-based games—also known as Interactive Fiction—the "actions" are sentences or phrases. This presents three major hurdles for standard RL approaches:

  1. Unbounded Action Space: Natural language allows for a theoretically infinite number of unique actions.
  2. Sparsity: At any given moment, only a tiny fraction of possible sentences are valid or meaningful within the game's logic.
  3. Dynamic Availability: Unlike a controller with fixed buttons, the set of available actions changes at every step based on the story's context.

Standard DQNs fail in these environments because they require a fixed output layer where each node represents a specific action. The DRRN aims to bridge the gap between natural language understanding and sequential decision-making by treating action selection as a relevance-matching problem.

The Deep Reinforcement Relevance Network (DRRN)

The DRRN architecture is built around the principle that the optimal action is the one most relevant to the current state in terms of maximizing future rewards.

Architecture and Learning

The model employs a Dual-Path Embedding strategy. One Deep Neural Network (DNN) maps the state text (the description of the current situation) into a hidden vector, while a second DNN maps candidate action texts into their own vectors.

Crucially, the action-side network uses tied parameters. This ensures that every candidate action at a given time step is processed by the same set of weights, allowing the model to learn general linguistic features of actions rather than memorizing specific action slots. To calculate the Q-value (expected long-term reward), the model computes the "relevance" between the state embedding and each action embedding using an interaction function, such as an inner product or a bilinear transformation.

The DRRN architecture featuring separate state and action embedding paths.

The model is trained end-to-end using Q-learning with experience replay. It utilizes a softmax strategy for exploration, choosing actions based on their relative Q-values. This structure naturally handles a changing number of actions: the action-side DNN is simply run for as many actions as are available.

Experimental Evaluation

The DRRN was evaluated on two text-based games:

  • "Saving John": A deterministic, choice-based game with a vocabulary of 1,762 words and a maximum of four actions per state.
  • "Machine of Death": A larger, stochastic game featuring both choice-based and hypertext-based interactions. It is significantly more complex, with a vocabulary of 2,258 words and up to nine actions per state.

Final rewards were manually annotated for different game endings (ranging from -20 for "bad" endings to +30 for "good" ones) to provide a clear reinforcement signal.

Results and Insights

The DRRN consistently outperformed linear baselines and modified DQN architectures. In "Saving John," a 2-hidden-layer DRRN achieved an average reward of 18.70, significantly higher than the best DQN baseline of 7.12.

Relevance as a Proxy for Value

By framing the Q-function as a measure of relevance, the DRRN generalizes across similar states and actions. If the model learns that "picking up a key" is beneficial in one context, the embedding space allows it to infer that "grabbing a gold key" might be beneficial in another similar context.

Evolution of state and action embeddings over training episodes.

As shown in the visualization of the embedding space, the model learns to align the state vector with high-reward action vectors while pushing away low-reward ones. This suggests the model develops a genuine level of language understanding rather than simple path memorization. Furthermore, the DRRN is more parameter-efficient; in "Machine of Death," it utilized roughly 288k parameters compared to the DQN's 614k, while delivering superior performance.

Conclusion and Future Work

While the DRRN represents a significant step forward, it currently uses a "bag-of-words" approach for initial text representation, which ignores word order. Future iterations could incorporate attention mechanisms to help the network focus on strategic keywords in long descriptions. Additionally, while this work focuses on choice-based games, extending the DRRN to "parser-based" games—where the agent must generate action text from scratch—remains a challenging frontier for generative reinforcement learning.

Summary updated

Abstract

In this paper, we propose the deep reinforcement relevance network (DRRN), a novel deep architecture, to design a model for handling an action space characterized using natural language with applications to text-based games. For a particular class of games, a user must choose among a number of actions described by text, with the goal of maximizing long-term reward. In these games, the best action is typically what fits the current situation best (modeled as a state in the DRRN), also described by text. Because of the exponential complexity of natural language with respect to sentence length, there is typically an unbounded set of unique actions. Even with a constrained vocabulary, the action space is very large and sparse, posing challenges for learning. To address this challenge, the DRRN extracts separate high-level embedding vectors from the texts that describe states and actions, respectively, using a general interaction function, such as inner product, bilinear, and DNN interaction, between these embedding vectors to approximate the Q-function. We evaluate the DRRN on two popular text games, showing superior performance over other deep Q-learning architectures.
BibTeX
@misc{he2015deep,
  author = {Ji He and Jianshu Chen and Xiaodong He and Jianfeng Gao and Lihong Li and Li Deng and Mari Ostendorf},
  title = {{Deep Reinforcement Learning with an Action Space Defined by Natural Language}},
  year = {2015},
}
Figure