Papers
Topics
Authors
Recent
Search
2000 character limit reached

LENp: Logic-Based Text Classification

Updated 10 July 2026
  • LENp is an explainable-by-design extension of Logic Explained Networks that uses compact logic formulas over word features to justify text classification predictions.
  • It refines local explanations by perturbing input words to remove non-contributing terms, thus achieving higher sensitivity and faithfulness compared to LIME.
  • The model maintains interpretability by operating on human-readable, word-based inputs and employing a controlled global explanation search for enhanced transparency.

LENp is an extension of Logic Explained Networks (LENs) to text classification in which the classifier remains explainable by design and its predictions are expressed through compact logic formulas over interpretable word-based inputs. It was introduced to address two limitations identified for prior LENs in text settings: LENs had only been applied to vision and tabular data, and their local explanations tended to be noisy and verbose. LENp improves local explanations by perturbing input words and retaining only literals that contribute in the observed direction. In the reported experiments, it yields better local explanations than LIME in both sensitivity and faithfulness, and its logic explanations were judged more useful and user-friendly than feature scoring in a human survey (Jain et al., 2022).

1. Foundations in Logic Explained Networks

A LEN is an explainable-by-design neural model that is trained end-to-end while enforcing architectural sparsity so that predictions can be exactly described by small First-Order-Logic (FOL) formulas over human-interpretable “concept” inputs. The input is a vector x[0,1]dx\in[0,1]^d, and the output f(x){0,1}rf(x)\in\{0,1\}^r corresponds to rr binary classification tasks. In the text setting, those concepts are word-based features rather than latent embeddings (Jain et al., 2022).

For a predicted class ii with fi(x)=1f_i(x)=1, the LEN local explanation is a conjunction of relevant literals,

ϕl(i)(x)=jA(i)xj(x),\phi^{(i)}_l(x)=\bigwedge_{j\in\mathcal A^{(i)}} \mathbf{x}_j(x),

where each literal xj(x)\mathbf{x}_j(x) is either xj>0.5x_j>0.5 or ¬(xj>0.5)\neg(x_j>0.5), and

A(i)={jαj(i)0.5},αj(i)=Wj(i)1.\mathcal A^{(i)}=\{j\mid \alpha_j^{(i)}\ge 0.5\},\qquad \alpha_j^{(i)}=\|W_j^{(i)}\|_1.

Here, f(x){0,1}rf(x)\in\{0,1\}^r0 is the f(x){0,1}rf(x)\in\{0,1\}^r1-norm of the input-to-first-layer weights for task f(x){0,1}rf(x)\in\{0,1\}^r2.

The corresponding global explanation is a disjunction of the most frequent local formulas,

f(x){0,1}rf(x)\in\{0,1\}^r3

This formulation makes the explanatory object itself logical rather than a secondary approximation to the model.

2. Adaptation to Text Classification

LENp reuses the MLP backbone of prior LENs, with one hidden layer and ReLU activations, and preserves the entropy-based sparsity regulariser on the input-weight norms f(x){0,1}rf(x)\in\{0,1\}^r4. Its text-specific adaptation begins with input encoding: raw Q/A text is tokenized and converted either into binary “word-present” vectors or into TF-IDF vectors in f(x){0,1}rf(x)\in\{0,1\}^r5. These vectors constitute the interpretable concept inputs used by the network (Jain et al., 2022).

The network is a fully connected architecture

f(x){0,1}rf(x)\in\{0,1\}^r6

trained with multi-label cross-entropy together with an entropy penalty: f(x){0,1}rf(x)\in\{0,1\}^r7 At inference time, the decision rule is thresholded so that f(x){0,1}rf(x)\in\{0,1\}^r8 is interpreted as class f(x){0,1}rf(x)\in\{0,1\}^r9.

This design preserves the central LEN property that explanations are expressed directly over human-readable inputs. In the text domain, the relevant concepts are words represented through binary bag-of-words or TF-IDF features rather than latent token encodings.

3. Perturbation-Based Local Explanations

The main innovation of LENp is a perturbation procedure for refining local explanations. The original LEN local-extraction algorithm builds rr0 from the importance scores rr1 and the sign of rr2, but it cannot distinguish whether a feature contributes positively or negatively to the predicted class. LENp addresses precisely this failure mode (Jain et al., 2022).

For each literal in the raw LEN explanation, LENp performs the following steps:

  1. Record the original prediction rr3.
  2. Flip the corresponding feature’s presence or absence in rr4 to obtain rr5.
  3. Re-evaluate the prediction rr6.
  4. If rr7, the flipped feature is treated as a “bad” term; otherwise it is a “good” term.
  5. Return the conjunction containing only the good terms, with their original polarity.

The resulting local explanation contains only literals whose removal lowers the class score. By discarding bad terms, LENp ensures that each literal truly contributes in the observed direction. This directly targets the problem described for prior LEN local explanations, namely that they can be noisy and verbose.

A reported qualitative example concerns the question “Which .NET collection should I use for adding multiple objects at once and getting notified?” predicted with tag C#. The original LEN local rule was

rr8

whereas the LENp local rule was

rr9

The interpretation given is that, although “C#” was globally important, its absence did not drive the prediction; when “C#” was perturbed to present, removing ii0 increased ii1, so it was identified as a bad term and discarded (Jain et al., 2022).

LENp also specifies a global-explanation procedure based on disjunctions of local formulas. Given a collection of local explanations for class ii2, the method considers nonempty subsets of the top-ii3 local explanations, forms a disjunction for each subset, evaluates the resulting formula on validation data, and returns the formula with the best accuracy (Jain et al., 2022).

Operationally, the procedure is an exhaustive power-set search over the selected local rules. This yields an optimal disjunction within the chosen candidate set, but the reported setup notes a clear computational restriction: power-set search is only feasible for small ii4. Accordingly, the global explanation size ii5 was varied in ii6.

This makes the global stage a controlled trade-off between expressivity and tractability. A plausible implication is that LENp’s global explanations are most practical when the explanatory basis can be compressed into a small number of representative local rules.

5. Evaluation Protocol and Quantitative Results

The empirical study uses StackSample, described as “10% of Stack Overflow Q&A,” for multi-label tag classification, reduced to the top ii7 K most frequent tags. Three tags—“C#”, “Java”, and “Python”—were used for detailed local-explanation comparison. Inputs were binary bag-of-words or TF-IDF vectors. The compared explainers were original LEN, LENp, and LIME with discretized inputs (D) and without discretization (ND). LEN was used both as an explainable-by-design classifier and as a surrogate in explanation comparisons, while a Random Forest black box and RBF-SVMs were used for the human-survey comparison. Hyperparameters were chosen by grid-search under a computational budget of 15 min per explainer run, and the perturbation radius for sensitivity was set to ii8 (Jain et al., 2022).

Two explanation metrics were defined. Faithfulness was measured by the Area Under the Most Relevant First perturbation Curve (AUC-MoRF): ii9 where fi(x)=1f_i(x)=10 are feature indices sorted by decreasing relevance, and

fi(x)=1f_i(x)=11

Smaller values indicate more faithful explanations. Sensitivity was measured by Max-Sensitivity: fi(x)=1f_i(x)=12 Lower values indicate greater robustness to small perturbations.

Method AUC-MoRF Max-Sensitivity
LEN fi(x)=1f_i(x)=13 fi(x)=1f_i(x)=14
LENp fi(x)=1f_i(x)=15 fi(x)=1f_i(x)=16
LIME (D) fi(x)=1f_i(x)=17 fi(x)=1f_i(x)=18
LIME (ND) fi(x)=1f_i(x)=19 ϕl(i)(x)=jA(i)xj(x),\phi^{(i)}_l(x)=\bigwedge_{j\in\mathcal A^{(i)}} \mathbf{x}_j(x),0

On these metrics, LENp had the lowest AUC-MoRF and tied LEN at zero Max-Sensitivity. The paper also reports a biased-model detection experiment, measured as the percentage of runs in which noisy features were spotted. In setting S1/S2, LENp achieved ϕl(i)(x)=jA(i)xj(x),\phi^{(i)}_l(x)=\bigwedge_{j\in\mathcal A^{(i)}} \mathbf{x}_j(x),1 / ϕl(i)(x)=jA(i)xj(x),\phi^{(i)}_l(x)=\bigwedge_{j\in\mathcal A^{(i)}} \mathbf{x}_j(x),2, compared with ϕl(i)(x)=jA(i)xj(x),\phi^{(i)}_l(x)=\bigwedge_{j\in\mathcal A^{(i)}} \mathbf{x}_j(x),3 / ϕl(i)(x)=jA(i)xj(x),\phi^{(i)}_l(x)=\bigwedge_{j\in\mathcal A^{(i)}} \mathbf{x}_j(x),4 for LEN, ϕl(i)(x)=jA(i)xj(x),\phi^{(i)}_l(x)=\bigwedge_{j\in\mathcal A^{(i)}} \mathbf{x}_j(x),5 / ϕl(i)(x)=jA(i)xj(x),\phi^{(i)}_l(x)=\bigwedge_{j\in\mathcal A^{(i)}} \mathbf{x}_j(x),6 for LIME (D), and ϕl(i)(x)=jA(i)xj(x),\phi^{(i)}_l(x)=\bigwedge_{j\in\mathcal A^{(i)}} \mathbf{x}_j(x),7 / ϕl(i)(x)=jA(i)xj(x),\phi^{(i)}_l(x)=\bigwedge_{j\in\mathcal A^{(i)}} \mathbf{x}_j(x),8 for LIME (ND) (Jain et al., 2022).

6. Human Evaluation, Interpretation, and Significance

The human survey involved 26 respondents: 13 ML experts, 10 with CS background, and 3 non-experts. It assessed both local and global explanatory usefulness rather than only perturbation-based proxy metrics (Jain et al., 2022).

In Task 1, which asked about ease of understanding local explanations on a 1–5 scale, LENp and LIME had high overlap in their 95% confidence intervals. In Task 2, respondents were asked to identify the feature to ignore for improving the classifier. The correct feature (“add”) was selected by ϕl(i)(x)=jA(i)xj(x),\phi^{(i)}_l(x)=\bigwedge_{j\in\mathcal A^{(i)}} \mathbf{x}_j(x),9 of respondents with LIME explanations and by xj(x)\mathbf{x}_j(x)0 with LENp explanations. In Task 3, respondents chose the more general of two classifiers by inspecting global explanations; xj(x)\mathbf{x}_j(x)1 were correct with LIME (SP-LIME), versus xj(x)\mathbf{x}_j(x)2 with LENp.

The paper summarizes these results by stating that logic explanations were more useful and user-friendly than feature scoring provided by LIME, and that participants found LENp global explanations markedly easier to use than LIME’s aggregated feature weights. Within the scope of the reported experiments, LENp therefore occupies a specific position in explainable text classification: it preserves the explainable-by-design character of LENs, refines local rules through single-feature perturbations, and produces logic rules that are both quantitatively more faithful and more effective in user tasks than the compared LIME variants (Jain et al., 2022).

Definition Search Book Streamline Icon: https://streamlinehq.com
References (1)

Topic to Video (Beta)

No one has generated a video about this topic yet.

Whiteboard

No one has generated a whiteboard explanation for this topic yet.

Follow Topic

Get notified by email when new papers are published related to LENp.