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

inseq assertion error #21

Closed
qiaw99 opened this issue Dec 4, 2023 · 7 comments
Closed

inseq assertion error #21

qiaw99 opened this issue Dec 4, 2023 · 7 comments
Assignees
Labels
bug Something isn't working

Comments

@qiaw99
Copy link
Collaborator

qiaw99 commented Dec 4, 2023

Prompt:

show me the 5 most important features for data point 730 by attention

Error Track:

  File "C:\Users\87290\DFKI\LLMCheckup\flask_app.py", line 267, in get_bot_response
    response = BOT.update_state(user_text, conversation)
  File "C:\Users\87290\DFKI\LLMCheckup\logic\core.py", line 536, in update_state
    returned_item = run_action(
  File "C:\Users\87290\DFKI\LLMCheckup\logic\action.py", line 49, in run_action
    action_return, action_status = actions[p_text](
  File "C:\Users\87290\DFKI\LLMCheckup\actions\explanation\feature_importance.py", line 130, in feature_importance_operation
    out_agg = out.aggregate(inseq.data.aggregator.SubwordAggregator)
  File "C:\Users\87290\anaconda3\envs\llm\lib\site-packages\inseq\data\attribution.py", line 617, in aggregate
    aggregated.sequence_attributions[idx] = seq.aggregate(aggregator, **kwargs)
  File "C:\Users\87290\anaconda3\envs\llm\lib\site-packages\inseq\data\aggregator.py", line 249, in aggregate
    return aggregator.aggregate(
  File "C:\Users\87290\anaconda3\envs\llm\lib\site-packages\inseq\data\aggregator.py", line 720, in aggregate
    return super().aggregate(attr, source_spans=source_spans, target_spans=target_spans, **kwargs)
  File "C:\Users\87290\anaconda3\envs\llm\lib\site-packages\inseq\data\aggregator.py", line 546, in aggregate
    return super().aggregate(attr, source_spans=source_spans, target_spans=target_spans, **kwargs)
  File "C:\Users\87290\anaconda3\envs\llm\lib\site-packages\inseq\data\aggregator.py", line 102, in aggregate
    cls.post_aggregate_hook(aggregated, **kwargs)
  File "C:\Users\87290\anaconda3\envs\llm\lib\site-packages\inseq\data\aggregator.py", line 337, in post_aggregate_hook
    cls.is_compatible(attr)
  File "C:\Users\87290\anaconda3\envs\llm\lib\site-packages\inseq\data\aggregator.py", line 432, in is_compatible
    assert attr.target_attributions.shape[1] == attr.attr_pos_end - attr.attr_pos_start
AssertionError

prompt:

primary features of data point 3444 by input gradient
  File "C:\Users\87290\DFKI\LLMCheckup\flask_app.py", line 267, in get_bot_response
    response = BOT.update_state(user_text, conversation)
  File "C:\Users\87290\DFKI\LLMCheckup\logic\core.py", line 536, in update_state
    returned_item = run_action(
  File "C:\Users\87290\DFKI\LLMCheckup\logic\action.py", line 49, in run_action
    action_return, action_status = actions[p_text](
  File "C:\Users\87290\DFKI\LLMCheckup\actions\explanation\feature_importance.py", line 120, in feature_importance_operation
    out = inseq_model.attribute(
  File "C:\Users\87290\anaconda3\envs\llm\lib\site-packages\inseq\models\attribution_model.py", line 445, in attribute
    attribution_outputs = attribution_method.prepare_and_attribute(
  File "C:\Users\87290\anaconda3\envs\llm\lib\site-packages\inseq\attr\attribution_decorators.py", line 71, in batched_wrapper
    out = f(self, *args, **kwargs)
  File "C:\Users\87290\anaconda3\envs\llm\lib\site-packages\inseq\attr\feat\feature_attribution.py", line 237, in prepare_and_attribute
    attribution_output = self.attribute(
  File "C:\Users\87290\anaconda3\envs\llm\lib\site-packages\inseq\attr\feat\feature_attribution.py", line 372, in attribute
    attr_pos_start, attr_pos_end = check_attribute_positions(
  File "C:\Users\87290\anaconda3\envs\llm\lib\site-packages\inseq\attr\feat\attribution_utils.py", line 85, in check_attribute_positions
    raise ValueError("Start and end attribution positions cannot be the same.")
ValueError: Start and end attribution positions cannot be the same.
@qiaw99 qiaw99 added the bug Something isn't working label Dec 4, 2023
@qiaw99 qiaw99 closed this as completed Jan 6, 2024
@qiaw99 qiaw99 reopened this Jan 10, 2024
@nfelnlp
Copy link
Member

nfelnlp commented Jan 11, 2024

The SubwordAggregator problem is being discussed here: inseq-team/inseq#246

@nfelnlp
Copy link
Member

nfelnlp commented Jan 12, 2024

First issue is finally fixed.

For the second prompt, I get the CUDA error all the time. I can't reproduce the ValueError you posted, @qiaw99 . Can you check again, please? Maybe the CUDA exception is too general and should be caught elsewhere.

@qiaw99
Copy link
Collaborator Author

qiaw99 commented Jan 12, 2024

sure, I will check it again.

@qiaw99
Copy link
Collaborator Author

qiaw99 commented Jan 16, 2024

somehow the first issue is still there.
My input: most significant feature for instance 2322 by attention

Get error:

 File "C:\Users\87290\DFKI\LLMCheckup\flask_app.py", line 273, in get_bot_response
    response = BOT.update_state(user_text, conversation)
  File "C:\Users\87290\DFKI\LLMCheckup\logic\core.py", line 593, in update_state
    returned_item = run_action(
  File "C:\Users\87290\DFKI\LLMCheckup\logic\action.py", line 49, in run_action
    action_return, action_status = actions[p_text](
  File "C:\Users\87290\DFKI\LLMCheckup\actions\explanation\feature_importance.py", line 136, in feature_importance_operation
    out_agg = out.aggregate(SubwordAggregator).aggregate()
  File "C:\Users\87290\anaconda3\envs\llm\lib\site-packages\inseq\data\attribution.py", line 617, in aggregate
    aggregated.sequence_attributions[idx] = seq.aggregate(aggregator, **kwargs)
  File "C:\Users\87290\anaconda3\envs\llm\lib\site-packages\inseq\data\aggregator.py", line 249, in aggregate
    return aggregator.aggregate(
  File "C:\Users\87290\anaconda3\envs\llm\lib\site-packages\inseq\data\aggregator.py", line 720, in aggregate
    return super().aggregate(attr, source_spans=source_spans, target_spans=target_spans, **kwargs)
  File "C:\Users\87290\anaconda3\envs\llm\lib\site-packages\inseq\data\aggregator.py", line 546, in aggregate
    return super().aggregate(attr, source_spans=source_spans, target_spans=target_spans, **kwargs)
  File "C:\Users\87290\anaconda3\envs\llm\lib\site-packages\inseq\data\aggregator.py", line 102, in aggregate
    cls.post_aggregate_hook(aggregated, **kwargs)
  File "C:\Users\87290\anaconda3\envs\llm\lib\site-packages\inseq\data\aggregator.py", line 337, in post_aggregate_hook
    cls.is_compatible(attr)
  File "C:\Users\87290\anaconda3\envs\llm\lib\site-packages\inseq\data\aggregator.py", line 432, in is_compatible
    assert attr.target_attributions.shape[1] == attr.attr_pos_end - attr.attr_pos_start
AssertionError
```

@tanikina
Copy link
Collaborator

Hi @qiaw99 , have you tried re-installing inseq? For me this solved the issue :)
I think there were some recent updates in the inseq repository that affect aggregation: inseq-team/inseq@7503576

@qiaw99
Copy link
Collaborator Author

qiaw99 commented Jan 17, 2024

Ah right, I forget to reinstall Inseq. I will try it :) thanks!

@qiaw99
Copy link
Collaborator Author

qiaw99 commented Jan 17, 2024

Both issues are resolved by using updated inseq. I think we should list 0.6.0-dev in requirements.txt

@qiaw99 qiaw99 closed this as completed Jan 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants