Goal-Directed Story Generation: Augmenting Generative Language Models with Reinforcement Learning

Amal Alabdulkarim, Winston Li, Lara J. Martin, Mark O. RiedlarXiv 2021

Introduction

While large language models (LLMs) excel at generating fluent text, they are often "aimless," meandering or repeating themselves instead of driving a narrative toward a specific conclusion. This paper addresses the challenge of "forethought" in storytelling: how to direct a high-capacity, pre-trained LLM to reach a specific goal without sacrificing the natural quality of its prose. The authors introduce KG-DQN, a framework that utilizes Reinforcement Learning (RL) and Knowledge Graphs (KG) to steer GPT-2 toward target events.

Methodology: The KG-DQN Framework

The core innovation of this work is treating story generation as a selection problem rather than a pure autoregressive task. The KG-DQN framework consists of three primary components working in tandem:

  1. Candidate Generation: A frozen GPT-2 model generates 25 candidate continuations for the current story state.
  2. World Modeling: The system maintains a Knowledge Graph of the story world (entities and their relations) extracted via Open Information Extraction (OpenIE). This provides an explicit "map" of the narrative state.
  3. Selection via DQN: A Deep Q-Network (DQN) with a Graph Attention mechanism evaluates the candidates. It analyzes the current KG state and selects the continuation most likely to move the story closer to the defined goal.
Architecture of the KG-DQN framework illustrating the pipeline from query to goal-directed continuation.

Additionally, the authors developed GPT2-RS, which fine-tunes GPT-2 using Proximal Policy Optimization (PPO) and reward shaping based on verb proximity to the goal. The most advanced variant, KG-DQN-RS, uses this fine-tuned model to generate the candidates for the DQN selector.

Experimental Setup

The models were evaluated using a Science Fiction Plot Corpus of over 1,400 stories. To ensure the models learned general plot structures rather than specific character names, stories were preprocessed with Named Entity Recognition (NER) tags (e.g., replacing names with CHARACTER_0). Goals were defined using VerbNet classes; for instance, a "discovery" goal was satisfied by generating a sentence containing a verb from the discover-84 class.

Key Results

The KG-DQN approach demonstrated a dramatic improvement in goal achievement. In the "discover" goal category, a vanilla GPT-2 reached the goal only 18.86% of the time. In contrast, the full KG-DQN-RS model achieved a 98.73% success rate.

Performance metrics across different models showing the significant improvement in goal achievement rate for KG-DQN-RS.

Beyond success rates, the RL-guided models were significantly more concise. While the base GPT-2 would often ramble for over 15 sentences without reaching a goal, the KG-DQN models reached their destination in an average of 4–5 sentences. Human evaluations confirmed these findings, ranking KG-DQN stories higher in grammar, avoidance of repetition, and causal coherence.

Discussion and Future Work

A primary insight of this research is that explicit Knowledge Graphs are superior to an LLM's internal hidden states for tracking complex story worlds. By providing a structured "map," the RL agent can more effectively calculate the utility of specific plot moves.

However, limitations remain. Extracting KGs from raw text via OpenIE can be noisy, and the models' focus on efficiency can sometimes result in a "rushed" narrative feel. Future work will look toward multi-stage goals and balancing plot efficiency with descriptive, atmospheric prose to maintain narrative "flavor."

Summary updated

BibTeX
@misc{alabdulkarim2021goal,
  author = {Amal Alabdulkarim and Winston Li and Lara J. Martin and Mark O. Riedl},
  title = {{Goal-Directed Story Generation: Augmenting Generative Language Models with Reinforcement Learning}},
  year = {2021},
  eprint = {2112.08593},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2112.08593},
}
Figure