Generate, Filter, and Rank: Grammaticality Classification for Production-Ready NLG Systems

Ashwini Challa, Kartikeya Upasani, Anusha Balakrishnan, Rajen Subba

Abstract: Ashwini Challa, Kartikeya Upasani, Anusha Balakrishnan, Rajen Subba. Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 2 (Industry Papers).

2019.

Introduction

Neural Natural Language Generation (NLG) models have revolutionized dialogue systems, enabling natural and diverse responses. However, in production environments like virtual assistants, these models often lack a necessary "safety net." A single ungrammatical or nonsensical response can significantly erode user trust.

Traditional "Generate and Rank" frameworks, where a reranker selects the most likely candidate from a generated set, suffer from two primary issues:

  1. The "Best of the Worst" Problem: If all generated candidates are ungrammatical, the reranker will still select one, delivering a broken response to the user.
  2. Data Mismatch: Standard grammatical error datasets (e.g., NUCLE) focus on human learner mistakes. AI models, however, exhibit unique "hallucinations" and glitches—such as word repetitions ("with with") or missing units ("3 celsius")—that these datasets fail to capture.

This paper introduces a Generate, Filter, and Rank framework designed to explicitly veto "broken" outputs before they reach the user.

Methodology

The authors propose a three-stage pipeline. The "Filter" is a high-precision classifier that evaluates candidates and rejects those that are not 100% grammatical. Two supervised learning approaches were evaluated for this filter:

  • CNN-based Classification: A convolutional neural network identifies local patterns of ungrammaticality. An enhanced version, "CNN + source," incorporates information about which specific model generated the text.
  • LM-GBDT: A Gradient Boosted Decision Tree utilizing features from a 7-gram Language Model (LM), such as n-gram probability statistics (min, max, median).

To focus on syntax over specific facts, the models used delexicalization, replacing entities (e.g., "London", "72 degrees") with generic placeholders like LOCATION and NUMBER.

Data and Error Analysis

The study utilizes two main datasets: the standard NUCLE (CoNLL-2014) benchmark and a new Weather Dataset. The latter contains 33,000 responses from four different NLG systems, human-labeled for grammaticality and semantic correctness.

Analysis reveals that model-generated errors are distinct from human errors. LSTMs often repeat words or drop "glue" words, while retrieval systems (IR) may select ill-fitting templates.

Examples of model-generated errors categorized by type.

Results and Discussion

The implementation of the filtering stage showed significant improvements in system reliability.

  • Filtering Efficacy: Using a standard "Ranker" resulted in ungrammatical top responses 29.4% of the time. The "Filter + Ranker" approach reduced this failure rate to just 2.4%.
  • Precision over Recall: In production, precision is prioritized. It is preferable to reject a few good sentences (lower recall) to ensure that those delivered are perfect. If all candidates are rejected, the system falls back to a safe, pre-written template.
  • Dataset Specificity: Models trained on human errors (NUCLE) performed poorly on model-generated errors. A CNN trained on the new weather dataset achieved 72.8% recall at 98% precision, highlighting the necessity of domain-specific, model-aware training data.
Reduction in ungrammatical and semantically incorrect responses using the Filter + Ranker framework.

Conclusion and Future Work

The "Generate, Filter, and Rank" framework provides a robust path for deploying neural NLG in production. However, it relies on the availability of a "safe" fallback template. Future research is needed to address "semantic correctness" (ensuring factual accuracy) and to test the generalizability of these filters across more complex conversational domains beyond weather.

Summary updated

BibTeX
@inproceedings{challa2019generate,
  author = {Ashwini Challa and Kartikeya Upasani and Anusha Balakrishnan and Rajen Subba},
  title = {{Generate, Filter, and Rank: Grammaticality Classification for Production-Ready NLG Systems}},
  booktitle = {Conference of the North American Chapter of the Association for Computational Linguistics},
  year = {2019},
  url = {https://openreview.net/forum?id=BkNf6Q-OWH},
}
Figure