Expand XAI notebooks with perturbation, TCAV, and attention vs attribution#28
Expand XAI notebooks with perturbation, TCAV, and attention vs attribution#28aravind-3105 merged 18 commits intomainfrom
Conversation
|
@shainarazavi I've added the extra notebooks we wanted to add to expand the refresher implementation. The main files to be checked are
|
There was a problem hiding this comment.
Pull request overview
This PR expands the implementations/xai_refresher module documentation and environment setup to support additional advanced XAI notebooks (perturbation/robustness, TCAV, attention vs attribution), and updates the dependency group/lockfile accordingly.
Changes:
- Added new interpretability dependencies to the
ref1-refresher-interpretabilitygroup and updateduv.lock. - Updated
implementations/xai_refresher/README.mdto document notebooks 5–8 and reorganize further reading. - Adjusted the Jupyter kernelspec metadata in
concept_grounding.ipynb.
Reviewed changes
Copilot reviewed 3 out of 8 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
uv.lock |
Adds new resolved packages for the expanded notebook environment (but currently contains duplicated package entries). |
pyproject.toml |
Extends ref1-refresher-interpretability with new libraries for the added notebooks (but currently missing datasets). |
implementations/xai_refresher/concept_grounding.ipynb |
Updates kernelspec metadata to match the environment naming used by newer notebooks. |
implementations/xai_refresher/README.md |
Documents new notebook sequence, interconnections, and expands/reorganizes references. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| "captum>=0.8.0", | ||
| "huggingface-hub>=1.3.4", | ||
| "bertviz>=1.4.1", |
There was a problem hiding this comment.
ref1-refresher-interpretability is missing the datasets dependency, but the new notebooks/docs require it (e.g., tcav_concept_sensitivity.ipynb imports datasets). Please add datasets to this dependency group and regenerate uv.lock so the environment matches the README/setup instructions.
|
@aravind-3105 some of them are PRs to run locally, lets meet tommorow and dry run and get it done |
shainarazavi
left a comment
There was a problem hiding this comment.
we can dry run, however, from a quick review,check the model vs clf_model naming collision, also is`` def gradient_token_importance(text, target_class=None): defined twice??
shainarazavi
left a comment
There was a problem hiding this comment.
That line appears twice, once for the train results, once for the test features:
python data = torch.load(test_features_path, map_location="cpu")
Both calls omit weights_only=True, meaning arbitrary pickle code can execute on load. is it a design choice?
shainarazavi
left a comment
There was a problem hiding this comment.
Great work Aravind, we can dry run. Just a quick question but this line:
num_layers = len(model(**tokenizer("test", return_tensors="pt").to(device)).hidden_states) runs a full forward pass just to count layers, which is wasteful. And profession_concept is defined twice , i think once as full sentences, once as single words. I think we can pick one form and define it once.
|
@aravind-3105 Thanks for the great work! Please feel free to merge the PR at your convenience. |
d13d16b to
3522393
Compare
… implementation 1
…ttribution and adjust library dependencies
… implementation 1
…nd update README for clarity on index-url requirements
…e and improving function definitions
…ution and perturbation_robustness_captum_image notebooks
… and attention notebooks
18bff8b to
20c0351
Compare
Summary
This pull request significantly expands the
xai_refreshermodule's documentation and dependencies to support four new advanced notebooks (perturbation, robustness, TCAV, and attention vs attribution) and clarifies their interconnections. It also updates the recommended setup, adds required libraries, and reorganizes further reading references for clarity and completeness.Clickup Ticket(s): Link(s) if applicable.
Type of Change
Changes Made
Notebooks and Documentation Enhancements:
captum,transformers,datasets,bertviz) needed for the new notebooks.Dependencies and Environment:
captum,huggingface-hub, andbertvizto theref1-refresher-interpretabilitydependency group inpyproject.tomlto support the new notebooks.concept_grounding.ipynbfor consistency with the new environment.Reference Materials:
Testing
uv run pytest tests/)uv run mypy <src_dir>)uv run ruff check src_dir/)Manual testing details:
Screenshots/Recordings
Related Issues
Deployment Notes
Checklist