Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Embeddings defaults to model.get_input_embeddings() for all models #21

Merged
merged 1 commit into from
Feb 27, 2021

Conversation

cdpierse
Copy link
Owner

  • This is a small change but adds compatibility for most if not all models in the HF library when fetching embeddings
  • This change is opinionated and now only selects input embeddings (word embeddings) as the embeddings from which it calculates attributions along.
  • I'm still researching this a bit to sanity check this as a choice, there are subtle but real differences between the attributions when using input embeddings versus Bert like models model.bert.embeddings which is usually a collection of embedding layers.
  • I'll convert this to a regular PR when I feel a bit more sure of the decision.

@cdpierse cdpierse marked this pull request as ready for review February 27, 2021 13:28
@cdpierse
Copy link
Owner Author

This feels ready to merge now. I've been reading how members of the Captum team are doing this and from what I've seen they are also commonly using word_embeddings/get_input_embeddings() for calculating attributions (see pytorch/captum#592 ).

There certainly are cases where embeddings w.r.t position and token type might be useful (layer conductance) but the library currently doesn't have support for that level of model introspection.

@cdpierse cdpierse merged commit c97e50b into master Feb 27, 2021
@cdpierse cdpierse deleted the feature/use-word-input-embeddings-only branch September 15, 2022 11:41
This pull request was closed.
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.

1 participant