Learning to Answer by Learning to Ask: Getting the Best of GPT-2 and BERT Worlds

Tassilo Klein, Moin NabiarXiv 2019

Abstract

Automatic question generation aims at the generation of questions from a context, with the corresponding answers being sub-spans of the given passage. Whereas most methods rely on heuristic rules, neural network approaches have recently been proposed. In this work, we propose a variant of the self-attention Transformer network architecture to generate meaningful and diverse questions. We introduce a model consisting of the conjunction of the Transformer decoder (GPT-2) with a Transformer encoder (BERT) for the downstream task of question answering. The model is trained in an end-to-end fashion, where the language model is trained to produce a question-answer-aware input representation that facilitates generating an answer-focused question. Our results on the SQuAD 1.1 dataset suggest that our method can produce semantically correct and diverse questions. Additionally, analysis shows that our proposed generation & answering collaboration framework improves both tasks and is particularly powerful in the semi-supervised setup, providing a robust and lean pipeline for question generation in small-data regimes.

Introduction

In Natural Language Processing, Question Answering (QA) has seen massive progress, but its "inverse" task—Question Generation (QG)—is often overlooked. Traditional QG relies on rigid heuristic rules, while newer neural approaches often struggle to produce diverse, semantically meaningful questions.

A major bottleneck in this field is data: training high-quality QA systems requires massive amounts of human-annotated question-answer pairs. This research addresses two main challenges: the evaluation gap, where standard metrics like BLEU fail to capture semantic validity, and data scarcity, exploring how unlabeled text can be used to improve QA systems through high-quality question generation.

Methodology: The Collaborative Training Loop

The proposed architecture leverages the complementary strengths of two Transformer-based models: GPT-2 for generation and BERT for answering. As a Transformer decoder, GPT-2 is naturally suited for left-to-right text generation, while BERT, a bidirectional encoder, excels at identifying answer spans within a context.

The core innovation is the Collaborative Training Loop. Instead of training these models in isolation, the system uses BERT as a teacher for GPT-2.

Overview of the fine-tuning approach: GPT-2 generates a question, and BERT attempts to answer it. If BERT fails, the loss is backpropagated to improve GPT-2's generation.

As illustrated in the figure above, the process follows these steps:

  1. GPT-2 generates a question based on a context and an annotated answer.
  2. This generated question is fed to a pre-trained BERT QA model.
  3. If BERT cannot correctly identify the original answer span from the generated question, the failure is backpropagated as a loss to GPT-2.
  4. To prevent catastrophic forgetting, a replay mechanism is used, continuously sampling from a set of previously "successful" question-answer pairs.

Experimental Results

The researchers utilized the SQuAD 1.1 dataset to evaluate the model. To test efficiency in low-data regimes, they experimented with "labeling rates" ranging from 10% to 90%, treating the remaining data as unlabeled text for the QG model to practice on.

Superior Semi-Supervised Performance

The framework proved most powerful when labeled data was limited. At a 10% labeling rate, the proposed method achieved a Test F1 score of 0.6391, nearly 17 points higher than previous state-of-the-art GAN-based or dual-learning approaches.

Table comparing performance across various labeling rates, demonstrating the significant gains of the proposed method in low-data scenarios.

Key Insights

  • QA as a Surrogate Metric: The best way to judge a question generator is by seeing if a QA model can answer its output. If a generated question leads a QA model to the right answer, it is semantically valid, regardless of its overlap with human-written ground truth.
  • Duality as a Teacher: By forcing the generator to satisfy the answerer, the model learns to focus on relevant semantic features rather than just mimicking syntax.
  • Stability through Static Feedback: The authors found it best to keep the BERT weights frozen during the collaborative phase to prevent training instability and "drift."

Conclusion

This collaborative framework demonstrates that "learning to answer by learning to ask" is a viable path for improving NLP systems in data-scarce environments. While the current model still requires an answer span as a prompt, future work will explore autonomous identification of "answerable" spans and more complex closed-loop systems where both models improve each other simultaneously.

Summary updated

BibTeX
@misc{klein2019learning,
  author = {Tassilo Klein and Moin Nabi},
  title = {{Learning to Answer by Learning to Ask: Getting the Best of GPT-2 and BERT Worlds}},
  year = {2019},
  eprint = {1911.02365},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1911.02365},
}
Figure