Introduction
Answer selection is a critical component of question answering (QA) systems, where the objective is to rank candidate answers based on their relevance to a given question. Historically, neural models for this task relied on fixed word embeddings like GloVe or Word2Vec. However, these static representations fail to capture polysemy—where a single word has multiple meanings depending on its context.
With the advent of contextualized word embeddings such as ELMo, BERT, and RoBERTa, NLP models can now generate dynamic word vectors based on the surrounding sentence. This paper investigates the most effective way to integrate these embeddings with Transformer encoders for answer selection, specifically comparing a feature-extraction approach against direct fine-tuning of pre-trained models.
Methodology
The authors propose and evaluate two distinct architectural strategies for modeling question-answer similarity:
1. Contextualized Embeddings based Transformer Encoder (CETE)
In this feature-based approach, pre-trained models like ELMo or BERT are used strictly as feature extractors. The resulting contextual word vectors are combined with positional encodings and fed into a single-layer Transformer encoder. The output is then pooled into sentence vectors for both the question and the answer, and a cosine similarity score is calculated between them.
2. Fine-Tuning-Based Approach
In contrast to the feature-based method, this approach involves taking pre-trained Transformer models (BERT, RoBERTa, and XLNet) and fine-tuning them directly on the target answer selection task. The question and answer are concatenated with a [SEP] token, and a linear classification layer is added on top of the [CLS] token to predict the relevance score.
Experimental Setup
The models were evaluated on six publicly available datasets spanning factoid and community question answering (CQA):
- TREC-QA (RAW and Cleaned): Standard factoid QA benchmarks.
- WikiQA: An open-domain QA dataset sourced from Wikipedia.
- YahooCQA: A large-scale community-based QA dataset.
- SemEval-2015, 2016, and 2017 CQA: Community QA datasets from the Qatar Living Forums.
Results and Discussion
The Power of Context
The study confirms that context is paramount. In the feature-based CETE framework, replacing traditional GloVe embeddings with ELMo or BERT resulted in substantial performance gains. For example, on the WikiQA dataset, the ELMo-based CETE model achieved a 13.56% improvement in Mean Average Precision (MAP) over the GloVe baseline. Qualitative analysis of attention maps (Figure 4) demonstrates that contextualized models are significantly better at identifying relevant semantic overlaps between questions and answers.
Fine-Tuning vs. Feature Extraction
Across all datasets, fine-tuning the entire pre-trained model significantly outperformed the feature-based CETE approach. Adapting deep, pre-trained weights directly to the target task proved more effective than training a shallow network on top of frozen features. The fine-tuned RoBERTa-Large model established new state-of-the-art (SOTA) results on five out of the six datasets, including a MAP of 0.950 on TREC-QA RAW and 0.900 on WikiQA.
Structural Insights
An ablation study revealed that when using frozen features, the addition of a Transformer encoder layer is crucial. This layer improved MAP by 25% to 43% compared to using raw frozen embeddings alone, highlighting that even pre-trained features require task-specific structural modeling to reach their full potential.
Conclusion
This research demonstrates that while contextualized embeddings provide a massive boost to sentence similarity modeling, the method of integration matters. Fine-tuning large-scale pre-trained models like RoBERTa-Large is currently the most effective strategy for the answer selection task. Future work will explore extending these Transformer-based architectures to a broader range of NLP challenges, including sentiment analysis and abstractive summarization.
Summary updated