[Paper Review] Towards Grad-CAM Based Explainability in a Legal Text Processing Pipeline
This paper introduces the first application of Grad-CAM, a computer vision explainability technique, to legal text processing pipelines. By adapting Grad-CAM to analyze convolutional neural networks (CNNs) on legal texts, the authors demonstrate how different word embeddings (e.g., DistilBERT, word2vec, Law2Vec) influence model attention and prediction, showing that DistilBERT leads to broader attention across input sentences, while Grad-CAM-guided pruning preserves model accuracy with reduced input data.
Explainable AI(XAI)is a domain focused on providing interpretability and explainability of a decision-making process. In the domain of law, in addition to system and data transparency, it also requires the (legal-) decision-model transparency and the ability to understand the models inner working when arriving at the decision. This paper provides the first approaches to using a popular image processing technique, Grad-CAM, to showcase the explainability concept for legal texts. With the help of adapted Grad-CAM metrics, we show the interplay between the choice of embeddings, its consideration of contextual information, and their effect on downstream processing.
Motivation & Objective
- To introduce Grad-CAM as a post-hoc explainability method for legal text processing pipelines.
- To evaluate how different word embeddings (contextual vs. non-contextual) affect CNN attention patterns in legal text classification.
- To develop metrics for quantifying and comparing the extent of model attention across embeddings.
- To explore data optimization via Grad-CAM-guided word selection, reducing input size without sacrificing accuracy.
- To lay the foundation for future integration of explainability with legal decision-making transparency (epistemic view).
Proposed method
- Adapt Grad-CAM to generate class activation heatmaps for legal text inputs processed by CNNs.
- Use a binarization threshold (e.g., 0.15) on Grad-CAM heatmaps to identify salient words contributing to predictions.
- Define a metric $\mathcal{F}(t)$ to compute the average fraction of input tokens considered by the CNN for prediction across test sentences.
- Introduce a white-listing strategy based on Grad-CAM attention to filter input sentences to only include high-attention words during inference.
- Compare model performance (accuracy) between full input and Grad-CAM-optimized input to assess data efficiency.
- Apply metrics $\mathcal{F}(t)$ and $\mathcal{I}$ (Jaccard index) to quantify attention spread and similarity between embedding types.
Experimental results
Research questions
- RQ1How does the choice of word embedding (e.g., DistilBERT, word2vec, Law2Vec) affect the attention distribution of a CNN on legal text?
- RQ2Can Grad-CAM-based attention maps reveal differences in context handling between contextual and non-contextual embeddings in legal NLP?
- RQ3To what extent can Grad-CAM be used to identify and extract the most salient words in legal sentences for downstream data optimization?
- RQ4Does pruning input sentences to only include Grad-CAM-salient words preserve model accuracy in legal text classification tasks?
- RQ5Can the proposed metrics provide a reliable proxy for evaluating embedding quality in low-resource or semi-supervised legal NLP settings?
Key findings
- DistilBERT embeddings yielded the highest mean $\mathcal{F}(t)$ value, indicating broader attention across input sentences compared to word2vec and Law2Vec.
- Word2vec and Law2Vec showed high similarity in attention patterns, as evidenced by a high $\mathcal{I}$ metric (Jaccard index), suggesting comparable attention behavior.
- Grad-CAM-guided input pruning preserved model accuracy—achieving 0.7 accuracy for PTSD-word2vec(GoogleNews) and 0.85 for PTSD-DistilBERT—despite reduced input size.
- The method enabled identification of salient words per sentence, allowing for potential optimization of data pipelines and reduced computational load.
- The proposed metrics $\mathcal{F}(t)$ and $\mathcal{I}$ provide a quantitative basis for comparing embedding models in terms of attention coverage and consistency.
- The results suggest that Grad-CAM can serve as a tool for analyzing context dependency in legal embeddings, supporting model interpretability and optimization.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.