1 of 95

Explainability and Interpretability for NLP

PFIA 2025 Dijon

1

2 of 95

Celine Hudelot

Prof. MICS, CentraleSupélec, Univ. Paris-Saclay

Wassila Ouerdane

Prof. MICS, CentraleSupélec, Univ. Paris-Saclay

Antonin Poché

PhD Student at IRT Saint Exupéry & IRIT

Jean-Philippe Poli

DR. CEA List

Univ. Paris-Saclay / Carnot List

Charlotte Claye

PhD Student ScientaLab, MICS, CentraleSupélec, Univ. Paris-Saclay

3 of 95

3

4 of 95

Table of content

  • Context & Motivations

  • User-centered Explanations

  • Research-centered explanation

  • In practice: Interpreto Library

4

5 of 95

Context & Motivations

5

6 of 95

Context : High-Performing Language Models

  • Accelerating progress in language AI
  • An increase in usage intentions in many domains
  • Language AI at the central pillar of Generative AI

6

7 of 95

Context: Several (critical) applications

7

8 of 95

Context : Prone to unexpected failures

8

9 of 95

Requirements for AI adoption

9

10 of 95

The key component of Explainability

10

11 of 95

Scope of the explanation

11

Feature Viz,

Concept Activation Vector

Explanation “by design”

...

Feature Attribution

Feature Inversion

...

Nearest Neighbourhood

Influence Function

Prototypes

...

12 of 95

Application time

12

(ant-hoc/transparent/self-explaining)

13 of 95

Format of the explanations

13

Dalvil, et al (ICLR, 2022)

Captum tutorial

Xplique

Example-based

Model surrogate

Attributions

Concept-based

Feature viz

14 of 95

Target of explanation

14

End users

Regulatory entities

Data scientist

Domain expert

15 of 95

Current explainability challenges

15

User-level Evaluation

Maturity of the tools

Frequent new objects

Interpretation

16 of 95

XAI for NLP

16

17 of 95

Language AI : the main tasks

Main principles :

  • Text representation : tokenization and embedding.
    • High-dimensionality
  • Recent models are mainly based on the transformer architecture
    • Importance of the attention mechanism
  • Many tasks are generative
    • Translation, Question-Answering, Summarization, ….

17

18 of 95

Challenges: Cognitive load

I have a dream that my four little children will one day live in a nation where they will not be judged by the color of their skin but by the content of their character.

Martin Luther King

18

19 of 95

Challenges : Tokenization and Embeddings

Artificial Intelligence

CLS

Art

##ific

##ial

Intel

##lig

##ence

EOS

101

4362

67103

796

15875

39771

27646

102

101: [0.1, 0.5, 0.9, 0.3, 0.8]

4362: [0.0, 0.2, 0.9, 0.4, 0.7]

67103: [0.6, 0.2, 0.5, 0.7, 0.8]

796: [0.5, 0.5, 0.4, 0.1, 0.3]

15875: [0.8, 0.6, 0.9, 0.3, 0.3]

39771: [0.1, 0.1, 0.8, 0.5, 0.5]

27646: [0.7, 0.2, 0.2, 0.3, 0.3]

102: [0.2, 0.8, 0.8, 0.5, 0.1]

Input text

Input tokens

Input ids

Input embeddings

20 of 95

Challenge: Context and Ambiguity

20

Words and sentences often have multiple meanings, and understanding the correct interpretation depends heavily on context.

21 of 95

Challenges: Generation

  • Generations are auto-regressive.
    • Local explanation only explain one token prediction.
    • To explain text generation there are as many explanations as generated tokens.

21

22 of 95

Challenges: Generating Auto-explanations

  • To be useful explanations should be both plausible and faithful. Jacovi et Golberg 2019
    • Plausible: Probable and convincing to humans
    • Faithful: Represent the model mechanisms

Auto-explanations are highly plausible (they are trained for it). But nothing proves their faithfulness.

22

23 of 95

Challenges: LLM sizes

  • Explainability often requires hundreds of inferences

  • Most generation language model (> 8B) do not fit in “consumer” size GPUs

  • Largest models are “sharded" across GPUs which is an engineering challenge

23

24 of 95

User-centered Explanations

  • Attributions methods

  • Concepts-based methods

  • Evaluation and metrics

24

25 of 95

User-centered methods: an overview

25

Attribution methods

Concept-based methods

Rationalization

Perturbation-

based attribution

Gradient-

based attribution

Internal-based attribution

SHAP techniques

Unsupervised concepts

Supervised concepts

SHAP techniques x Unsupervised concepts

Supervised concepts x Rationalization

Adapted from Fanny Jourdan’s slides

26 of 95

Rationalization: a quick note (not the focus)

26

Rationalization provides explanations in natural language to justify a model’s prediction

  • Extractive rationalization ⤳ important features or sentences from the input data

  • Abstractive rationalization ⤳ novel sentences with new words

(GURRRAPU et al., 2023) : https://arxiv.org/abs/2301.08912

27 of 95

Attribution methods

27

28 of 95

Attribution methods

28

Adapted from Thomas Fel’s slides

29 of 95

Attribution-based XAI for classification

Classification Task ✅❌

29

I

best

love

this film !

It’s the

movie I’v ever seen

Avis Positif

Heatmap of word importance for the 'positive' class.

Adapted from Fanny Jourdan’s slides

30 of 95

Attribution-based XAI : application

Bias Detection Task ❗🔍

30

pour son sérieux et

Elle

l’hôpital

travaille à

de Perpignan depuis 3 ans.

Les

patients

qu’

elle

opère la recommande fortement

sa gentillesse

Classe prédite: Infirmière

Vraie classe: Chirurgienne

Adapted from Fanny Jourdan’s slides

31 of 95

Attribution-based XAI : application

Bias Detection Task ❗🔍

31

pour son sérieux et

Elle

l’hôpital

Classe prédite: Infirmière

Vraie classe: Chirurgienne

travaille à

de Perpignan depuis 3 ans.

Les

patients

qu’

elle

opère la recommande fortement

sa gentillesse

Heatmap de l’importance des mots de l’exemple pour la prédiction de la classe «infirmière»

Adapted from Fanny Jourdan’s slides

32 of 95

Attribution-based XAI for generation

Generation Task 📄➡️📄

32

L’enseignante

adore

aider

ses

étudiants

The teacher

loves

Heatmap of the importance of preceding words for the generation of the word 'loves'

Adapted from Fanny Jourdan’s slides

33 of 95

Perturbation-based Attribution

33

34 of 95

Perturbation-based: The principle

Perturbed inputs

What a great example.

What a great example.

What a great example.

What a great example.

Logit scores

0.8

0.9

0.4

0.8

Attribution

What a great example.

34

Model

Aggregation

How do we perturb samples?

How do we aggregate scores?

35 of 95

How do we perturb inputs?

Text inputs

Token ids

Token embeddings

Transformer output

Classification output

Generation output ids

Generation output text

  • We cannot perturb the text without knowing how it is tokenized.

  • Perturbed token ids are replaced by the [MASK] token id or removed.

  • Which token to perturb depend on the attribution method.

  • We can vary the granularity

(tokens / words / sentences)

OR

35

Perturbations

36 of 95

Some example of perturbation-based methods

  • A method is defined by its perturbation and aggregation.

  • Most methods can be adapted from computer vision.

Paper

Method

Perturbation

Aggregation

Occlusion

One by one

Mapping

Lime

Random

Linear regression

Rise

Random

Mean

Sobol

Sobol sampling

Sobol indices

37 of 95

SHAP techniques

37

  • Given a set of features, we need to find the marginal contribution of each feature to the prediction.

  • We therefore need to imagine a basic predicted value, and how each feature forces the prediction to deviate from this basic value.

38 of 95

SHAP-SHapley Additive exPlanation

38

  • A general method that uses Shapley values to measure the importance of each feature (or "player") in an input, in order to explain a model’s predictions.

  • SHAP is not just an extension or a rebranding of Shapley values. It provides an additive model (that links Shapley Values to LIME) and provides efficient ways to estimate the Shapley Values

39 of 95

SHAP-SHapley Additive exPlanation

39

  • Text classification: easy case

Generally we have a score (sentiment analysis) or a distribution (text categorization), so we can use SHAP as for regression

  • Text generation: still challenging

Contrary to tabular data, we do not have a dataset, but only a prompt. So the expected value cannot be used and must be replaced (different strategies)

40 of 95

SHAP-SHapley Additive exPlanation

40

Example: sentiment analysis

41 of 95

SHAP-SHapley Additive exPlanation

41

Example: summarization

42 of 95

Gradient-based Attribution

42

43 of 95

Gradient-based: The principle

Inputs

What a great example.

Outputs

Positive review

Attribution

What a great example.

43

Forward

Where do we compute the gradient?

How do we aggregate gradients?

Backward

44 of 95

Where do we compute the gradient?

  • The embedding operation is not differentiable.

  • We derive from the token embeddings to the selected logits.

  • Therefore the gradient shape is
    • Classification (n, l, d)
    • Generation (n, g, l + g, d)

  • We aggregate on the l dimension via mean of absolute values.

Text inputs

Token ids (n, l)

Token embeddings (n, l, d)

Transformer output (n, l, d)

Classification output (n, c)

Generation output ids (n, g)

Generation output text

OR

44

Gradient

Gradient

45 of 95

Some example of gradient-based methods

  • Similarly to perturbation-based methods, a gradient-based method is defined by its perturbation and aggregation.

  • Most methods can be adapted from computer vision.

Paper

Method

Perturbation

Aggregation

Saliency

None

None

Integrated Gradient

Linear interpolation

Mean

SmoothGrad

Gaussian noise

Mean

VarGrad

Gaussian noise

Variance

46 of 95

Concept-based methods

“Showing where a network is looking does not tell us what the network is seeing in a given input”

46

47 of 95

What is a concept?

47

“A concept is an abstraction of

common elements between samples“

48 of 95

A drawing field

48

2018 CAV & TACV

2019 ProtoPNet, ACE

2020 CBM, ProtoTree

2021 ICE, ICB,

2022 CRAFT, CAR

2023 Cockatiel, Holistic, Mech. Inter.

2024 SAEs, Anthropic, Deep Mind…

49 of 95

Concept-based motivations

49

  • They better resemble the way humans reason and explain (Kim et al., 2023)

  • They are more stable (similar inputs yield similar explanations) under perturbation (Melis et al., 2018)

  • They better detect model biases (Rishabh et al, 2022)

50 of 95

Concept-based: classification task

50

Adapted from Fanny Jourdan’s slides

51 of 95

Concept-based: classification task

51

Adapted from Fanny Jourdan’s slides

52 of 95

Concept-based: application

Bias Detection Task ❗🔍

Adapted from Fanny Jourdan’s slides

53 of 95

Concept-based: application

Bias Detection Task ❗🔍

Adapted from Fanny Jourdan’s slides

54 of 95

Concept-based methods taxonomy

54

Ante-hoc

The model is trained to reason from concepts

Post-hoc

Concepts are identified within the trained model

Supervised

Requires labelled concepts

Unsupervised

Annotation free

55 of 95

Pros and cons: our analysis!

55

Pros

Cons

Supervised

  • Relatable to experts
  • Labour (annotation of examples)
  • Human biases
  • Generalization

Unsupervised

  • Knowledge discovery
  • Scales to new domains
  • Challenging to interpret
  • Unstable
  • Requires large data and compute

Ante-hoc

  • For well-defined tasks, combined with supervised approaches
  • Never competes in performance
  • Not always more interpretable

Post-hoc

  • Applicable to any model
  • Improves with model performance
  • Might not align with expert knowledge

56 of 95

Common points

  • Local interpretation has three steps:
    • Which concepts are present
    • Where in the text
    • How do they contribute

  • Global interpretation studies the general link between the concepts and the classes

56

57 of 95

A framework for post-hoc unsupervised C-XAI

[PhD. C. Claye]

57

58 of 95

A framework for post-hoc unsupervised C-XAI

[PhD. C. Claye]

58

[1]

[2] / [1]

[3]

[4]

59 of 95

A framework for post-hoc unsupervised C-XAI

[PhD. C. Claye]

59

[2] / [1]

[3]

NMF [1], SAE [2]

60 of 95

A framework for post-hoc unsupervised C-XAI

[PhD. C. Claye]

60

[1]

[2]

61 of 95

A framework for post-hoc unsupervised C-XAI

[PhD. C. Claye]

61

[1]

[2]

62 of 95

COCKATIEL

62

63 of 95

Evaluation and metrics

63

64 of 95

Evaluation and metrics

  • Metrics evaluate one of the three parts:
    • Concept extraction
      • Faithfulness (completeness, FID, MAE…)
      • Complexity (sparsity, conciseness…)
    • Concept interpretation
      • AutoInterpret
    • Concept importance (see attribution metrics)

  • There are also human evaluation with comprehensibility.

64

65 of 95

ConSim: an end2end metric based on simulatability [PhD. Poché]

65

66 of 95

Research-centered explanation

Mechanistic Interpretability

66

Generated with Sora

67 of 95

Motivations

67

Scientific curiosity

Prevent misalignment

Improve models

Generated with Sora

68 of 95

Etymology

  • Causal Mechanism + Interpretability

  • Explainability is called interpretability in NLP

  • The term “mechanistic interpretability” was first used by Chris Olah and colleagues in their distill.pub Circuit Thread from March 2020 to April 2021

68

69 of 95

Definition

69

Narrow technical definition

A technical approach to understanding neural networks through their causal mechanisms.

Reverse engineering

Broad technical definition

Any research that describes the internals of a model, including its activations or weights.

Narrow cultural definition

Any research originating from the mechanistic interpretability community.

Broad cultural definition

Any research in the field of AI—especially

LM—interpretability.

70 of 95

History

NLP Interpretability (2016+)

  • Comes from the NLP community
  • Vector semantics
  • Attributions
  • Neuron analysis and localization
  • Component analysis and probing

Mechanistic interpretability (2020+)

  • Comes from the ML community
  • Does anything but saliency maps
  • Driven by LLM companies
  • Initially communicated in blog posts

70

71 of 95

History

71

Generated with Sora

72 of 95

Transformers Architecture

  • Input: Sequences of words
  • Output: Probability distribution over the next word
  • Residual stream: A sequence of representations
    • One for each input word, per layer!
    • Each layer is an incremental update - stream is a running total
    • Represents the word plus context
  • Attention: Moves information between words
    • Made up of heads, each acts independently and in parallel
    • We try to interpret heads!
  • MLP: Processes information once it’s been moved to a word

72

73 of 95

Logit Lens

  • Apply the unembedding at different layers of the model

  • Subject to distribution shift

73

74 of 95

Landscape

74

Key concepts

Hypothesis

75 of 95

Features & Superposition

75

Features Definition: Features are the fundamental units of neural network representations that cannot be further decomposed into simpler independent factors.

Superposition Hypothesis: Neural networks represent more features than they have neurons by encoding features in overlapping combinations of neurons.

76 of 95

Linear Representation Hypothesis

76

Linear Representation Hypothesis: Neural networks represent more features than they have neurons by encoding features in overlapping combinations of neurons.

77 of 95

Probes

  • On a model’s latent activations

  • Train a single output linear model

  • Compare probes performance on different location to know when and where information gets linearly accessible in a model.

77

78 of 95

Probes versus Logit Lens

78

79 of 95

Sparse Auto-Encoders (SAEs)

  • Concept-based explanation

  • Scaling and overcomplete dictionaries

  • Activation and architecture variants: ReLU/Vanilla, TopK, JumpReLU, BatchTopK, Matryoshka, Hierarchical, Archetypal…

  • Position variants: transcoder, crosscoders…

79

80 of 95

SAEs on Claude 3.5 Sonnet: Golden Gate Claude

80

81 of 95

Circuits & Motifs

81

Circuits Definition: Circuits are sub-graphs of the network, consisting of features and the weights connecting them.

Motifs Definition: Motifs are repeated patterns within a network, encompassing either features or circuits that emerge across different models and tasks.

82 of 95

Causal Interventions

Aka Activation Patching aka Causal Tracing aka Resample Ablating

  • Replace some activations on sample A by activations from sample B

  • Goals:
    • Discovering circuits
    • Steering models

82

83 of 95

Indirect Object Identification circuit

83

84 of 95

Universality

84

Universality Hypothesis: Neural networks trained on similar tasks tend to develop common features, circuits, and computational motifs that reflect shared underlying learning principles. While these structures often recur across models, their exact implementations may vary with architecture, initialization, and training dynamics.

85 of 95

Emergent properties:

85

Simulation Hypothesis: A model whose objective is text prediction will simulate the causal processes underlying the text creation if optimized sufficiently strongly.

Prediction Orthogonality Hypothesis: A model whose objective is prediction can simulate agents who optimize toward any objectives with any degree of optimality.

86 of 95

Some Results

86

87 of 95

Our takes

  • Streetlight interpretability

  • Too complex to apply in practice (for now)

  • Lacks social science insights, psychology and human machine interaction (dismiss human biases)

  • Mechanistic interpretability can only be done by researchers

  • It requires large compute

87

88 of 95

To summarize

88

Analyzes input-output relations.

Quantifies individual input feature influences.

Identifies high-level representations governing behavior.

Uncovers precise causal mechanisms from inputs to outputs.

89 of 95

Other challenges and opportunities for generation

89

90 of 95

LLMs for explanation

Many recent approaches based on prompt-based explanations

But, an important debate

91 of 95

Practice with Interpreto

Attribution and concepts

Link to the notebook

91

92 of 95

Interpreto Team

92

Gabriele

Thomas

Fanny

Antonin

Fred

Charlotte

Corentin

+ Raphael

93 of 95

Thank you for you attention!

94 of 95

94

95 of 95

References

[1] Koh et al, Concept Bottleneck Models. ICML 2020

[2] Chen et al, This Looks Like That: Deep Learning for Interpretable Image Recognition, NeurIPS 2019

[3] Kim et al, Interpretability Beyond Feature Attribution: Quantitative Testing with Concept Activation Vectors (TCAV). ICML

[4] Ghorbani et al, Towards Automatic Concept-based Explanations. NeurIPS 2019

[5] Fel et al, CRAFT: Concept Recursive Activation FacTorization for Explainability, CVPR 2023

95