Skip to content

Fix Chefer and add standardized API#841

Merged
jhnwu3 merged 15 commits intosunlabuiuc:masterfrom
Logiquo:fix/chefer
Feb 11, 2026
Merged

Fix Chefer and add standardized API#841
jhnwu3 merged 15 commits intosunlabuiuc:masterfrom
Logiquo:fix/chefer

Conversation

@Logiquo
Copy link
Collaborator

@Logiquo Logiquo commented Feb 11, 2026

This PR furthur enhance the interpretability API

  1. Move interpretability related API to a separate ABC Interpretable for model want to be interpretable to inherite, this make the BaseModel ABC cleaner
  2. Create a new API called CheferInterpretable for Chefer specific API
  3. Remove Chefer model specific attribution implementation, and use Chefere specific API to fetch information instead.

Model

  • Transformer
  • StageAttn
  • ViT (will be defered to later PR)

Methods

  • Chefer

@Logiquo Logiquo changed the title Fix/chefer Fix Chefer Feb 11, 2026
@Logiquo Logiquo changed the title Fix Chefer Fix Chefer and add standardlized API Feb 11, 2026
@Logiquo Logiquo changed the title Fix Chefer and add standardlized API Fix Chefer and add standardized API Feb 11, 2026
@Logiquo Logiquo marked this pull request as ready for review February 11, 2026 03:44
@Logiquo Logiquo requested a review from jhnwu3 February 11, 2026 05:38
Copy link
Collaborator

@jhnwu3 jhnwu3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

everything else lgtm. I like the idea of defining Interpretable abstractions as technically it is different.

I also think there are technically 3-4 types of "Interpretable" abstractions as I'm categorizing them in the literature:

  1. Black-box interpreters, which if we properly implement them, technically shouldn't need to have access to embeddings at all. We may need to revisit SHAP and LIME's design later.
  2. Counterfactual based, GIM, DeepLift, and Integrated Gradients all require hooks + embedding access. I guess this is our Interpretable abstraction atm
  3. Attention-based (CheferInterpretable)
  4. Convolution-based (GradCAM, CAM, etc.) - not yet implemented, but are very much related

class_index=None,
**data,
) -> Dict[str, torch.Tensor]:
"""[REFERENCE ONLY] Original ViT-specific Chefer attribution.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a clarification question, I guess it's because our TorchVision wrapper doesn't/can't support a CheferInterpretable here due to technically not being a static model?

https://github.com/sunlabuiuc/PyHealth/blob/master/pyhealth/models/torchvision_model.py

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Due to i haven't had time to modify the ViT yet🤣, technically nothing stop it from happening. but given that we are working on interpretability project more, i want to fix the most relavent model first.

Copy link
Collaborator

@jhnwu3 jhnwu3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, we can iterate further on the API later when we finalize some of these things.

@jhnwu3 jhnwu3 merged commit fcd0a2b into sunlabuiuc:master Feb 11, 2026
1 check passed
@Logiquo Logiquo deleted the fix/chefer branch February 12, 2026 02:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants