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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example for LMGradientAttribution is missing. #1237

Open
saxenarohit opened this issue Jan 31, 2024 · 4 comments
Open

Example for LMGradientAttribution is missing. #1237

saxenarohit opened this issue Jan 31, 2024 · 4 comments

Comments

@saxenarohit
Copy link

saxenarohit commented Jan 31, 2024

馃摎 Documentation

This is in reference to the tutorial page below.
https://captum.ai/tutorials/Llama2_LLM_Attribution

I could not find the example for LLMGradientAttribution for LLAMA2.

Any help on this will be appreciated.

Thanks

@aobo-y
Copy link
Contributor

aobo-y commented Jan 31, 2024

@saxenarohit thanks for reminding us. We will add it soon

@Dongximing
Copy link

Hi aobo, if you are busy, could you tell me which model layer need I take as a parameters in the LayerIntegratedGradients ?

@aobo-y
Copy link
Contributor

aobo-y commented Mar 22, 2024

hi @Dongximing , it should be the embedding layer of your model. As a token is discrete, its backpropagate gradient stop at its embedding. For Llama2, it would something like the following

emb_layer = model.get_submodule("model.embed_tokens")
lig = LayerIntegratedGradients(model, emb_layer)

@Dongximing
Copy link

Thanks, I saw the result, and analysis the code, the final results are computed on log_softmax. and is that means if a contribution in this way, -10,20,-20. the token_1 and token_2 are both important? or we need "abs()" to eval the important of tokens?

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

No branches or pull requests

3 participants