Extending Logic Explained Networks to Text Classification

Rishabh Jain, Gabriele Ciravegna, Pietro Barbiero, Francesco Giannini, Davide Buffelli, Pietro Liò

Introduction

Deep Neural Networks, particularly Transformers and LSTMs, have become the standard for text classification tasks. However, their "black-box" nature poses significant challenges in safety-critical domains where understanding the reasoning behind a prediction is as important as the prediction itself. Traditional eXplainable AI (XAI) methods, such as LIME and SHAP, operate post-hoc, attempting to approximate the model's logic after training. These methods often suffer from "noisy" explanations—feature importance vectors that lack faithfulness to the model's internal logic and exhibit high sensitivity to minor input perturbations.

This paper introduces $LEN^p$, an extension of Logic Explained Networks (LENs) specifically tailored for text classification. Unlike post-hoc methods, $LEN^p$ is designed to be inherently interpretable, providing explanations in the form of First-Order Logic (FOL) formulas. By incorporating a novel perturbation-based approach and optimal global aggregation, $LEN^p$ offers a more robust and human-centric alternative to existing XAI tools.

Methodology

The $LEN^p$ framework improves upon the original LEN architecture through three primary mechanisms:

1. Perturbation-Based Local Explanations

The core innovation of $LEN^p$ is its strategy for refining local explanations. While standard LENs identify important terms based on neural weights, $LEN^p$ validates these terms through active perturbation. The model identifies "important" terms and then "flips" their presence in the input to observe the effect on prediction probability:

  • Supportive Terms: Words that, when removed, significantly decrease the prediction probability, indicating they truly drive the classification.
  • Spurious Terms: Words that may have high weights but do not materially drive the prediction for a specific instance.

The resulting local explanation is a conjunction (an "AND" statement) of only the verified supportive terms, ensuring the explanation is faithful to the model's actual decision-making process.

2. Optimal Global Aggregation

To provide a comprehensive view of the model's behavior across an entire dataset, $LEN^p$ moves beyond "greedy" aggregation methods. It employs a power-set approach to identify the optimal combination of local logic formulas. This ensures that the global explanation maintains high validation accuracy relative to the model's overall logic, providing a more reliable summary of the model's global behavior.

3. Architecture and Regularization

$LEN^p$ utilizes a specific neural architecture that imposes sparsity. By using entropy-based regularization, the model ensures that internal weights are easily translatable into discrete logic gates, bridging the gap between continuous neural representations and symbolic logic.

Experimental Evaluation

The researchers evaluated $LEN^p$ using the StackSample: 10% of Stack Overflow Q&A dataset. The task involved multi-label text classification, predicting tags (e.g., "python", "java", or "C#") based on question text. For preprocessing, the text was converted into a bag-of-words representation using TF-IDF to facilitate logic-based reasoning.

Key Results and Insights

The evaluation focused on three critical dimensions: faithfulness, robustness, and human utility.

Faithfulness and Robustness

$LEN^p$ demonstrated superior performance in identifying influential features. Using the AUC-MoRF (Area Under the Mean of Rank Functions) metric, where lower scores indicate better faithfulness, $LEN^p$ achieved 0.0489, significantly outperforming LIME's 0.3919.

Furthermore, $LEN^p$ exhibited remarkable stability. While LIME variants showed a Max-Sensitivity of approximately 1.4—meaning explanations changed significantly with minor input variations—$LEN^p$ recorded 0.0 Max-Sensitivity. This indicates that $LEN^p$ provides consistent and reliable explanations that are not swayed by noise.

Human Utility and Bias Detection

A user study highlighted the practical benefits of logic-based explanations. When tasked with identifying features to ignore to improve a biased model, 84.6% of participants succeeded using LEN explanations, compared to only 61.5% using LIME. This suggests that First-Order Logic (e.g., python AND NOT android) is more intuitive and actionable for human operators than numerical importance scores.

Performance Trade-offs

Crucially, the transition to an "explainable-by-design" architecture did not result in a significant loss of predictive power. The $LEN^p$ model performed comparably to a standard Multi-Layer Perceptron (MLP), proving that interpretability does not necessarily require a sacrifice in accuracy.

Discussion and Future Work

While $LEN^p$ represents a significant step forward, it faces certain limitations. The optimal global aggregation strategy has a computational complexity of $O(2^k \times n)$, which may become a bottleneck as the number of local explanations ($k$) grows. Additionally, the current reliance on bag-of-words (TF-IDF) means the model does not yet capture sequential context or word order, which are vital for complex linguistic tasks.

Future research will focus on integrating concept extraction from sequential models like Transformers and exploring more computationally efficient aggregation methods to scale $LEN^p$ to larger and more diverse datasets, such as news or legal corpora.

Summary updated

BibTeX
@inproceedings{jain2022extending,
  author = {Rishabh Jain and Gabriele Ciravegna and Pietro Barbiero and Francesco Giannini and Davide Buffelli and Pietro Liò},
  title = {{Extending Logic Explained Networks to Text Classification}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2022},
  doi = {10.18653/v1/2022.emnlp-main.604},
}
Figure