Transformer-Based Neural Text Generation with Syntactic Guidance

Yinghao Li, Rui Feng, Isaac Rehg, Chao ZhangarXiv 2020

Abstract

Syntactically controlled text generation aims to produce fluent sentences that adhere to a specified grammatical structure while preserving the semantic meaning of a source input. Traditional approaches utilizing Recurrent Neural Networks (RNNs) often struggle with long-range dependencies and the hierarchical nature of language. In this paper, we present GuiG (Guided Generation), a Transformer-based architecture designed to follow complex syntactic constraints. By introducing a novel path attention mechanism and a multi-encoder framework, GuiG achieves a significant leap in performance, improving BLEU scores from 11.83 to 26.27 and enhancing semantic quality by over 120% compared to previous state-of-the-art models.

Introduction

In Natural Language Processing (NLP), the ability to control the "style" or syntactic structure of generated text is crucial for tasks such as paraphrasing, question generation, and formal-to-informal translation. For instance, a user might require a model to rewrite a declarative sentence into a specific complex grammatical construction without losing the original intent.

Previous state-of-the-art models, such as the Syntactically Controlled Paraphrase Network (SCPN), relied heavily on Long Short-Term Memory (LSTM) networks. However, LSTMs face two primary hurdles: they struggle to maintain long-term dependencies in lengthy sentences and they treat language as a flat sequence rather than a hierarchical structure. Consequently, these models often fail to truly internalize the structural constraints of a syntax tree, treating them as simple sequences to be translated.

The GuiG Framework

To overcome these limitations, researchers from Georgia Tech developed GuiG. This model leverages the parallel processing capabilities of Transformers while introducing structural inductive biases specifically tailored for syntax.

Overview of the GuiG framework, showing the transition from source text and template parse to the final generated output.

Syntax Expansion and Linearization

Providing a complete, detailed parse tree for every generation task is often impractical. GuiG addresses this by using a Syntax Expander. The process begins with a "template"—a high-level sketch representing the top levels of a parse tree. The Syntax Expander then populates the remaining levels to align with the specific source text. To maintain efficiency, GuiG utilizes a node-level linearization format, representing trees as sequences of (node, level) pairs, which is significantly more compact than traditional bracketed representations.

Path Attention

A core innovation of GuiG is the Path Attention mechanism. While standard Transformer attention allows every token to attend to every other token, Path Attention restricts a node's attention to only its ancestors and descendants within the syntax tree. This constraint forces parent nodes to act as summaries for their children, effectively modeling the tree's hierarchy within the Transformer's self-attention layers.

The Guided Text Generator architecture featuring the Path Attention mechanism designed to preserve hierarchical tree structures.

Multi-Encoder Architecture

Rather than concatenating source text and syntax into a single sequence, GuiG employs a multi-encoder approach. One encoder processes the semantic meaning (source text), while another processes the structural guidance (expanded parse tree). A specialized multi-encoder attention mechanism in the decoder then dynamically balances these two streams of information during the generation process.

Experimental Results

The model was evaluated using a standardized subset of the ParaNMT-50M dataset, comprising nearly 450,000 paraphrase pairs. Performance was measured using both automated metrics and human evaluation on high-quality, manually annotated sets.

  • Syntactic and Semantic Accuracy: GuiG demonstrated a massive improvement in BLEU scores, rising to 26.27 from the previous benchmark of 11.83. Human evaluators further confirmed these findings, rating GuiG's output as 122.1% better in semantic quality than SCPN.
  • Structural Adherence: Using Tree Edit Distance (TED) as a metric, GuiG showed a much closer adherence to requested syntactic structures, proving that the model successfully follows the "rules" of the provided parse trees.

Discussion and Conclusion

While GuiG represents a major advancement, it is not without limitations. The authors noted occasional logic errors, particularly with complex negations (e.g., "not unlike"), and typical Transformer-related issues like word repetition or subword artifacts from Byte Pair Encoding (BPE).

Despite these challenges, GuiG's ability to separate and then fuse syntax and semantics makes it a powerful tool for data augmentation and style transfer. By providing a "skeleton" through templates, GuiG allows for highly controlled and diverse text generation that respects the fundamental hierarchical nature of human language.

Summary updated

BibTeX
@misc{li2020transformer,
  author = {Yinghao Li and Rui Feng and Isaac Rehg and Chao Zhang},
  title = {{Transformer-Based Neural Text Generation with Syntactic Guidance}},
  year = {2020},
  eprint = {2010.01737},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2010.01737},
}
Figure