# Hierarchical Neural Story Generation

Hierarchical generation writes stories by planning a premise before the text

Angela Fan, Mike Lewis, Yann Dauphin · arXiv · 2018-5-13

- **Problem** Language models drift off the prompt when writing long stories, because a seq2seq model given a prompt often degenerates into a plain language model that ignores it.
- **Method** The hierarchical model first writes a premise with a convolutional language model, then a fused seq2seq model writes the story from it. Its gates read a fixed pretrained model's hidden states.
- **Results** In a blind comparison of 400 story pairs, human raters chose the hierarchical model's stories 67.32% of the time over the language model's stories.

## Why long story generation strains standard models

Story generation asks a model to keep a plot consistent over a long document, to be creative, and to hold a high-level plan. A plain language model emits one word at a time, so it has no explicit place to keep such a plan. Conditioning on a premise gives the story a grounding and makes it less likely to drift off topic.

A seq2seq model given a writing prompt often degenerates into a language model that pays little attention to the prompt. The authors trace this to the link between a prompt and its story, which is more complex and underspecified than the local dependencies that language modelling captures. Length adds a second difficulty. Stories average 734.5 words in the dataset, and recurrent architectures process tokens sequentially, which makes such documents slow to model.

## Building a prompt-story dataset from a writing forum

The stories come from a Reddit writing community in which users post premises and others reply with stories. Each prompt can have several story responses. Over three years of posts were collected through the official Reddit API. Bot posts, deleted posts, announcements, moderator comments and stories shorter than 30 words were removed, and the text was tokenized with NLTK.

The collection contains 303,358 human-written stories paired with writing prompts. Five percent of the prompts form the validation set and five percent the test set. The training split has 272,600 stories, the test split 15,138 and the validation split 15,620, with 7.7M prompt words and 200M story words in total.

Stories are capped at 1000 words in the experiments. The authors note that the many rare words and misspellings from the forum make the full vocabulary costly to model.

## Splitting generation into a prompt stage and a story stage

The first stage produces a premise with a self-attentive GCNN language model. The premise sketches the structure of the story before any story text exists. The second stage is a seq2seq model that writes the story from that premise. Conditioning on the premise keeps the story consistent and gives it structure beyond single phrases.

Prompts are sampled with top-k random sampling from the 10 most likely candidates at each step, and generation stops when the language model emits the end of prompt token. The prompt language model reaches a validation perplexity of 63.06, and it uses the same prompt-side vocabulary as the story-generation models.

## Convolutional seq2seq with gated multi-scale self-attention

The base model is a convolutional seq2seq network built on the work of Gehring et al. (2017). Its encoder and decoder are stacks of convolutional layers, so positions within a sequence can be computed in parallel. Attention modules link the encoder and decoder at each decoder layer by taking a weighted sum over the encoder outputs.

Convolutions only see a bounded window, so the decoder is supplemented with self-attention over the words it has already generated. Self-attention can then pick up long-range context while keeping the computation parallel. Each attention head takes its queries, keys and values from gated deep networks built on Gated Linear Units rather than from plain linear projections.

The authors credit this gating with giving the mechanism the capacity to make fine-grained selections.

Each head works at its own time scale. The first head sees every input position, the second every other position, the third every third position, and so on. Downsampling reduces the number of tokens each head attends over, which makes the attention maps sharper and pushes the heads toward different information.

Each head's output combines a gated value representation of the earlier hidden states with softmax attention weights computed from query and key representations, followed by a linear layer. Two changes from the original self-attention design are made. The model may attend to a zero vector at a timestep, which lets it ignore past positions when they add only noise, and the current timestep is excluded so that only earlier positions are attended to.

The zero-vector option lets the model fall back to the architecture without self-attention, according to the authors.

## Fusing a second seq2seq model with a fixed pretrained one

The fusion model is motivated by the observation that a seq2seq model tends to learn the local regularities of language and miss the subtler dependency on the prompt. Training a second model on top of a pretrained one lets that second model concentrate on what the first failed to learn. The pretrained model is a Conv seq2seq with self-attention trained on WRITING PROMPTS.

Its parameters are held fixed while the second model trains.

The method modifies cold fusion. Cold fusion gates a seq2seq model with the final hidden layer of a pretrained language model, whereas here the gate reads the hidden states of a second seq2seq model. A gate is computed from the concatenated hidden states of the training model and the pretrained model, with a linear projection, a weight matrix W and a bias b, and it is passed through a sigmoid.

The gate scales the concatenated hidden states elementwise, and the gated result feeds fully connected layers with Gated Linear Unit activations, with layer normalization after each fully connected layer.

\\\[ g\_t = \\sigma(W \[h^{Training}\_t ; h^{Pretrained}\_t\] + b) \\\] \\\[ h\_t = g\_t \\circ \[h^{Training}\_t ; h^{Pretrained}\_t\] \\\]

## Training and sampling choices

The models are implemented in fairseq-py on PyTorch. Training uses Nesterov accelerated gradient with gradient clipping, and hyperparameters are chosen by random search cross-validated on the validation set. The architectures are given in the appendix.

Stories are sampled with top-k random sampling. At each step one word is drawn from the k = 10 most likely candidates, and this is the sampling used for story generation.

Each model has its softmax temperature tuned at generation time. Evaluation stories are 150 words long, and unknown word tokens are not generated.

## Perplexity gains from self-attention and fusion

Among the baselines, the GCNN LM reaches a test perplexity of 54.79, the LSTM seq2seq 46.79 and Conv seq2seq 45.54, with Conv seq2seq plus self-attention at 37.94.

The ablation chain in Table 2 adds one component at a time to Conv seq2seq. Test perplexity moves from 45.54 to 42.32 with self-attention, to 40.39 with multiple heads, to 38.91 with multiple scales and to 37.94 with gating. The validation values follow the same order, from 45.27 for Conv seq2seq down to 37.37 with gating.

The fusion model improves on the ensemble in test perplexity while using fewer parameters, which the authors read as evidence that training a second model on top of the first encourages it to learn dependencies on the source. Perplexity measures how fluently a model predicts the next word, so these numbers reflect fluency on the test set rather than dependence on the prompt, which is covered by the prompt-relevance evaluations.

## Prompt ranking and human pairing

Prompt ranking decodes each story under ten prompts, nine random and one true, and records the share of stories for which the true prompt gives the highest likelihood. Each model is scored on 1000 test stories.

In the human study, stories and prompts are shuffled and judges must select the correct pairing for all three prompts. Each model contributes 105 stories grouped into questions, and each question is answered by 15 judges on Amazon Mechanical Turk. Adding model fusion improves the pairing accuracy of the human judges by 7%, according to the authors, while ensembling has no effect on that accuracy.

The fusion model matches nearest neighbour search on how closely a story relates to its prompt. Nearest neighbour retrieval loses relevance quickly as the rank of the retrieved story increases, while the generative model can produce an unlimited number of stories.

## Human preference for hierarchical stories

Stories from the self-attentive GCNN language model are compared with stories from the hierarchical fusion model given prompts from the language model, with 400 stories generated per side. The comparison used 400 pairs of stories, each judged by 5 raters in a blind test on Amazon Mechanical Turk, and raters chose the story they preferred reading.

Raters chose the hierarchical model's story 67.32% of the time and the language model's story 32.68% of the time. The result is a preference between two stories for the same readers in one blind pairing. It does not measure how the hierarchical approach compares with a seq2seq model that has no generated prompt.

## Copying, repetition and prompt quality

In an analysis of 500 generated stories of 150 words from test-set prompts, the fusion model reaches an average longest common subsequence of 8.9 with training text.

Random sampling sometimes splits tokens, for example producing ca n't from can't and sometimes emitting the first token but not the second. After one line of dialogue, the model can continue with another line without emitting a newline token. Repetition is a further problem, because the model focuses on what it has recently produced and so repeats similar text.

Prompts from the GCNN language model are generic compared with human prompts. Many generated prompts begin with the man, and the model rarely produces the specific vocabulary of fantasy settings such as those in Harry Potter and Game of Thrones.

## What the fusion model's attention attends to

Decoder self-attention could reach words generated far in the past, but at many timesteps it focuses on the recent past.

## Limitations

All experiments use the WRITING PROMPTS dataset built from one forum, and the perplexity and prompt-ranking results are measured on that test set. The human studies use stories of 150 words, while the dataset allows stories up to 1000 words, so longer generation is outside the evaluated range.

Random sampling can produce tokenization errors and missing newline tokens, and the fusion model tends to repeat recently produced text. Prompts from the GCNN language model are more generic than human prompts, so the premise stage is weaker than the human prompts in the dataset.

## Paper info

- **Authors**: Angela Fan, Mike Lewis, Yann Dauphin
- **Venue**: arXiv · Preprint
- **First published**: 2018-5-13
- **Added**: 2026-11-13
- **Updated**: 2018-5-13
- **Version**: v1
- **arXiv**: 1805.04833
- **Category**: cs.CL
- **Original paper terms**: [arXiv non-exclusive 1.0](https://arxiv.org/licenses/nonexclusive-distrib/1.0/)
- **What we show**: Paper info and commentary

[Original paper ↗](https://arxiv.org/abs/1805.04833v1) · [PDF ↗](https://arxiv.org/pdf/1805.04833v1)

AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.

## Quote from the paper

Angela Fan, Mike Lewis, Yann Dauphin (2018). Hierarchical Neural Story Generation. arXiv:1805.04833v1. https://arxiv.org/abs/1805.04833v1

**BibTeX**

```
@misc{fan2018hierarchical,
  title = {{Hierarchical Neural Story Generation}},
  author = {Angela Fan and Mike Lewis and Yann Dauphin},
  year = {2018},
  eprint = {1805.04833},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1805.04833v1}
}
```

## Related papers

- [Conformer: Convolution-augmented Transformer for Speech Recognition](https://refivu.com/en/papers/ca253d3a-da87-4fd6-a1f7-53fed7bcc781-conformer-convolution-augmented-transformer-for-speech.md)
- [Text Classification Algorithms: A Survey](https://refivu.com/en/papers/5134d426-2cd3-4691-aeff-cf1fc4cb8d39-text-classification-algorithms-a-survey.md)
- [Recent Trends in Deep Learning Based Natural Language Processing](https://refivu.com/en/papers/6cdbf953-5aaa-4de2-9e22-528902a11655-recent-trends-in-deep-learning-based-natural-language.md)
- [Deep Speech 2: End-to-End Speech Recognition in English and Mandarin](https://refivu.com/en/papers/a706b06b-386b-46f0-b3bc-637c9d25b331-deep-speech-2-end-to-end-speech-recognition.md)
- [Train Short, Test Long: Attention with Linear Biases Enables Input Length Extrapolation](https://refivu.com/en/papers/16116a1b-83a4-4d2d-b5ff-31f5b005ba3f-train-short-test-long-attention-with-linear-biases.md)
- [A Neural Attention Model for Abstractive Sentence Summarization](https://refivu.com/en/papers/d68d7c9a-7c6e-4b4f-a4e9-ba1853fdfad2-a-neural-attention-model-for-abstractive-sentence.md)

## Other paper commentary

- [GQA: A New Dataset for Real-World Visual Reasoning and Compositional Question Answering](https://refivu.com/en/papers/d0afea32-dc3f-4529-bea4-dbdd41e95856-gqa-a-new-dataset-for-real-world-visual.md)
- [How to Fine-Tune BERT for Text Classification?](https://refivu.com/en/papers/b42bc4b9-8309-43db-89e9-41cd1d0ec800-how-to-fine-tune-bert-for-text-classification.md)
- [Reading Wikipedia to Answer Open-Domain Questions](https://refivu.com/en/papers/0abc2d22-75a1-4c4d-91be-624a590aabec-reading-wikipedia-to-answer-open-domain-questions.md)
- [A Neural Conversational Model](https://refivu.com/en/papers/2838569c-2f3a-45e5-86e6-549de8737d24-a-neural-conversational-model.md)
- [OpenNMT: Open-Source Toolkit for Neural Machine Translation](https://refivu.com/en/papers/d158ab7b-d0c6-4ffd-a069-53d34c28b7eb-opennmt-open-source-toolkit-for-neural-machine-translation.md)
- [The One Hundred Layers Tiramisu: Fully Convolutional DenseNets for Semantic Segmentation](https://refivu.com/en/papers/3c8829cf-0ddd-4bc8-9b7c-cfba6d667b61-the-one-hundred-layers-tiramisu-fully-convolutional.md)
- [Self-supervised Graph Learning for Recommendation](https://refivu.com/en/papers/101a7b08-1d43-4cb8-8a03-8ebbce6be79e-self-supervised-graph-learning-for-recommendation.md)
- [A Primer in BERTology: What we know about how BERT works](https://refivu.com/en/papers/f34bc767-f87b-4316-aaf7-7f973209f3fe-a-primer-in-bertology-what-we-know-about.md)
- [Panoptic Segmentation](https://refivu.com/en/papers/dd0aa8a4-d18c-432a-aa71-a94345749b15-panoptic-segmentation.md)
- [Heterogeneous Graph Transformer](https://refivu.com/en/papers/f71bb06f-968c-4006-81b4-63b69f07a087-heterogeneous-graph-transformer.md)
- [Fast Underwater Image Enhancement for Improved Visual Perception](https://refivu.com/en/papers/3952933f-2406-4db3-9d2c-43621581b5b2-fast-underwater-image-enhancement-for-improved-visual.md)
- [Kindling the Darkness: A Practical Low-light Image Enhancer](https://refivu.com/en/papers/e0950d09-0e10-4409-aac5-8ad757e499cc-kindling-the-darkness-a-practical-low-light-image.md)

## Terms in this paper

- [perplexity](https://refivu.com/en/terms/2b204e513801-perplexity)
- [SEQ2SEQ](https://refivu.com/en/terms/6f6133892227-seq2seq)
- [kNN](https://refivu.com/en/terms/c4c008424c75-knn)
- [longest common subsequence](https://refivu.com/en/terms/b0a5cd89a6bb-longest-common-subsequence)

---

AI-written text can contain mistakes. [Refivu](https://refivu.com/en/papers/90786984-6cb5-4a01-ba2e-d107890942b5-hierarchical-neural-story-generation)
