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

AttributeError: 'OutputSeq' object has no attribute 'saliency' #86

Open
Claus1 opened this issue Dec 5, 2022 · 4 comments
Open

AttributeError: 'OutputSeq' object has no attribute 'saliency' #86

Claus1 opened this issue Dec 5, 2022 · 4 comments

Comments

@Claus1
Copy link

Claus1 commented Dec 5, 2022

captum 0.5.0
torch 1.13.0+cu117

Language_Models_and_Ecco_PyData_Khobar.ipynb

text= "The countries of the European Union are:\n1. Austria\n2. Belgium\n3. Bulgaria\n4."
output_3 = lm.generate(text, generate=20, do_sample=True)
output_3.saliency()

AttributeError Traceback (most recent call last)
Cell In [13], line 1
----> 1 output_3.saliency()

AttributeError: 'OutputSeq' object has no attribute 'saliency'

@JoaoLages
Copy link
Contributor

We changed the name, use output_3.primary_attributions() instead. Check here for more options and information.

@verazuo
Copy link

verazuo commented Jul 30, 2023

After change it to output_3.primary_attributions(), I got following errors:

╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ in <module>:3                                                                                    │
│                                                                                                  │
│   1 text= "The countries of the European Union are:\n1. Austria\n2. Belgium\n3. Bulgaria\n4.     │
│   2 output = lm.generate(text, generate=20, do_sample=True)                                      │
│ ❱ 3 output.primary_attributions()                                                                │
│   4                                                                                              │
│                                                                                                  │
│ /home/xxx/anaconda3/envs/py39/lib/python3.9/site-packages/ecco/output.py:252 in                 │
│ primary_attributions                                                                             │
│                                                                                                  │
│   249 │   │   importance_id = position - self.n_input_tokens                                     │
│   250 │   │   tokens = []                                                                        │
│   251 │   │                                                                                      │
│ ❱ 252 │   │   assert attr_method in self.attribution, \                                          │
│   253 │   │   │   f"attr_method={attr_method} not found. Choose one of the following: {list(se   │
│   254 │   │   attribution = self.attribution[attr_method]                                        │
│   255 │   │   for idx, token in enumerate(self.tokens[0]):                                       │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
AssertionError: attr_method=grad_x_input not found. Choose one of the following: []

Any ideas?

@JoaoLages
Copy link
Contributor

Right, you need to pass attribution="grad_x_input" in the lm.generate call

@verazuo
Copy link

verazuo commented Jul 31, 2023

thx, after passing attribution=["grad_x_input"] in the lm.generate(), it works!

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