Visualize Before You Write: Imagination-Guided Open-Ended Text Generation

Wanrong Zhu, An Yan, Yujie Lu, Wenda Xu, Xin Wang, Miguel P. Eckstein, William Yang Wang · DOI

Abstract

Open-ended text generation frequently suffers from degeneration, where models produce repetitive or uninformative content. This paper proposes iNLG (imagination-guided Natural Language Generation), a framework inspired by human creative visualization. By integrating a text-to-image diffusion model to "imagine" a scene, iNLG provides a global semantic anchor for the language model. Experimental results across story generation and sentence completion tasks demonstrate that iNLG significantly improves text coherence and creativity while reducing repetition, particularly in low-resource settings.

1. Introduction

Open-ended text generation—tasks like finishing a story or completing a sentence—remains a significant challenge for modern language models. Even powerful architectures like GPT-2 or BART often suffer from degeneration, becoming repetitive or losing the logical thread of the context. This occurs because standard models predict the next word based solely on previous tokens, lacking a global "blueprint" of the scene.

Comparison of text-only generation versus imagination-guided generation.

In contrast, human writers often use creative visualization, forming a mental image of a scene to ground their writing. This paper introduces iNLG to endow machines with this same ability to "visualize before they write."

2. The iNLG Framework

The iNLG framework is a model-agnostic approach that functions in three primary stages: rendering, prefix construction, and dual-objective training.

The iNLG architecture, featuring text-to-image generation and visually-guided text generation modules.

2.1 Text-to-Image Rendering

Given an input context (e.g., "A man is skiing behind a boat"), the system uses Stable Diffusion to render a corresponding image. This "imagined" image serves as a bespoke visualization of the specific prompt, which the authors found to be more effective than retrieving generic images from external databases.

2.2 Visual Prefix Construction

To bridge the gap between visual pixels and linguistic tokens, the generated image is processed through a frozen CLIP encoder. A trainable Mapping Network (an 8-layer Transformer) then converts these visual features into a sequence of "visual prefixes." These continuous embeddings are prepended to the text context, allowing the language model to process them as special prompt tokens.

2.3 Dual-Objective Training

The model is trained using two complementary objectives:

  • Teacher Forcing: The model learns to predict the target text given both the visual prefix and the text context.
  • Contrastive Learning: A novel objective that penalizes the model if the semantic representation of its generated text diverges from the visual features of the imagined image. This ensures the imagination actually anchors the narrative content.

3. Experimental Setup

The researchers evaluated iNLG across three distinct tasks:

  • Sentence Completion: Using the ActivityNet subset of HellaSwag.
  • Story Generation: Using ROCStories, a collection of five-sentence everyday life narratives.
  • Concept-to-Text: Using CommonGen, requiring the generation of coherent sentences from a set of provided concepts.

The mapping networks were pre-trained on MSCOCO and VIST to establish the general relationship between images and descriptive text before task-specific fine-tuning.

4. Key Results and Analysis

The quantitative and qualitative improvements provided by iNLG were substantial across all benchmarks:

  • Mitigating Degeneration: On the ROCStories task in a few-shot setting, iNLG reduced the repetition metric (rep-2) from 25.41 (text-only) to 10.73.
  • Human-like Quality: The MAUVE score, which measures the similarity between machine and human text distributions, jumped from 9.10 to 35.94 on story generation.
  • Few-Shot Efficiency: iNLG demonstrated remarkable prowess in low-resource scenarios. When trained on only 1% of the available data, visually-guided models outperformed text-only baselines by significant margins, suggesting that visual grounding facilitates more efficient common-sense learning.
  • Model Agnosticism: The framework successfully improved performance across various architectures, including GPT-2, BART, and T5.

5. Conclusion and Future Work

iNLG demonstrates that visual imagination can act as a powerful semantic anchor, stabilizing text generation and preventing models from falling into local word-prediction loops.

However, limitations remain. Current text-to-image models struggle with abstract concepts or specific numerical values. Furthermore, the image generation process currently happens "offline," adding computational latency. Future research may explore end-to-end systems that iteratively update their "imagination" or use sequences of images (mental videos) to maintain narrative flow in longer stories.

Summary updated

BibTeX
@inproceedings{zhu2023visualize,
  author = {Wanrong Zhu and An Yan and Yujie Lu and Wenda Xu and Xin Wang and Miguel P. Eckstein and William Yang Wang},
  title = {{Visualize Before You Write: Imagination-Guided Open-Ended Text Generation}},
  booktitle = {EACL (Findings)},
  year = {2023},
  doi = {10.18653/v1/2023.findings-eacl.5},
}
Figure