Sobol Attribution¶
Bases: MultitaskExplainerMixin
, AttributionExplainer
Sobol is a variance-based sensitivity analysis method used to quantify the contribution of each input component to the output variance of the model.
It estimates both the first-order (main) and total (interaction) effects of features using Monte Carlo sampling strategies. In NLP, Sobol helps assess which words or tokens are most influential for the model’s decision, including how they interact with one another.
Reference: Fel et al. (2021). Look at the variance! Efficient black-box explanations with Sobol-based sensitivity analysis. Paper
Examples:
>>> from interpreto import Granularity, Sobol
>>> from interpreto.attributions import InferenceModes
>>> method = Sobol(model, tokenizer, batch_size=4,
>>> inference_mode=InferenceModes.LOGITS,
>>> n_token_perturbations=8,
>>> granularity=Granularity.WORD,
>>> sobol_indices_order=Sobol.sobol_indices_orders.FIRST_ORDER,
>>> sampler=Sobol.samplers.SOBOL))
>>> explanations = method(text)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
PreTrainedModel
|
model to explain |
required |
|
PreTrainedTokenizer
|
Hugging Face tokenizer associated with the model |
required |
|
int
|
batch size for the attribution method |
4
|
|
Granularity
|
The level of granularity for the explanation (e.g., token, word, sentence). |
WORD
|
|
Callable[[Tensor], Tensor]
|
The mode used for inference. It can be either one of LOGITS, SOFTMAX, or LOG_SOFTMAX. Use InferenceModes to choose the appropriate mode. |
LOGITS
|
|
int
|
the number of perturbations to generate |
32
|
|
SobolIndicesOrders
|
Sobol indices order, either |
required |
|
SequenceSamplers
|
Sobol sequence sampler, either |
SOBOL
|
|
device
|
device on which the attribution method will be run |
None
|