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: 'str' object has no attribute 'shape' #516

Open
1 of 2 tasks
spol25 opened this issue Aug 2, 2024 · 5 comments
Open
1 of 2 tasks

AttributeError: 'str' object has no attribute 'shape' #516

spol25 opened this issue Aug 2, 2024 · 5 comments

Comments

@spol25
Copy link

spol25 commented Aug 2, 2024

System Info / 系統信息

Google Colab A100 Cuda

Who can help? / 谁可以帮助到您?

I am using the script in https://huggingface.co/THUDM/cogvlm-base-224-hf but I get this error:

~/.cache/huggingface/modules/transformers_modules/THUDM/cogvlm-base-224-hf/cf0930a30d930c4ad0de393726385591a0271567/modeling_cogvlm.py in llm_forward(self, input_ids, token_type_ids, attention_mask, position_ids, past_key_values, inputs_embeds, use_cache, output_attentions, output_hidden_states, return_dict)
439
440 if past_key_values is not None:
--> 441 past_key_values_length = past_key_values[0][0].shape[2]
442 seq_length_with_past = seq_length_with_past + past_key_values_length
443

AttributeError: 'str' object has no attribute 'shape'

Information / 问题信息

  • The official example scripts / 官方的示例脚本
  • My own modified scripts / 我自己修改的脚本和任务

Reproduction / 复现过程

I ran the script from both THUDM/cogvlm-chat-hf as well as THUDM/cogvlm-base-224-hf with several different formats of images but always get the same error. I double checked that the inputs are all of the right expected type.

Expected behavior / 期待表现

2 weeks ago, when I ran the script, I did not get this error. Instead it'd generate a valid word/sentence output.

@cocoshe
Copy link

cocoshe commented Aug 4, 2024

You can refer the issue here #517 , add a simple _ in the modeling code, or just install a older version(<4.42.0) of transformers lib can work.

@kkkwjr
Copy link

kkkwjr commented Nov 28, 2024

Why I can't modify the code? Every time I make changes and run it, the code reverts back to its original state.

@cocoshe
Copy link

cocoshe commented Nov 28, 2024

Why I can't modify the code? Every time I make changes and run it, the code reverts back to its original state.

Remove the python cache may work?

@kkkwjr
Copy link

kkkwjr commented Nov 28, 2024

Why I can't modify the code? Every time I make changes and run it, the code reverts back to its original state.

Remove the python cache may work?

thanks,i will try it. choose the version of 4.36.2 may also works

@cocoshe
Copy link

cocoshe commented Nov 28, 2024

Why I can't modify the code? Every time I make changes and run it, the code reverts back to its original state.

Remove the python cache may work?

thanks,i will try it. choose the version of 4.36.2 may also works

Set the specific version is the optimal solution 👀

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