Texar: A Modularized, Versatile, and Extensible Toolbox for Text Generation

Zhiting Hu, Zichao Yang, Tiancheng Zhao, Haoran Shi, Junxian He, Di Wang, Xuezhe Ma, Zhengzhong Liu, Xiaodan Liang, Lianhui Qin, Devendra Singh Chaplot, Bowen Tan, Xingjiang Yu, Eric P. Xing2018

Abstract

Zhiting Hu, Zichao Yang, Tiancheng Zhao, Haoran Shi, Junxian He, Di Wang, Xuezhe Ma, Zhengzhong Liu, Xiaodan Liang, Lianhui Qin, Devendra Singh Chaplot, Bowen Tan, Xingjiang Yu, Eric Xing. Proceedings of Workshop for NLP Open Source Software (NLP-OSS).

2018.

Introduction

Text generation is a broad field in Natural Language Processing (NLP), encompassing tasks such as machine translation, summarization, dialog systems, and image captioning. Historically, toolkits in this space have been "siloed"—developed for specific tasks like Neural Machine Translation (NMT). This specialization creates a significant gap, making it difficult to share algorithmic advances across different applications. For example, an optimization technique developed for translation might be highly effective for summarization, but implementing it in a different codebase often presents a massive engineering hurdle.

Texar is an open-source, TensorFlow-based toolkit designed to unify this fragmented landscape. By providing a "LEGO-like" modular architecture, it allows researchers to easily build, swap, and extend complex models for a wide variety of text generation tasks, fostering reproducible research and rapid technique sharing.

Methods: Modularization through Decomposition

The core philosophy of Texar is modularization through decomposition. The toolkit breaks down the standard machine learning pipeline into four decoupled elements:

  1. Model Architecture ($f_\theta$): The structure of encoders, decoders, and memories.
  2. Data ($D$): Input sources and processing pipelines.
  3. Losses ($\mathcal{L}$): Optimization objectives (e.g., MLE, adversarial loss).
  4. Learning Procedure ($\max$): Optimization algorithms (e.g., Adam, RL agents).
The hierarchical architecture of Texar, showcasing the decoupling of model templates, library APIs, and core components.

By decoupling these components, Texar allows users to maintain the same model architecture while switching from Maximum Likelihood Estimation (MLE) to Reinforcement Learning (RL) or Adversarial Learning (GANs) with only a few lines of code. Texar offers two levels of user interfaces: high-level YAML configuration files for non-experts and full-access Python library APIs for researchers who need to manipulate internal states or create entirely new modules.

Key Insights: The "LEGO" Approach

Texar treats components like encoders, decoders, and classifiers as interchangeable bricks. This allows for the assembly of "composite" architectures that go far beyond simple sequence-to-sequence models.

Diverse model architectures (a-g) constructed using Texar's modular components.

A key innovation is the toolkit's algorithm agnosticism. The decoder, for instance, does not need to know how it is being trained; whether it is optimized via cross-entropy or a policy gradient, the underlying inference logic remains the same. Texar’s Connector modules handle the "glue" between these disparate parts. This modularity makes it trivial to take a state-of-the-art architecture from one field—such as the Transformer from machine translation—and apply it to a different domain, like VAE-based language modeling or dialog systems.

Evaluation and Key Results

The authors demonstrated Texar’s versatility across several standard benchmarks, including Yahoo and PTB (Penn Treebank) for VAE language modeling, Switchboard for conversation generation, and Yelp for text style transfer.

The paper focuses on case studies that highlight the toolkit's utility:

  • Transformer Generalization: By swapping an LSTM decoder for a Transformer decoder in a VAE, the authors achieved improved performance on the Yahoo dataset, with test perplexity dropping from 68.31 to 61.26.
  • Style Transfer: Using Texar to re-implement existing style transfer models yielded better results than the original implementations. On the Yelp dataset, the Texar implementation achieved 88.6% accuracy, compared to the original 79.5%.
  • Fair Benchmarking: Texar allows for clean comparisons of different techniques on the same task. For instance, evaluations showed that while seqGAN is popular, it did not improve perplexity over standard MLE on the PTB dataset, highlighting the importance of standardized implementations for honest evaluation.

Conclusion

Texar provides a robust and flexible library of modules to support the fast-moving field of text generation. While the initial version was focused on the TensorFlow ecosystem, the toolkit's design principles are platform-agnostic. Since its publication, a PyTorch version has also been released to accommodate the shifting preferences of the research community. Future work focuses on supporting distributed model training and streamlining service deployment.

Summary updated

BibTeX
@misc{hu2018texar,
  author = {Zhiting Hu and Zichao Yang and Tiancheng Zhao and Haoran Shi and Junxian He and Di Wang and Xuezhe Ma and Zhengzhong Liu and Xiaodan Liang and Lianhui Qin and Devendra Singh Chaplot and Bowen Tan and Xingjiang Yu and Eric P. Xing},
  title = {{Texar: A Modularized, Versatile, and Extensible Toolbox for Text Generation}},
  year = {2018},
  doi = {10.18653/v1/w18-2503},
}
Figure