Context-Aware Transformer Pre-Training for Answer Sentence Selection

Luca Di Liello, Siddhant Garg, Alessandro Moschitti

Abstract

Standard Transformer models often struggle with "contextual" Answer Sentence Selection (AS2) because their pre-training does not prepare them to distinguish between a question, a candidate answer, and the surrounding context. This paper introduces three novel pre-training objectives that utilize document and paragraph structures to teach models these specific roles. By framing pre-training as a "Sentences in Same Paragraph" (SSP) task, the proposed approach achieves accuracy improvements of up to 9.1% across public benchmarks and large-scale industrial datasets.

Introduction

Answer Sentence Selection (AS2) is a critical component of modern Question Answering (QA) systems, where the goal is to rank candidate sentences to find the most accurate response to a user's query. While state-of-the-art systems use Transformers to cross-encode questions and answers, evaluating a candidate sentence in isolation is often insufficient. Sentences frequently contain unresolved pronouns or lack the necessary background to be definitively linked to a question without surrounding text.

Incorporating "local context"—the sentences immediately preceding and following a candidate—can resolve these ambiguities. However, standard pre-trained models like RoBERTa or ELECTRA are not designed to handle this three-part input (Question + Candidate + Context). During fine-tuning, these models must simultaneously learn the ranking task and the structural roles of these distinct text segments, which often leads to sub-optimal performance, especially on smaller datasets.

Methodology: Continuous Pre-Training

The authors propose a "Continuous Pre-Training" approach that builds upon existing checkpoints (RoBERTa-Base and ELECTRA-Base). Instead of training from scratch, they perform additional training using three new objectives designed to mimic the structure of contextual AS2. This task is framed as "Sentences in Same Paragraph" (SSP), where the model is fed a triplet $(a, b, c)$. Here, $a$ acts as a pseudo-question, $b$ is the candidate sentence, and $c$ is the context. The model must predict if $a$ and $b$ belong to the same paragraph.

Three variants of this objective were tested:

  1. Static Document-level Context (SDC): The context $c$ is always the first paragraph of the document, providing global entity anchors.
  2. Dynamic Paragraph-level Context (DPC): The context $c$ consists of all other sentences in the paragraph where $b$ was found.
  3. Dynamic Sentence-level Local Context (DSLC): The context $c$ is specifically the sentences immediately before and after $b$, mimicking the local context used in downstream AS2.

Experimental Setup

The models were pre-trained on a massive corpus including English Wikipedia, BookCorpus, OpenWebText, and CC-News. Evaluation was conducted across a diverse set of benchmarks, ranging from small public sets to massive industrial datasets.

Table 2: Statistics for the datasets used in evaluation, including the large-scale industrial IQAD dataset.

As shown in the dataset statistics, the evaluation covers a wide spectrum of data scales, from the 237 test questions in WikiQA to the millions of QA pairs in the industrial IQAD and ASNQ datasets.

Key Results and Discussion

The proposed pre-training objectives yielded significant performance gains across all tested datasets. The structural alignment provided by the SSP task allowed the models to develop specialized embeddings for different input slots before fine-tuning began.

Table 1: Performance comparison (MAP and P@1) of the proposed SSP objectives against standard ELECTRA and RoBERTa baselines.

Performance Highlights:

  • Accuracy Gains: On the WikiQA dataset, the proposed pre-training improved P@1 (Precision at 1) by 8% to 9.1% compared to standard baselines. This suggests that specialized pre-training is particularly effective when fine-tuning data is scarce.
  • Industrial Impact: On the Alexa-based IQAD datasets, the SDC (Static Document-level Context) method consistently outperformed other strategies. In web-scale retrieval, where candidates come from disparate documents, the "global" summary provided by the first paragraph helps the model rank candidates more effectively than local context alone.
  • Efficiency: These results were achieved using only approximately 10% of the compute required for the original model's pre-training, making this an efficient "top-off" training phase for existing models.

Conclusion

This research demonstrates that the role of text segments is as vital as their content in contextual QA. By forcing models to use context to determine relationships between sentences during pre-training, they become significantly more adept at downstream ranking tasks. Future work may explore more sophisticated multi-task learning strategies to combine these objectives and the incorporation of additional global signals like document titles and metadata.

Summary updated

BibTeX
@inproceedings{liello2023context,
  author = {Luca Di Liello and Siddhant Garg and Alessandro Moschitti},
  title = {{Context-Aware Transformer Pre-Training for Answer Sentence Selection}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2023},
  doi = {10.18653/v1/2023.acl-short.40},
}
Figure