Welcome to Inseq! π
Note
The Inseq community now has a dedicated Discord server! Join us at https://discord.gg/V5VgwwFPbu to chat with the team and other users, ask questions, and share your work!
Inseq is a Pytorch-based hackable toolkit to democratize the study of interpretability for sequence generation models. At the moment, Inseq supports a wide set of models from the π€ Transformers library and an ever-growing set of feature attribution methods, leveraging in part the widely-used Captum library. For a quick introduction to common use cases, see the Getting started with Inseq page.
Using Inseq, feature attribution maps that can be saved, reloaded, aggregated and visualized either as HTMLs (with Jupyter notebook support) or directly in the console using rich. Besides simple attribution, Inseq also supports features like step score extraction, attribution aggregation and attributed functions customization for more advanced use cases. Refer to the guides in the π Using Inseq section for more details and examples on specific features.
In just a couple lines of code, Inseq can be used to perform the source-side attribution of an English-to-French translation produced by the model Helsinki-NLP/opus-mt-en-fr
from π€ Transformers using the IntegratedGradients
method with 300 integral approximation steps, and returning the attribution convergence delta and token-level prediction probabilties.
import inseq
model = inseq.load_model("Helsinki-NLP/opus-mt-en-fr", "integrated_gradients")
out = model.attribute(
"The developer argued with the designer because she did not like the design.",
n_steps=300,
return_convergence_delta=True,
step_scores=["probability"],
)
out.show()
Inseq is still in early development and is currently maintained by a small team of grad students working on interpretability for NLP/NLG led by Gabriele Sarti. We are working hard to add more features and models. If you have any suggestions or feedback, please open an issue on our GitHub repository. Happy hacking! π
β
- Inseq CLI
- Main Functions
- Models
AttributionModel
AttributionModel.model
AttributionModel.model_name
AttributionModel.is_encoder_decoder
AttributionModel.pad_token
AttributionModel.embed_scale
AttributionModel.device
AttributionModel.attribution_method
AttributionModel.is_hooked
AttributionModel.default_attributed_fn_id
AttributionModel.attribute()
AttributionModel.configure_interpretable_embeddings()
AttributionModel.forward()
AttributionModel.remove_interpretable_embeddings()
AttributionModel.setup()
- Framework Classes
- Architectural Classes
- Final Classes
- Attribution Methods
- Aggregators
- Step Functions
- Aggregation Functions
- Data Classes