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

关于 example size 的问题 #4

Closed
qitianyuu opened this issue Apr 20, 2023 · 4 comments
Closed

关于 example size 的问题 #4

qitianyuu opened this issue Apr 20, 2023 · 4 comments

Comments

@qitianyuu
Copy link

hi,
我在运行样例代码中遇到下面问题:

ValueError: Attention mask should be of size (1, 1, 30, 30), but is torch.Size([1, 30, 30])

我只替换了样例代码的pretrained_model_dir路径,我用的是经过训练之后的llama-7B 模型,大约26GB大小。

我并没有对example进行更改,同时检查了example的尺寸

>>> example.get("input_ids").shape
torch.Size([1, 30])
>>> example.get("attention_mask").shape
torch.Size([1, 30])

请问这个报错和transformers版本有关系吗?

我的transformers版本是最新的版本。Commits on Apr 20, 2023(474bf508dfe0d46fc38585a1bb793e5ba74fddfd)

@PanQiWei
Copy link
Collaborator

噢!是我的疏忽,llama 的 attention_mask 在进入到 transformer layer 之前需要被 reshape, 类似于 opt。我一会就把这个修复掉,如果你想快速体验的话,可以在 auto_gptq.modeling.llama 里覆写以下函数:

@staticmethod
def _resize_attention_mask(attention_mask):
        attention_mask = [attention_mask.unsqueeze(1) for attention_mask in attention_mask]
        return attention_mask

然后从源码重新安装一下,不出意外应该就没问题了。

@PanQiWei
Copy link
Collaborator

噢!是我的疏忽,llama 的 attention_mask 在进入到 transformer layer 之前需要被 reshape, 类似于 opt。我一会就把这个修复掉,如果你想快速体验的话,可以在 auto_gptq.modeling.llama 里覆写以下函数:

@staticmethod
def _resize_attention_mask(attention_mask):
        attention_mask = [attention_mask.unsqueeze(1) for attention_mask in attention_mask]
        return attention_mask

然后从源码重新安装一下,不出意外应该就没问题了。

还有一些其他的问题,我会统一进行修复

@qitianyuu
Copy link
Author

好的!多谢🙏

1 similar comment
@qitianyuu
Copy link
Author

好的!多谢🙏

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

2 participants