TextBox: A Unified, Modularized, and Extensible Framework for Text Generation

Junyi Li, Tianyi Tang, Gaole He, Jinhao Jiang, Xiaoxuan Hu, Puzhao Xie, Zhipeng Chen, Zhuohao Yu, Wayne Xin Zhao, Ji-Rong Wen

Introduction

Natural Language Generation (NLG) is a cornerstone of modern AI, encompassing diverse tasks such as machine translation, summarization, and dialogue systems. However, the software ecosystem for NLG has historically been fragmented. Researchers often rely on niche libraries focused on specific paradigms (e.g., only GANs or only Machine Translation), which complicates fair comparisons and hinders reproducibility.

TextBox is an open-source, PyTorch-based library designed to address these challenges. By providing a unified framework that supports 21 different models—ranging from Variational Auto-Encoders (VAEs) and Generative Adversarial Networks (GANs) to state-of-the-art Pretrained Language Models (PLMs)—TextBox standardizes the entire pipeline from data preprocessing to evaluation.

Modularized Design and Methods

The core strength of TextBox lies in its modularized architecture, which decouples the generation process into four distinct, reusable components. This design allows researchers to "plug and swap" modules for rapid experimentation.

The modularized architecture of the TextBox framework, illustrating the separation of Strategy, Model, Data, Evaluation, and Configuration modules.
  1. Data Module: Implements a unified data flow (input text → Dataset → DataLoader → models). It handles tokenization and vocabulary building for both unconditional (single-sequence) and conditional (paired-sequence) tasks.
  2. Model Module: Breaks down architectures into sub-modules like Encoders, Decoders, and Attention mechanisms. Every model follows a standardized interface with forward() for training and generate() for inference.
  3. Evaluation Module: To ensure fair comparisons, TextBox includes a comprehensive suite of metrics. This includes logit-based metrics (Perplexity, NLL) and word-based metrics (BLEU, ROUGE, METEOR, CIDEr, and BERTScore). It also integrates fastBLEU for high-speed multi-threaded evaluation.
  4. Configuration Module: Experiments are managed via YAML files or command-line arguments, enabling hyperparameter tuning without source code modification.

Benchmark Datasets

To provide a ready-to-use environment, the authors incorporated nine widely-used benchmark datasets:

  • COCO: For unconditional text generation.
  • AMAZON: For attribute-to-text generation.
  • Personal Chat: For dialogue systems.
  • IWSLT2014 (German-to-English): For machine translation.
  • GigaWord: For text summarization.

Key Results and Empirical Validation

The authors validated TextBox by implementing 21 baseline models and comparing their performance against original reported results. This standardized evaluation protocol prevents common pitfalls where minor implementation differences in metrics lead to non-comparable results.

Performance comparison of various models across unconditional generation, attribute-to-text, and dialogue system tasks.

Performance Highlights

  • Unconditional Generation: On the COCO dataset, GPT-2 demonstrated significant dominance, achieving a BLEU-4 score of 31.88, outperforming GAN-based models like RankGAN (26.40) and SeqGAN (25.18).
  • Decoding Strategies: Empirical tests showed that decoding methods significantly impact performance. In machine translation tasks, Beam Search consistently outperformed Greedy and Top-k search across both RNN and Transformer architectures.
  • PLM Dominance: In summarization tasks, pretrained models like BART and T5 significantly outperformed traditional baselines. For instance, BART achieved a ROUGE-L score of 41.25, compared to 38.36 for a standard RNN+Attention model.

Conclusion and Future Directions

TextBox successfully bridges the gap between disparate modeling paradigms by treating VAEs, GANs, and Transformers under a single structural umbrella. While the current version focuses on text-to-text generation, future work aims to expand input diversity to include graphs and tables. Additionally, the authors plan to optimize multi-machine distributed training and incorporate bias mitigation frameworks to address the ethical risks inherent in large-scale text generation.

Summary updated

BibTeX
@inproceedings{li2021textbox,
  author = {Junyi Li and Tianyi Tang and Gaole He and Jinhao Jiang and Xiaoxuan Hu and Puzhao Xie and Zhipeng Chen and Zhuohao Yu and Wayne Xin Zhao and Ji-Rong Wen},
  title = {{TextBox: A Unified, Modularized, and Extensible Framework for Text Generation}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2021},
  doi = {10.18653/v1/2021.acl-demo.4},
}
Figure