cdpierse / transformers-interpret

Model explainability that works seamlessly with 🤗 transformers. Explain your transformers model in just 2 lines of code.
Apache License 2.0
1.29k stars 97 forks source link

Feature/add nsteps param Closes #51 #54

Closed cdpierse closed 3 years ago

cdpierse commented 3 years ago

PR Description

This PR adds two new optional parameters to every explainer these are n_steps and internal_batch_size.

Both of these parameters are passed directly into Captum's LIGAttribution instance. n_steps controls how many steps occur from the integration between baseline inputs and actual inputs, in theory the more steps the more stable the explanations, increasing n_steps will increase the time it takes to calculate attributions, the default value in Captum is 50.

internal_batch_size is used to control the batch size of inputs. This feature is particularly useful for instances where transformers-interpret was going OOM due to the amount of gradient accumulation in one step (#51). Lowering internal_batch_size should greatly reduce memory overhead in situations where a single batch of gradients would cause OOM.

Motivation and Context

References issue: # (ISSUE)

Tests and Coverage

Types of changes

Final Checklist: