Tree-Structured Neural Machine for Linguistics-Aware Sentence Generation

Ganbin Zhou, Ping Luo, Rongyu Cao, Yijun Xiao, Fen Lin, Bo Chen, Qing He

Abstract

Standard conversational AI models typically generate sentences word-by-word in a linear chain. While effective for short sequences, this approach often fails to capture the inherent hierarchical structure of human language, leading to responses that lack global grammatical coherence. We present X2TREE, a framework that incorporates linguistic analysis directly into the generation process. By utilizing a dependency parser, X2TREE transforms target sentences into dependency trees and learns to generate these structures top-down. To optimize for modern hardware, we introduce a tree canonicalization method that converts arbitrary trees into equivalent ternary structures. Experimental results on social media datasets show that X2TREE improves the acceptance ratio of generated responses by over 11.15% compared to state-of-the-art sequence-to-sequence baselines.

Introduction: The Limits of Linear Generation

Most sequence-to-sequence (Seq2Seq) models treat language as a linear string of tokens. While Recurrent Neural Networks (RNNs) like LSTMs and GRUs are designed to capture long-distance dependencies, they struggle with the hierarchical nature of grammar. When a model generates a sentence linearly, it must maintain the state of a "subject" while generating a "verb" many tokens later. This often results in "word salad"—sentences that appear locally correct but lack global structural integrity.

Figure 2: Example of a dependency tree structure mapping an input query to a linguistically structured response.

The X2TREE framework addresses this by shifting the decoding process from a linear sequence to a top-down tree structure. By generating the core concepts (like the main verb) first and then filling in descriptive details as children, the model anchors the sentence's meaning early in the generation process.

Methodology

Dependency Tree Learning

Instead of predicting the next word in a line, the X2TREE decoder predicts the "children" of a given node in a dependency tree. This allows the model to establish high-level semantic relationships before committing to specific word orders. The generation follows a top-down path, starting from the root of the dependency tree.

Tree Canonicalization

A significant technical challenge in tree-structured generation is that different words have varying numbers of children, which complicates GPU parallelization. To solve this, the authors propose a Tree Canonicalization method. This process transforms arbitrary dependency trees into full ternary trees (where every internal node has exactly three children: left, middle, and right).

Figure 4: The canonicalization process transforming an n-ary dependency tree into a structured ternary tree for efficient computation.

This ternary structure is theoretically the minimal complexity required to represent any dependency tree while maintaining a fixed branching factor, significantly accelerating training and inference on parallel hardware.

Search and Flattening

To find the most probable response, the framework employs a Generalized Beam Search capable of managing multiple growing branches of a tree simultaneously. Once the tree is fully generated, an in-order traversal flattens the hierarchy back into a standard linear sentence for the final output.

Key Insights

  • Reduced Path Length: In a linear sentence of length $T$, the distance between the first and last word is $T$. In a tree, the average distance from any node to the root is only $O(\sqrt{T})$. This drastically reduces the vanishing gradient problem, facilitating the learning of long-range relationships.
  • Importance-First Generation: By generating the root (usually the main verb) first, the model establishes the core meaning early, leading to higher relevance to the input prompt.
  • Robustness: The model is surprisingly robust to parser errors. As long as the dependency parser makes consistent errors, the model learns those patterns and can still produce a correct linear sequence.

Experimental Results

The framework was evaluated using a dataset of 14 million post-response pairs from Tencent Weibo, cleaned down to a training set of 775,000 pairs. X2TREE was compared against standard Seq2Seq and Attention-based models using human evaluation and automated metrics:

  • Acceptance Ratio: X2TREE achieved a 65.53% "Acceptable" rating, marking an 11.15% improvement over the best baseline (NRM).
  • BLEU Scores: X2TREE outperformed all baselines with a score of 15.87 (vs. 13.73 for the nearest competitor).
  • Grammaticality: The model maintained a high standard of fluency, with ungrammatical responses occurring in only 0.44% of cases.

Conclusion

X2TREE demonstrates that incorporating linguistic structure into neural generation leads to more relevant and coherent conversational AI. By moving beyond linear sequences to hierarchical trees, the model better mimics the structured way humans conceptualize and produce language. Future work may involve applying similar tree-structured architectures to the encoder to further enhance input understanding.

Summary updated

Abstract

Different from other sequential data, sentences in natural language are structured by linguistic grammars. Previous generative conversational models with chain-structured decoder ignore this structure in human language and might generate plausible responses with less satisfactory relevance and fluency. In this study, we aim to incorporate the results from linguistic analysis into the process of sentence generation for high-quality conversation generation. Specifically, we use a dependency parser to transform each response sentence into a dependency tree and construct a training corpus of sentence-tree pairs. A tree-structured decoder is developed to learn the mapping from a sentence to its tree, where different types of hidden states are used to depict the local dependencies from an internal tree node to its children. For training acceleration, we propose a tree canonicalization method, which transforms trees into equivalent ternary trees. Then, with a proposed tree-structured search method, the model is able to generate the most probable responses in the form of dependency trees, which are finally flattened into sequences as the system output. Experimental results demonstrate that the proposed X2Tree framework outperforms baseline methods over 11.15% increase of acceptance ratio.
BibTeX
@inproceedings{zhou2018tree,
  author = {Ganbin Zhou and Ping Luo and Rongyu Cao and Yijun Xiao and Fen Lin and Bo Chen and Qing He},
  title = {{Tree-Structured Neural Machine for Linguistics-Aware Sentence Generation}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2018},
  doi = {10.1609/aaai.v32i1.11969},
}
Figure