Abstract
Generative models for Question Answering (QA) offer significant flexibility but are frequently undermined by their tendency to hallucinate information not present in the source text. Conversely, extractive models provide high reliability by identifying specific spans within a text but often require specialized, task-specific architectures. This paper proposes a novel framework that bridges these two paradigms by leveraging the internal cross-attention mechanisms of generative Seq2Seq Transformers. We demonstrate that by jointly training models on both generative and extractive objectives, we can extract precise answer spans without adding additional parameters. Our approach, evaluated on SQuAD, NaturalQuestions, and TriviaQA, significantly reduces hallucinations through a "backoff" strategy and achieves state-of-the-art performance in passage reranking.
Introduction
In the current landscape of Question Answering (QA), researchers typically choose between generative models, which synthesize answers token-by-token, and extractive models, which point to specific snippets in a source text. While generative models like BART and T5 are powerful, their "black-box" nature makes them prone to confidently stating incorrect facts—a significant liability in industrial applications. Extractive models are safer but less flexible. This work investigates whether we can obtain extractive reliability from generative models "for free" by interpreting their internal attention patterns.
Methodology: Attention as an Architectural Prior
The core of our approach is the observation that cross-attention serves as an inherent architectural prior for alignment. When a Transformer decoder generates an answer token, it must attend to the relevant portions of the input context. We hypothesize that the context token with the highest attention weight during the first decoding step likely indicates the start of the answer span, while the most attended token during the final step indicates the end.
To formalize this, we introduce a joint training objective: $$\mathcal{L}_{joint} = (1 - \lambda)\mathcal{L}_{gen} + \lambda\mathcal{L}_{span}$$ This loss function forces the model's attention to align specifically with ground-truth start and end positions during training, "sharpening" the model's focus.
Additionally, we propose a "backoff" strategy to mitigate hallucinations: if the generative model produces a string absent from the source text, the system defaults to the extractive span identified by the attention weights.
Experiments and Datasets
We evaluated our method across three major benchmarks:
- SQuAD v1.1: A reading comprehension dataset where answers are always spans within a single passage.
- NaturalQuestions (NQ): An open-domain dataset based on real-world search queries.
- TriviaQA: A large-scale open-domain dataset with complex, fact-based questions.
For open-domain tasks, we employed the Fusion-in-Decoder (FiD) architecture, allowing the model to aggregate information from multiple retrieved passages simultaneously.
Results and Discussion
Our results indicate that the joint training objective significantly enhances the extractive capabilities of generative models. On SQuAD v1.1, the BART-large joint model achieved an Exact Match (EM) score of 85.53, a substantial improvement over the 62.94 EM of the baseline generative model.
Key findings include:
- Parameter Efficiency: Our BART-large joint model (406M parameters) performed comparably to or better than SOTA FiD-KD models based on T5-large (770M parameters).
- Reranking Performance: Attention probabilities proved to be a powerful proxy for passage relevance. On NaturalQuestions, attention-based reranking improved P@1 from 50.36 to 66.59.
- Model Capacity: Interestingly, larger models (e.g., BART-large) initially performed worse at zero-shot extraction than smaller models, likely due to a greater reliance on internal knowledge. Joint training is therefore particularly critical for larger architectures to ensure grounding.
Conclusion
By guiding the attention of generative models, we can create QA systems that are both flexible and grounded. This approach eliminates the need for specialized extractive heads while providing a robust mechanism to combat hallucinations and improve passage retrieval. Future work will explore using these attention-aligned tokens in real-time during decoding to further steer model outputs.
Summary updated