- Introduced by
- Community (DeYoung et al.; Rajpurkar et al.)
- Year
- 2016–2020
- Type
- Interpretable NLP pipeline
- Family
- Deep learning / NLP / CV
What does it do?
Explainable Question Answering (XQA) pairs a neural reading-comprehension model, typically a BERT-family transformer, with interpretability techniques such as rationale extraction, attention visualization, LIME, or SHAP, so that the reason for a selected answer span can be inspected.
The aim goes beyond accuracy: the explanation should let users and domain experts check whether the evidence actually supports the answer.
The intuition behind the method
A standard extractive QA model reads a passage, picks an answer span, and stops. An explainable variant also reports which sentences or tokens most influenced that choice, either as a short supporting excerpt (a rationale) or as importance scores over the input tokens. A highlighted rationale that supports the answer is a reason to inspect the prediction further, not proof that it is correct. Whether the highlighted evidence actually drives the model's choice must be tested separately (see score-explanation and limitations). If the highlighted evidence does not support the answer, the mismatch is a warning that the model may be relying on something else. This matters most where a correct answer with a wrong justification can still cause harm, such as medical or legal settings.
History
The SQuAD dataset (Rajpurkar et al., 2016) is a reading-comprehension dataset in which each answer is a segment of text from a Wikipedia passage, so the answer's location in the text is directly available for inspection. The ERASER benchmark (DeYoung et al., 2020) is a benchmark for evaluating rationalized NLP models. Post-hoc attribution methods such as attention analysis, Integrated Gradients and LIME are commonly applied to NLP models.
When to use it
Choose XQA when a bare answer is not enough and someone must audit or justify the model's output, for example in clinical decision support, legal document search, or educational feedback. It fits best when passages are long enough for a rationale to be meaningful and when rationale annotations or faithfulness benchmarks are available for evaluation. Do not choose it when throughput or latency is the main constraint and the setting is low-stakes; a standard QA model is simpler to run. It is also a poor fit for purely factual lookups with no ambiguity, where an explanation adds little.
Limitations and considerations
- Post-hoc attribution (attention weights, SHAP, LIME, gradient-based saliency) describes what the model's inputs correlate with; highlighted tokens are not guaranteed to be the ones that causally drive the chosen span.
- Joint rationale-extraction models need rationale-level annotations, which are costly to produce for passage-question data.
- A plausible-looking rationale can accompany a wrong answer, which may raise reviewers' confidence in that answer.
- Rationale selection or per-token attribution adds computation to each query, so inference is slower than a plain span predictor.
Source conditions do not replace independent scientific review or validation by an analysis engine.
Strengths
- Each answer comes with evidence that a reviewer can check against the source passage, which helps where unexplained answers are not acceptable.
- Rationale inspection can expose shortcut learning, for example when the model highlights passage words that simply mirror the question rather than supporting the answer.
- Joint rationale-and-answer models make the explanation part of the prediction itself, rather than a separate description produced afterwards.
- Post-hoc attribution methods such as SHAP or Integrated Gradients can be applied to an existing BERT-family model without retraining it.
- ERASER-style comprehensiveness and sufficiency scores give a measure of explanation faithfulness that accuracy alone does not provide.
- Expert reviewers can override or flag predictions whose highlighted evidence is implausible, which supports human-in-the-loop review.
Applications
- Clinical QA systems that must cite source sentences from medical records or guidelines.
- Legal research assistants that highlight the clause supporting a contract question.
- Educational reading-comprehension tutors that show students the relevant passage fragment.
- Fact-checking pipelines that link a claim verdict to the specific evidence sentence.
- Regulatory compliance tools requiring audit trails for automated document queries.
How it works
How it works
The question and passage are tokenized and encoded jointly by a pre-trained transformer such as BERT or RoBERTa. Because both are processed as one sequence, the resulting contextual token representations allow question and passage tokens to interact, which supports fine-grained matching between them.
A span-prediction head applies learned start and end classifiers over the token sequence and selects the passage substring with the highest joint probability as the answer. Abstractive QA variants instead use a decoder that generates the answer text rather than extracting a span.
An explanation is produced either post hoc or jointly. Post-hoc options aggregate attention weights, compute gradient-based saliency such as Integrated Gradients, or use LIME to perturb input tokens and estimate local importance. In joint models, a rationale-extraction module selects a compact supporting excerpt, and training optimizes rationale selection and answer prediction together.
Explanations are judged with benchmark metrics such as those in ERASER. Comprehensiveness asks whether removing the rationale degrades the model's prediction; higher comprehensiveness means the rationale matters more to the prediction. Sufficiency asks whether the rationale alone is enough to reproduce the prediction; lower sufficiency means the rationale alone reproduces it more closely. Both measures are defined for a model output that can be scored as a probability. Applying them to span answers, where the output is a text segment rather than a class label, requires an explicit adaptation (for example, scoring the probability the model assigns to the predicted span), and the adaptation should be stated whenever results are reported. Where expert highlights exist, overlap between extracted rationales and those highlights measures plausibility, which is a separate property from faithfulness.
Common pitfalls
- Reading raw attention weights as the explanation without testing faithfulness with comprehensiveness or sufficiency scores.
- Judging explanation quality only by human plausibility ratings and skipping faithfulness tests, since a convincing highlight can still be unfaithful.
- Taking a high ERASER-style score as proof that explanations are correct on a deployment corpus whose passages and question styles differ from the benchmark.
- Reporting XQA results without any explanation-quality metric alongside Exact Match and F1.
- Treating extractive rationales as causal accounts; they show which inputs the decision relies on or correlates with, not a full causal mechanism.
Frequently asked questions
Is attention a reliable explanation for QA models?
Not on its own. Attention weights are not guaranteed to reflect what drives a prediction, so they should be tested rather than assumed. Comprehensiveness and sufficiency metrics from ERASER measure the explanation's effect on the model directly and are the better check.
What is the difference between post-hoc and joint explainability?
Post-hoc methods (SHAP, LIME, Integrated Gradients) explain a trained model after the fact without changing it. Joint models are trained to select a rationale and predict the answer together, so the rationale is produced within the forward pass. Joint training is designed to tie the explanation to the prediction, but faithfulness still needs to be measured.
Do I need annotated rationales to use XQA?
No. Post-hoc methods require no rationale annotations. Annotated rationales are needed only if you want to train a joint model or evaluate plausibility against human highlights.
How do I report explanation quality in a paper?
Report at minimum comprehensiveness and sufficiency scores alongside standard QA metrics (Exact Match, F1). If human annotations exist, add plausibility overlap. Cite the ERASER paper for the metric definitions.
Can XQA help detect dataset shortcuts?
Yes. If the model consistently highlights tokens that correlate with the answer for superficial reasons (e.g., question words mirrored in the passage), the rationale-inspection step reveals this artifact before deployment.
Related methods
Sources
DeYoung, J., Jain, S., Rajani, N. F., Lehman, E., Xiong, C., Socher, R., & Wallace, B. C. (2020). ERASER: A Benchmark to Evaluate Rationalized NLP Models. In Proceedings of ACL 2020, pp. 4443–4458.
Open DOI referenceRajpurkar, P., Zhang, J., Lopyrev, K., & Liang, P. (2016). SQuAD: 100,000+ Questions for Machine Comprehension of Text. In Proceedings of EMNLP 2016, pp. 2383–2392.
Open DOI reference